REST API for e-commerce management with JWT authentication and role-based access control.
API: https://ecommerce-c9m75lwwn-vandevbetts-projects.vercel.app
Docs: https://ecommerce-c9m75lwwn-vandevbetts-projects.vercel.app/docs
Note: First request may take a few seconds to respond.
- FastAPI — Python web framework
- PostgreSQL — Database
- SQLAlchemy — ORM
- bcrypt — Password hashing
- python-jose — JWT tokens
- Docker — Containerization
- pytest — Testing
- JWT authentication
- Role-based access control (admin / user)
- Product management
- Order management with stock validation
- Automatic total calculation
- Docker
- Docker Compose
- Python 3.12+
# Clone the repository
git clone git@github.com:vanDevBett/ecommerce-api.git
cd task-manager-api# Create the environment file
cp .env.example .env# Create and activate virtual environment
# Mac / Linux
python3 -m venv venv
source venv/bin/activate
# Windows
python -m venv venv
venv\Scripts\activate# Start the containers
docker compose up --buildAPI available at http://localhost:8000
Interactive documentation at http://localhost:8000/docs
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /auth/register | Register a new user | No |
| POST | /auth/login | Login and get JWT token | No |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /products | Get all products | No |
| GET | /products/{id} | Get a product | No |
| POST | /products | Create a product | Admin |
| PUT | /products/{id} | Update a product | Admin |
| DELETE | /products/{id} | Delete a product | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /orders | Create an order | User |
| GET | /orders | Get my orders | User |
| GET | /orders/{id} | Get an order | User |
pytest tests/ -vapp/
├── api/ # Endpoints
├── core/ # Config, database, security, dependencies
├── models/ # Database models
├── schemas/ # Pydantic schemas
├── services/ # Business logic
└── main.py # Entry point