A demo back-end eCommerce project built with DJango.
-
API Endpoints:
- POST: Create new resources (e.g., products, orders, brands, categories, accounts).
- GET: Retrieve information about resources.
- PUT: Update existing resources.
- DELETE: Remove resources from the system.
-
Dockerization
- Containerized the project using Docker for development, leveraging a PostgreSQL database. For production deployment, integrated Nginx as the reverse proxy server and Gunicorn as the application server.
-
Code Documentation:
- The project codebase includes comprehensive docstrings to provide detailed information about the purpose and usage of functions, classes, and modules. Explore the code to discover inline documentation that enhances code readability and facilitates understanding.
-
Database
- PostgreSQL is used as the database in both development and production.
-
Authorization & Authentication:
- Secure authentication using JSON Web Tokens (JWT) ensures data integrity and user identity verification.
- Clone the Repository:
git clone https://github.com/muzammilmalik01/PriceOye-Django.git cd Price-oye/Simple/priceoye
- Create the virtual environment:
python3 -m venv venv
- Activate Virtual Environment:
source venv/bin/activate
- Install Requirements
pip install -r requirements.txt
- Run Migrations:
python manage.py migrate
- Create Superuser
python manage.py createsuperuser
- Run development server:
python manage.py runserver
- Goto http://127.0.0.1:1337 (/admin) for admin, (/swagger) for swagger dashboard.
- Stop the server: Ctrl + C
- Running Test Cases
python manage.py test
Containerized setup with Dockers, Postgre SQL, Nginx and Gucicorn.
- Dockerfile: Specifies the configuration for the development container.
- docker-compose.yml: Defines services, including Django, PostgreSQL, etc., for local development.
- .env.dev: Stores environment variables specific to the development environment.
- entrypoint.sh: Shell script for setup and initialization during container startup.
NOTE: Please rename env.dev and env.prod to .env.dev and .env.prod
- Ensure Docker is installed.
- Git Clone the project.
- Goto:
cd Price-oye/Dockerized/priceoye/
- Build the Dockers Images:
sudo docker-compose up -d --build
- Run migration:
sudo docker-compose exec web python manage.py migrate --noinput
- Running the dockers:
sudo docker-compose up
- Goto http://127.0.0.1:8000 (/admin) for admin, (/swagger) for swagger dashboard.
- Stopping the dockers:
sudo docker-compose down
- Dockerfile.prod: Specifies the configuration for the production container.
- docker-compose.prod.yml: Defines services for production, including Nginx, Gunicorn, PostgreSQL, etc.
- .env.prod: Stores environment variables specific to the production environment.
- entrypoint.sh.prod: Production version of the entrypoint script.
- Stop development environment:
sudo docker-compose down -v
- Build the Dockers Images:
sudo docker-compose - docker-compose.prod. yml up -d --build
- Run migration:
sudo docker-compose -f docker-compose.prod.yml exec web python manage.py migrate --noinput
- Copy Static Files:
sudo docker-compose -f docker-compose.prod.yml exec web python manage.py collectstatic --no-input --clear
- Run the production server:
sudo docker-compose -f docker-compose.prod.yml up
- In a new terminal, create a superuser:
sudo docker-compose -f docker-compose.prod.yml exec web python manage.py createsuperuser
- Goto http://127.0.0.1:1337 (/admin) for admin, (/swagger) for swagger dashboard.
- Run tests:
sudo docker-compose exec web python manage.py test
- Stopping the dockers:
sudo docker-compose -f docker-compose.prod.yml down