Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation


πŸ›’ E-commerce Backend (FastAPI)

A modern, scalable backend API for an E-commerce platform built with Python & FastAPI. This project demonstrates real-world backend architecture β€” covering authentication, database relationships, payment integration, and RESTful API design.


πŸš€ Features

βœ… User Management

  • User registration & login with JWT authentication
  • Role-based access (Admin, Customer)

βœ… Product Management

  • CRUD operations for products
  • Category-based product listing
  • Search & filtering

βœ… Order Management

  • Create & manage customer orders
  • Track order status (Pending β†’ Shipped β†’ Delivered)
  • Admin order control

βœ… Payment Integration

  • Simulated/real payment handling (e.g., Stripe/Paystack ready)
  • Secure transaction flow

βœ… Database Relationships

  • One-to-Many: User β†’ Orders
  • Many-to-Many: Orders ↔ Products

βœ… API Design

  • RESTful endpoints
  • Pagination, validation, and error handling

🧠 Tech Stack

Layer Technology
Framework FastAPI
Database ORM SQLAlchemy
Database Migration Alembic
Authentication JWT (via python-jose, passlib[bcrypt])
Environment Management python-dotenv
Server Uvicorn
Testing Pytest
Docs Built-in Swagger UI (/docs) & Redoc (/redoc)

πŸ“ Project Structure

ecommerce-backend/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py                # Entry point
β”‚   β”œβ”€β”€ config.py              # Environment & DB settings
β”‚   β”œβ”€β”€ database.py            # DB connection setup
β”‚   β”œβ”€β”€ models/                # SQLAlchemy models
β”‚   β”œβ”€β”€ schemas/               # Pydantic schemas
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”œβ”€β”€ users.py
β”‚   β”‚   β”œβ”€β”€ products.py
β”‚   β”‚   β”œβ”€β”€ orders.py
β”‚   β”‚   └── payments.py
β”‚   β”œβ”€β”€ services/              # Business logic layer
β”‚   └── utils/                 # Helpers (auth, hashing, etc.)
β”œβ”€β”€ tests/                     # Unit & integration tests
β”œβ”€β”€ requirements.txt
└── README.md

βš™οΈ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/<your-username>/ecommerce-backend.git
cd ecommerce-backend

2️⃣ Create a Virtual Environment

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

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Setup Environment Variables

Create a .env file in the root directory:

DATABASE_URL=postgresql://user:password@localhost:5432/ecommerce_db
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

5️⃣ Run Database Migrations

alembic upgrade head

6️⃣ Start the Application

uvicorn app.main:app --reload

Now open your browser and navigate to: πŸ‘‰ Swagger Docs: http://127.0.0.1:8000/docs


πŸ§ͺ Example Endpoints

Method Endpoint Description
POST /users/signup Register new user
POST /users/login Login & get JWT token
GET /products/ List all products
POST /orders/ Create an order
POST /payments/checkout Process a payment

πŸ› οΈ Future Improvements

  • Integrate Paystack or Stripe API
  • Implement Redis caching for performance
  • Add Celery background tasks (e.g., email notifications)
  • Build an admin dashboard frontend

πŸ‘¨β€πŸ’» Author

Olabowale Babatunde Ipaye πŸ“§ b.tunde.ipaye@gmail.com 🌍 Lagos, Nigeria πŸ”— LinkedIn | GitHub


🧾 License

This project is licensed under the MIT License. Feel free to use, modify, and distribute.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors