A production-ready backend for a coffee shop ordering system — handles products, baskets, orders and authentication. Built with Node.js, TypeScript and Express on top of MongoDB, Redis and RabbitMQ.
CoffeeShop Backend is a REST API that powers a coffee shop's ordering platform. It manages products, customer baskets and orders, with order processing handed off to RabbitMQ workers. Sessions live in Redis, data in MongoDB, errors flow to Sentry, and the whole stack runs in Docker.
The codebase follows Clean Architecture with strict separation between interfaces → application → domain → infrastructure.
- Product catalog with CRUD endpoints
- Basket management per authenticated user
- Queue-based order processing powered by RabbitMQ
- Authentication & sessions with JWT and Redis-backed
express-session - Password hashing with bcrypt
- Transactional emails via Nodemailer
- Error tracking & profiling with Sentry
- Type-safe environment loading with envalid
- HTTP request logging with morgan
- Containerized stack — API, MongoDB, Redis, RabbitMQ via Docker Compose
- Postman collection included for quick API exploration
| Layer | Technology |
|---|---|
| Language | Node.js + TypeScript 5 |
| Framework | Express 4 |
| Database | MongoDB + Mongoose |
| Cache / Sessions | Redis (ioredis, connect-redis) |
| Message Queue | RabbitMQ (amqplib) |
| Auth | JWT, express-session, bcrypt |
| Nodemailer | |
| Monitoring | Sentry (node + profiling) |
| Config | envalid, dotenv |
| Logging | morgan |
| Containerization | Docker & Docker Compose |
This project follows the Clean Architecture pattern — outer layers depend on inner ones, never the reverse.
interfaces/— HTTP layer: controllers, routes and middlewaresapplication/— use-cases and application services orchestrating business logicdomain/— entities and Mongoose modelsinfrastructure/— concrete implementations: MongoDB, Redis, RabbitMQ, repositories, third-party clientsshared/— cross-cutting helpers (env loading, utilities)
- Docker & Docker Compose
- Node.js 20+ (only if running outside Docker)
- A Sentry DSN (optional, can be left blank in development)
git clone https://github.com/kwa0x2/CoffeeShop-Backend.git
cd CoffeeShop-BackendCreate a .env file in the project root:
# Server
PORT=3000
# MongoDB
MONGO_URI=mongodb://mongo:27017
MONGO_DB_NAME=coffeeshop
# Redis (sessions & cache)
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password
# RabbitMQ (order queue)
RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
# Auth
JWT_SECRET=your_jwt_secret
SESSION_SECRET=your_session_secret
COOKIE_NAME=sid
# Email (Nodemailer)
EMAIL=you@example.com
EMAIL_PASSWORD=your_email_app_password
# Observability
SENTRY_DSN=Variables are validated at startup by
envalid— seesrc/shared/utils/env.tsfor the full schema.
docker compose up -d --buildThe API will be available at http://localhost:3000.
npm install
npm startAll endpoints are prefixed with /api. Route groups:
| Group | Purpose |
|---|---|
/auth |
Sign-up, login, logout, sessions |
/products |
Product catalog (CRUD) |
/basket |
Per-user basket management & checkout |
A Postman collection is included — Coffee Shop API.postman_collection.json — covering every endpoint with example requests and responses.
CoffeeShop-Backend/
├── src/
│ ├── application/ # Use-cases & application services
│ │ ├── services/
│ │ └── use-cases/
│ ├── domain/ # Entities & Mongoose models
│ │ ├── entities/
│ │ └── models/
│ ├── infrastructure/ # External integrations
│ │ ├── database/ # MongoDB connection
│ │ ├── rabbitmq/ # Queue producers & consumers
│ │ ├── redis/ # Redis client & session store
│ │ ├── repositories/
│ │ └── third-party/
│ ├── interfaces/ # HTTP layer
│ │ ├── controllers/
│ │ ├── middlewares/
│ │ └── routes/
│ ├── shared/ # Env loading & utilities
│ └── server.ts # Application entry point
├── compose.yaml # Docker Compose stack
├── Dockerfile # API image
└── Coffee Shop API.postman_collection.json
Distributed under the MIT License. See LICENSE for more information.