- Python 3.8 or higher
- PostgreSQL (for local setup)
- Docker (for Docker setup)
- Docker Compose (for Docker setup)
git clone https://github.com/zpvk/labela_backend_assignment.git
cd your-repository
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Create a .env
file in the project root and add the following variables:
DEBUG=True
SECRET_KEY=my_secret_key
DB_NAME=my_database
DB_USER=my_user
DB_PASSWORD=my_password
DB_HOST=localhost
DB_PORT=5432
Make sure your PostgreSQL server is running, and the database and user specified in the .env
file are created.
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
docker-compose up -d
docker compose run web python manage.py createsuperuser
I have also implemented Swagger, but it is not automatically generated with the Swagger library. Instead, I have integrated it using the Postman collection. Kindly utilize Postman for API testing Visit http://localhost:8000/api/swagger-ui to explore the implemented API endpoints.
To test the endpoint, kindly make use of the Postman collection JSON provided in the repository, named AutoCompanyAPI.postman_collection.json
. The essential endpoints are outlined below. You can import the Postman collection into Postman and perform tests on the specified endpoints..
-
User Registration and Token Retrieval
- Endpoint:
/api/register
- Method: POST
- Request Body:
{ "email: "[email protected]", "username": "your_username", "password": "your_password" }
- Endpoint:
-
Company - Add Products to Database
- Endpoint:
/api/products
- Method: POST
- Requires authentication: Yes (Admin)
- Request Body: Include product details
- Endpoint:
-
Client - Add Product to Shopping Cart
- Endpoint:
/api/cart
- Method: POST
- Requires authentication: Yes (User)
- Request Body: Include product details
- Endpoint:
-
Client - Remove Product from Shopping Cart
- Endpoint:
/api/cart/<product-id>
- Method: DELETE
- Requires authentication: Yes (User)
- Endpoint:
-
Client - Order Products in Shopping Cart with Select Delivery Date and Time
- Endpoint:
/api/checkout
- Method: POST
- Requires authentication: Yes
- Request Body: Include delivery date (User)
- Endpoint:
-
Client - View All Products (pagination page number with page size limit)
- Endpoint:
/api/products?page= &page_size=
- Method: GET
- Requires authentication: No
- Endpoint:
-
Client - View Details of a Product
- Endpoint:
/api/products/<id>
- Method: GET
- Requires authentication: No
- Endpoint: