This repository contains the Django backend for a full-stack digital library management system. The backend serves as a RESTful API, handling data operations for book records. The system includes a PostgreSQL database for storing book records.
-
Backend:
- Django
- Django Rest Framework
-
Database:
- PostgreSQL
-
Deployment:
- Docker
-
CI/CD Pipeline:
- GitHub Actions
- Python and pip installed
- PostgreSQL installed and running
- Docker installed (for containerization)
-
Clone the Repository:
git clone https://github.com/hasnat-abdullah/digital_library.git cd digital-library-backend -
Install Dependencies:
# Install backend dependencies pip install -r requirements/local.txt -
Update environment variables:
- Create a PostgreSQL database.
- Create a
.envfile in the root directory of the project. Get necessary variable names fromexample.envand use appropriate values according to environment. - put
DB_HOST=localhostin .env file if you run bypython manage.py runservercommand. If you run by docker-compose then putDB_HOST=dbin .env file.
-
Run Migrations:
# Apply database migrations python manage.py migrate -
Run the Django Development Server:
# Start the Django development server python manage.py runserver -
Seed database with fake data:
# seed db with few data python manage.py seed_db -
Run the following command to create a superuser:
python manage.py createsuperuser
Follow the prompts and provide the required information such as first name, last name, email, and password.
-
Access the API DOC: Open your browser and navigate to
http://localhost:8000/api/v1/doc/re/to access the Django REST API for the digital library.
-
Build & Run Docker Container:
# Run backend container docker-compose -f docker-compose.yml up --build -
Seed Database with fake data
-
Access the shell of the Docker container by running the following command:
docker exec -it <container_name> /bin/bash
Replace
<container_name>with the name or ID of your Docker container. -
Once inside the container's shell, navigate to the project directory:
cd /app -
Run the following command to create a superuser:
python manage.py createsuperuser
Follow the prompts and provide the required information such as first name, last name, email, and password.
-
Run the following command to seed db with some data:
python manage.py seed_db
-
Exit the container's shell:
exit
-
The CI/CD pipeline is set up using GitHub Actions. Check the .github/workflows directory for the workflow configuration.
To ensure high performance and reliability:
- Use Django's built-in caching mechanisms.
- Implement load balancing for distributing incoming traffic.
- Scale the Django backend horizontally by deploying multiple instances.
- Hasnat Abdullah (abdullah.2010bd@gmail.com)
Feel free to contribute by opening issues or submitting pull requests!