Skip to main content

Get Started in 5 Steps

Follow this guide to set up the API locally and make your first request.
1

Install Dependencies

Install Python 3.10+ and required system packages:
Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y python3.10 python3.10-dev python3-pip
sudo apt-get install -y build-essential libffi-dev libssl-dev libxml2-dev
sudo apt-get install -y libmysqlclient-dev
Install Python dependencies:
pip install -r requirement.txt
2

Configure Environment

Copy the example environment file and configure your settings:
cp .env.example .env
Update the .env file with your database credentials:
.env
# Database Configuration
HOST=localhost
USER=your_mysql_user
PASSWORD=your_mysql_password
DATABASE=ecommerce_db
DBPORT=3306

# MongoDB Configuration
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_DATABASE=ecommerce

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379

# API Configuration
PORT=8001
SECRET_KEY=your_secret_key_here
JWT_EXPIRY_DAY=30
3

Set Up Databases

Ensure MySQL, MongoDB, and Redis are running:
# Start MySQL
sudo systemctl start mysql

# Create database
mysql -u root -p
CREATE DATABASE ecommerce_db;
4

Start the API Server

Run the application using Gunicorn:
gunicorn main:app -b 0.0.0.0:8001 -w 4 --timeout 1200
The API will be available at http://localhost:8001
5

Make Your First Request

Test the API with a product listing request:
curl http://localhost:8001/api/v2/products/1/1
Expected response:
{
  "code": 200,
  "message": "success",
  "data": {
    "products": [...],
    "total": 100,
    "page": 1,
    "per_page": 20
  }
}

Next Steps

Now that you have the API running, explore these key features:

Authentication

Learn how to authenticate users and secure API requests

API Reference

Explore all available endpoints and their usage

Architecture

Understand the system architecture and design patterns

Deployment

Deploy the API to production with Docker

Common Operations

curl -X POST http://localhost:8001/api/v2/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecurePassword123",
    "first_name": "John",
    "last_name": "Doe",
    "phone_no": "+1234567890"
  }'
curl -X POST http://localhost:8001/api/v2/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecurePassword123"
  }'
Response includes a JWT token:
{
  "code": 200,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
curl -X POST http://localhost:8001/api/v2/cart \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "operation": "add",
    "prod_id": 12345,
    "quantity": 1
  }'
curl -X POST http://localhost:8001/api/v2/order \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "address_id": 1,
    "payment_method": 1,
    "platform": "WEB"
  }'
For detailed endpoint documentation, see the API Reference section.

Build docs developers (and LLMs) love