A scalable e-commerce backend built with FastAPI, featuring authentication, role-based access control, async processing with RabbitMQ, and real-time order tracking via WebSockets.
- Authentication: JWT with refresh tokens, password hashing (Argon2), rate limiting
- Authorization: Role-based access (USER, ADMIN, DRIVER)
- Products & Categories: Full CRUD with pagination, filters, and search
- Shopping Cart: Stock validation, quantity management
- Orders: State machine transitions, shipping addresses, driver assignment
- Real-time Tracking: WebSocket-based order tracking with driver location updates
- Async Processing: RabbitMQ for payment processing with retry and dead-letter queues
- Caching: Redis caching for products and categories with automatic invalidation
- Observability: Prometheus metrics, correlation IDs, structured JSON logging
- Infrastructure: Health checks, CORS, rate limiting
- Python 3.11+
- Docker & Docker Compose
- Make
git clone https://github.com/jeremyjsx/orderly.git
cd orderly
# Create virtual environment
make venv
# Install dependencies
make install
# Setup environment
cp .env.example .env# Start infrastructure (DB, Redis, RabbitMQ, S3, Prometheus, Grafana)
make dev
# Apply database migrations
make migrate
# Start the API server with hot-reload
make run- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/orderly)
- RabbitMQ Management: http://localhost:15672 (orderly/orderly)
make dev # Start infrastructure only
make run # Start API with hot-reloadmake docker-build # Build API image
make docker-up # Start all services
make docker-logs # View API logs
make docker-down # Stop all servicesmake test # Run all tests
make lint # Lint code
make format # Format codeapp/
βββ api/ # API router aggregation
βββ core/ # Config, security, redis, middleware
β βββ config.py # Pydantic settings
β βββ security.py # JWT, password hashing
β βββ redis.py # Redis client, tokens, cache
β βββ rate_limit.py # Sliding window rate limiter
β βββ middleware.py # Rate limit middleware
β βββ logging.py # Structured logging with correlation IDs
β βββ s3.py # S3 image uploads
β βββ schemas.py # Shared schemas
βββ db/ # Database session
βββ events/ # Async processing
β βββ client.py # RabbitMQ connection
β βββ orders/ # Order events + WebSocket
β βββ payments/ # Payment worker
βββ modules/
β βββ auth/ # Login, register, refresh
β βββ cart/ # Shopping cart
β βββ categories/ # Product categories
β βββ health/ # Health checks
β βββ orders/ # Orders + shipping
β βββ products/ # Product catalog
β βββ users/ # User management
βββ main.py # App entry point
| Category | Technology |
|---|---|
| Framework | FastAPI |
| Database | PostgreSQL + SQLAlchemy (async) |
| Cache | Redis |
| Message Queue | RabbitMQ |
| Auth | JWT + Argon2 |
| Real-time | WebSockets |
| Monitoring | Prometheus + Grafana |
| Migrations | Alembic |
| Testing | pytest + httpx |
| Containerization | Docker |
See .env.example for all available configuration options.
Key variables:
DATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection stringRABBITMQ_URL: RabbitMQ connection stringJWT_SECRET_KEY: Secret for JWT signing (change in production!)CORS_ORIGINS: Allowed origins (comma-separated or*)

