Skip to content

Yasser5711/Trinity

Repository files navigation

🛒 E-Commerce Backend

Tests Dockerized Alt

This project is a fully-featured e-commerce backend written in FastAPI 🚀 with a focus on DevOps principles, clean architecture, and modular design. It supports user authentication, role-based access control, stock and product management, PayPal integration for payments, and much more.

📦 Features

  • User Management
    Register, login, JWT-based auth, password reset, role assignment

  • 🛡 Role-Based Access Control
    Admin-only endpoints, dynamic role linking

  • 📦 Stock & Inventory Management
    CRUD operations on products, stock updates on checkout

  • 🛒 Cart & Checkout
    Cart with multiple items, item quantity tracking

  • 💳 PayPal Integration
    Create and capture PayPal orders via API

  • 📊 Reports & KPIs
    Generate downloadable PDF reports

  • 🔐 Token Blacklisting
    Secure logout with token blacklisting

  • 🧪 Full Test Coverage
    Unit + integration tests with pytest, factory_boy, and SQLite in-memory DB

  • 🐳 Dockerized Setup
    Clean service separation using Docker Compose (dev-ready)


🚀 Tech Stack

Layer Technology
API FastAPI
Auth JWT, PassLib
DB PostgreSQL
ORM SQLAlchemy
Payments PayPal REST API
Docs Swagger/OpenAPI
Testing Pytest, Factory Boy
DevOps Docker, Compose

📂 Project Structure


🧰 Getting Started

1. 📄 Set up your .env file

cp .env.template .env

2. 🐳 Start the Development Environment

Make sure Docker is running, then:

docker-compose -f docker-compose-dev.yml --profile back --env-file .env up -d

This spins up:

  • PostgreSQL database
  • FastAPI app (with hot reload)
  • Optional: pgAdmin (if tools profile is used)

🔄 To stop everything

docker-compose down

3. 🧪 Run Tests

docker exec -it back bash -c "pytest"

📈 Example Endpoints

Method Endpoint Description
POST /auth/register Register new user
POST /auth/login Login and receive JWT
GET /users List all users (admin only)
POST /stocks Add new stock (admin only)
POST /create-paypal-order Create PayPal order (auth)
POST /capture-paypal-order/:id Capture PayPal payment
GET /reports Download PDF report (admin)

🧠 License

This project is educational and open-source. Feel free to adapt it for your own use. Contributions welcome!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages