Giter VIP home page Giter VIP logo

labela_backend_assignment's Introduction

Auto API Assignment

Developer Local and Docker Setup ⚙️

Requirements

  • Python 3.8 or higher
  • PostgreSQL (for local setup)
  • Docker (for Docker setup)
  • Docker Compose (for Docker setup)

🧑‍💻 Developer Local Setup

Step 1: Clone the Repository

git clone https://github.com/zpvk/labela_backend_assignment.git
cd your-repository

Step 2: Create a Virtual Environment (Optional but recommended)

python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Set Environment Variables

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

Step 5: Run PostgreSQL Server (If not using Docker)

Make sure your PostgreSQL server is running, and the database and user specified in the .env file are created.

Step 6: Apply Migrations

python manage.py makemigrations
python manage.py migrate

Step 7: Create a Superuser (for accessing the admin panel)

python manage.py createsuperuser

Step 8: Run the Development Server

python manage.py runserver

🧑‍💻 Developer Docker Setup

Repeat Steps 1-2 for Cloning the Repository

Step 3: Run Docker Compose

docker-compose up -d

Step 4: Create Admin user

docker compose run web python manage.py createsuperuser

User Stories and API Endpoints

Access Swagger UI For Quick View Endpoints

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.

API Test Postman

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..

  1. User Registration and Token Retrieval

    • Endpoint: /api/register
    • Method: POST
    • Request Body:
        {   
            "email: "[email protected]",
            "username": "your_username",
            "password": "your_password"
        }
      
  2. Company - Add Products to Database

    • Endpoint: /api/products
    • Method: POST
    • Requires authentication: Yes (Admin)
    • Request Body: Include product details
  3. Client - Add Product to Shopping Cart

    • Endpoint: /api/cart
    • Method: POST
    • Requires authentication: Yes (User)
    • Request Body: Include product details
  4. Client - Remove Product from Shopping Cart

    • Endpoint: /api/cart/<product-id>
    • Method: DELETE
    • Requires authentication: Yes (User)
  5. 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)
  6. Client - View All Products (pagination page number with page size limit)

    • Endpoint: /api/products?page= &page_size=
    • Method: GET
    • Requires authentication: No
  7. Client - View Details of a Product

    • Endpoint: /api/products/<id>
    • Method: GET
    • Requires authentication: No

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.