An open API service indexing awesome lists of open source software.

https://github.com/ehtisham-sadiq/e_commerce_system

A modular FastAPI-based e-commerce system for managing authentication, sellers, buyers, car inventory, sales, and stock with a clean, scalable architecture.
https://github.com/ehtisham-sadiq/e_commerce_system

docker fastapi postgresql python

Last synced: 3 months ago
JSON representation

A modular FastAPI-based e-commerce system for managing authentication, sellers, buyers, car inventory, sales, and stock with a clean, scalable architecture.

Awesome Lists containing this project

README

          

# E-commerce System

## Overview

**This is a FastAPI-based modular web application designed to handle various components of an e-commerce system. The application features user authentication, seller and buyer management, car inventory management, sales tracking, and stock management. The project is structured with clean separation between business logic, routes, and database models, making it scalable and maintainable.**

**Table of Contents**
1. Features
2. Project Structure
3. Setup and Installation
4. Running the Application
5. API Documentation
6. Development Workflow
7. Testing
8. Contributors

### Features
- `JWT-based Authentication`: Secure login and registration with JWT tokens.
- `Seller Management`: Create, update, view, and delete seller profiles.
- `Buyer Management`: Manage buyer profiles and view buyer details.
- `Car Inventory Management`: Add, update, and manage cars for sale.
- `Sales Tracking`: Record and manage sales transactions.
- `Stock Management`: Track stock of cars and manage stock levels.

### Project Structure

This project follows a clean architecture, where each component is isolated into separate modules to improve scalability, maintainability, and testability.
```
├── Procfile # For Heroku deployment
├── README.md # Project documentation
├── app/
│ ├── __init__.py # Initialization file
│ ├── main.py # Application entry point
│ ├── resources/ # Static files or configurations
│ ├── src/
│ │ ├── config.py # Application configuration (DB settings, etc.)
│ │ ├── database.py # Database connection and session management
│ │ ├── dependencies.py # Shared dependencies for the application
│ │ ├── domain/ # Core business logic for various modules
│ │ │ ├── buyer/ # Buyer model, schema, service
│ │ │ ├── seller/ # Seller model, schema, service
│ │ │ ├── car/ # Car model, schema, service
│ │ │ ├── sale/ # Sale model, schema, service
│ │ │ ├── stock/ # Stock model, schema, service
│ │ │ ├── user/ # User model, schema, service for authentication
│ │ ├── internal/ # Internal admin functionality
│ │ ├── routers/ # API endpoints for each module
│ ├── converters/ # Data conversion logic (model to schema)
├── docker-compose.yml # Docker setup for containerized development
├── requirements.txt # Python dependencies
└── runtime.txt # Runtime environment
```

### Setup and Installation

#### Prerequisites
1. Python 3.9+
2. Docker (optional for containerized deployment)
3. Git (for version control)

#### Installation Steps

1. Clone the repository:
```
git clone https://github.com/your-username/fastapi-ecommerce-system.git
cd fastapi-ecommerce-system
```

2. Set up a virtual environment:
```
python3 -m venv env
source env/bin/activate
```

3. Install project dependencies:
```
pip install -r requirements.txt
```

4. Configure environment variables:
- Create a `.env` file in the root directory with the following content:
```
DATABASE_URL=postgresql://your_db_user:your_db_password@localhost:5432/your_db_name
JWT_SECRET=your_jwt_secret
```

#### Running the Application

**Local Development**

To run the FastAPI application locally, follow these steps:

1. Run the application:

```
uvicorn app.main:app --reload
```

2. Access the application:

Open your browser and navigate to:
```
http://localhost:8000
```
The API documentation will be available at:
```
http://localhost:8000/docs
```

For Deployment-Running with Docker. Currently, It is optional.

1. Ensure Docker is installed.
2. Build and run the Docker container:
```
docker-compose up --build
```

#### API Documentation

The API documentation is automatically generated by FastAPI and is available at:

- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc

**Authentication Routes**

| **HTTP Method** | **Route** | **Description** |
|-----------------|----------------|--------------------------------|
| POST | /login | Login user and return token |
| POST | /register | Register a new user |
| GET | /token | Validate JWT token |

------------

**Seller Management Routes**

| **HTTP Method** | **Route** | **Description** |
|-----------------|----------------------------|----------------------------|
| POST | /sellers | Create a new seller |
| GET | /sellers | List all sellers |
| GET | /sellers/{seller_id} | Get seller by ID |
| PUT | /sellers/{seller_id} | Update seller details |
| DELETE | /sellers/{seller_id} | Delete a seller by ID |

**Buyer Management Routes**

| **HTTP Method** | **Route** | **Description** |
|-----------------|------------------------------|-----------------------------|
| POST | /buyers | Create a new buyer |
| GET | /buyers | List all buyers |
| GET | /buyers/{buyer_id} | Get buyer by ID |
| PUT | /buyers/{buyer_id} | Update buyer details |
| DELETE | /buyers/{buyer_id} | Delete a buyer by ID |

**Car Management Routes**

| **HTTP Method** | **Route** | **Description** |
|-----------------|------------------------------|-----------------------------|
| POST | /cars | Add a car to inventory |
| GET | /cars | Get all cars in inventory |
| GET | /cars/{car_id} | Get car details by ID |
| PUT | /cars/{car_id} | Update car details |
| DELETE | /cars/{car_id} | Remove a car from inventory |

**Sales Management Routes**

| **HTTP Method** | **Route** | **Description** |
|-----------------|------------------------------|-----------------------------|
| POST | /sales | Record a new sale |
| GET | /sales | Get all sales |
| GET | /sales/{sale_id} | Get sale details by ID |

**Stock Management Routes**

| **HTTP Method** | **Route** | **Description** |
|-----------------|------------------------------|-----------------------------|
| POST | /stocks | Add stock for a car |
| GET | /stocks | Get all stock |
| GET | /stocks/{stock_id} | Get stock details by ID |

#### Development Workflow

**Branching Strategy**

The project follows a feature branch workflow to ensure isolated development and easy integration.

1. Create a feature branch:
```
git checkout -b feature/{feature_name}
```

2. Push your branch to the remote repository:
```
git push origin feature/{feature_name}
```

3. Once your feature is complete, open a Pull Request to the main branch. Ensure that the code passes tests and review before merging.

**Feature Breakdown by Developer**

| **Developer** | **Feature** | **Branch** |
|----------------|------------------------------|-----------------------|
| Raza | Authentication | `feature/auth` |
| Amna | Seller & Stock Management | `feature/sellers` |
| Abid | Buyer Management | `feature/buyers` |
| Usama | Car Inventory Management | `feature/cars` |
| Shoaib | Sales Management | `feature/sales` |

#### License
This project is licensed under the MIT License - see the LICENSE file for details.