A full-stack café ordering platform for a Rajpur Road café in Dehradun. The React and TypeScript storefront connects to Java/Spring Boot services for accounts, catalog, carts, inventory, orders, payments, and notifications. Customers can browse, order for pickup, and pay by cash on delivery or Razorpay. Admins manage products, categories, stock, orders, and users.
- Quick start
- Services and ports
- Architecture
- Payments and order recovery
- Email notifications
- Local development
- Create an account and admin
- API endpoints
- Frontend routes
- Detailed project report
Prerequisites: Docker Desktop (or Docker Engine + Compose v2), with about 8 GB of memory available. The first build downloads Maven and npm dependencies and may take several minutes.
git clone https://github.com/lieutenant-Rohit/Cafe-Ecommerce-Microservices.git
cd Cafe-Ecommerce-Microservices
docker compose up --buildNo .env file is required for a local demo. Defaults include a development JWT secret, a shared PostgreSQL password, and mock email mode (emails are logged, not sent). These defaults are for local development only. To customize supported settings, copy the example file:
cp .env.example .envCOD works with the local demo defaults. To try Razorpay, set RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET, and RAZORPAY_WEBHOOK_SECRET in .env with test credentials. For a publicly reachable environment, configure the Razorpay webhook at https://<your-domain>/api/payments/webhook for payment.captured and payment.failed. The app treats a payment as paid only after capture is confirmed.
Never share or commit a real
.env. It is git-ignored, but it can still end up in a ZIP archive. If it contains a Gmail app password, revoke that password and create a new one.
Wait for the services to start (the first build may take several minutes). Check their state with docker compose ps, then open:
- Frontend: http://localhost:3100
- API Gateway: http://localhost:8180
To stop everything:
docker compose downTo stop and permanently delete the local database volume (the next start creates an empty database):
docker compose down -vThis deletes local accounts, orders, catalog changes, inventory changes, and payment records. Use it only when you want a complete reset.
To follow logs:
docker compose logs -f # all services
docker compose logs -f order-service # one service| Problem | Fix |
|---|---|
Port 3100, 8180, 6380, or 19092 already in use |
Set FRONTEND_PORT, GATEWAY_PORT, REDIS_PORT, or KAFKA_PORT in .env, then run docker compose up -d again. |
| Containers exited after changing code | Rebuild only what changed: docker compose up -d --build user-service (or --build with no service for all). |
| Database looks stale or schema is out of date | docker compose down -v then docker compose up --build. This deletes all local data. |
| Need to check why a service failed | docker compose logs --tail=200 <service-name>. |
| Frontend loads but API calls fail | Check docker compose ps, then inspect docker compose logs nginx-gateway and the affected service. PostgreSQL, Redis, and Kafka have healthchecks; application services may need extra startup time. |
| Service | Port | Description |
|---|---|---|
| Frontend | 3100 | React SPA served by Nginx |
| Nginx Gateway | 8180 | Reverse proxy, routes /api/* to backend |
| User Service | 8081 (internal) | Registration, login, JWT, user management |
| Catalog Service | 8082 (internal) | Products, categories, Redis cache |
| Cart Service | 8083 (internal) | Shopping carts; clears them after order events |
| Order Service | 8084 (internal) | Checkout, order lifecycle, inventory coordination |
| Inventory Service | 8085 (internal) | Available and reserved stock |
| Notification Service | 8086 (internal) | Order email and WebSocket notifications |
| Payment Service | 8087 (internal) | Razorpay checkout, verification, refunds |
| PostgreSQL | 5432 (internal) | 7 databases (one per service) |
| Redis | 6380 → 6379 | Catalog caching (host port 6380 avoids clashing with local Redis) |
| Kafka | 19092 → 29092 | Async inter-service messaging (services use kafka:9092 internally) |
The frontend, API gateway, Redis, and Kafka are bound to loopback host ports 3100, 8180, 6380, and 19092 by default. Backend service ports and PostgreSQL are only available inside the Compose network. Override the local ports with FRONTEND_PORT, GATEWAY_PORT, REDIS_PORT, and KAFKA_PORT in .env if they conflict with local software.
COD orders are created immediately and reserve inventory before confirmation. Their initial payment status is PENDING because payment is due on collection. Customers can pay a COD order later through Razorpay from My Orders.
For Razorpay checkout, the payment service creates an attempt and verifies the provider signature and payment state. An order is created only after a captured payment is confirmed. Captured-payment and order-created events are persisted in service outboxes before Kafka publication, so events can be retried after service or broker interruptions.
If payment is captured but inventory cannot be reserved, the order service releases any earlier reservations and requests a full refund. The payment attempt moves to REFUND_PENDING until Razorpay accepts the idempotent refund request; the payment service retries pending refunds if the provider is unavailable. A refund is not instantaneous in every payment method, so customers should check the payment provider/bank for settlement timing. Closing checkout leaves the cart intact. A payment that is still being confirmed should not be retried until its status is checked.
When an order is placed, order-service stores an OrderCreated event in its outbox, the scheduler publishes it to Kafka, and notification-service emails the confirmation to the customer's registered address.
Mock mode is the default (the email is logged by notification-service). To send real email through Gmail SMTP, add this to .env and restart the affected services:
NOTIFICATION_EMAIL_MOCK=false
GMAIL_SMTP_USER=your-address@gmail.com
GMAIL_SMTP_PASS=your-16-char-app-passwordGMAIL_SMTP_PASS must be a Google App Password (2-Step Verification required), not the normal Gmail password. Then rebuild and restart:
docker compose up -d --build notification-service
docker compose logs -f notification-service| Technology | Purpose |
|---|---|
| React 18 | UI framework |
| TypeScript | Type safety |
| Vite | Build tool & dev server |
| Tailwind CSS | Utility-first styling |
| shadcn/ui | Reusable UI components |
| Zustand | State management |
| React Router v6 | Client-side routing |
| Axios | HTTP client with JWT interceptor |
| Motion | Page transitions & animations |
| Lenis | Smooth scrolling |
| Technology | Purpose |
|---|---|
| Java 21 | Language |
| Spring Boot 4.x | Application framework |
| Spring Security | JWT authentication & role-based access |
| Spring Data JPA | ORM / database access |
| Spring Kafka | Event-driven messaging |
| Spring WebSocket | Real-time push notifications |
| PostgreSQL | Primary database (one per service) |
| Redis | Caching layer (catalog service) |
| Apache Kafka | Async inter-service messaging |
| Lombok | Boilerplate reduction |
| Technology | Purpose |
|---|---|
| Docker Compose | Container orchestration |
| Nginx | Reverse proxy & API gateway |
Communication patterns:
- Synchronous (REST): Cart → Catalog for product validation; Order → Cart, Catalog, Inventory, User, and Payment during checkout; Payment → Razorpay.
- Asynchronous (Kafka): Payment → Order after capture; Order → Cart for cart clearing; Order → Notification for confirmation.
- WebSocket/STOMP: Notification service exposes order updates at
/topic/orders/{userId}for subscribed clients. - Transactional outboxes: Order and Payment services persist messages alongside their database changes, then publish them asynchronously. Notification consumers deduplicate processed order events.
- Browse paginated product catalog with category filtering
- Add, update, and remove items from shopping cart
- Backend-synced cart for authenticated users and an in-memory cart for guests
- Place orders with automatic inventory reservation
- View order history and payment status
- Responsive UI with smooth scroll, page transitions, and micro-interactions
- Dashboard with order and user overview
- Manage products, categories, orders, users, and inventory
- Role-based access control (CUSTOMER / ADMIN)
- Order status lifecycle management
- Stateless JWT authentication with 1-hour expiry
- Redis caching on catalog reads (10-minute TTL)
- Inventory reservation and compensation during checkout
- Idempotent Razorpay refund request and retry when a captured order cannot be fulfilled
- Event-driven architecture with Kafka for async decoupling
- Per-service database isolation (database-per-service pattern)
The app doesn't seed any users. To get started, register at http://localhost:3100/register, then promote yourself to admin:
-- Connect to the database
psql -U root1 -d blooms_user
-- Update your role (replace the email with yours)
UPDATE users SET role='ADMIN' WHERE email='your@email.com';Or via Docker:
docker exec -it blooms-postgres psql -U root1 -d blooms_user -c "UPDATE users SET role='ADMIN' WHERE email='your@email.com';"BloomCafeV2/
├── docker-compose.yml # Full stack orchestration
├── init.sql # Auto-creates PostgreSQL databases
├── nginx.conf # API gateway routing
├── cors-headers.conf # Shared CORS headers for Nginx
├── .env.example # Optional local overrides (copy to .env)
├── .env # Local secrets, git-ignored — never share
│
├── frontend/
│ ├── Dockerfile # Multi-stage: Node build + Nginx serve
│ ├── nginx.conf # SPA routing + API proxy
│ ├── package.json
│ ├── vite.config.ts
│ ├── tailwind.config.js
│ └── src/
│ ├── main.tsx # React entry point
│ ├── App.tsx # Auth init + cart hydration
│ ├── router/index.tsx # Application routes and transitions
│ ├── store/ # Zustand stores (auth, cart)
│ ├── api/ # Axios API clients
│ ├── types/index.ts # TypeScript interfaces
│ ├── pages/ # Public pages (Home, Menu, Cart...)
│ ├── pages/admin/ # Admin panel (Dashboard, CRUD...)
│ ├── components/ # UI components, layout, animations
│ ├── hooks/ # Custom hooks (useCafeStatus)
│ └── utils/ # JWT helpers
│
├── backend/
│ ├── user-service/ # :8081 — Auth, JWT, User CRUD
│ ├── catalog-service/ # :8082 — Products, Categories, Redis
│ ├── cart-service/ # :8083 — Shopping cart, Kafka consumer
│ ├── order-service/ # :8084 — Order orchestration, Kafka producer
│ ├── inventory-service/ # :8085 — Stock management
│ ├── notification-service/ # :8086 — Kafka consumer, WebSocket push
│ └── payment-service/ # :8087 — Razorpay integration, payment outbox
If you prefer running services locally:
- Java 21+
- Node.js 18+
- PostgreSQL 16+ on
localhost:5432 - Docker (only for Kafka + Redis)
docker compose up -d redis kafkaThe containerized Redis is published on host port 6380 (to avoid clashing with a local Redis on 6379) and Kafka on host port 19092. If you want the locally-run services to use these containers, set:
export SPRING_DATA_REDIS_PORT=6380 export SPRING_KAFKA_BOOTSTRAP_SERVERS=localhost:19092
CREATE DATABASE blooms_user;
CREATE DATABASE blooms_catalog;
CREATE DATABASE blooms_cart;
CREATE DATABASE blooms_order;
CREATE DATABASE blooms_inventory;
CREATE DATABASE blooms_notification;
CREATE DATABASE blooms_payment;export JWT_SECRET=replace-with-a-random-secret-at-least-32-characters-long
export RAZORPAY_KEY_ID=your-razorpay-test-key-id
export RAZORPAY_KEY_SECRET=your-razorpay-test-key-secret
export RAZORPAY_WEBHOOK_SECRET=your-razorpay-webhook-secret
export PAYMENT_INTERNAL_TOKEN=your-long-random-internal-tokenStart each service in its own terminal from the repository root. Keep each process running in its terminal. For example:
cd backend/user-service && ./mvnw spring-boot:runRepeat for backend/catalog-service, backend/cart-service, backend/order-service, backend/inventory-service, and backend/notification-service, using ./mvnw spring-boot:run in each service directory. payment-service currently reuses the order service Maven wrapper:
cd backend/payment-service && ../order-service/mvnw spring-boot:runcd frontend && npm install && npm run devFrontend runs on http://localhost:5173 and proxies API requests to the backend services.
The Vite proxy routes the storefront APIs to local services, but does not currently include /api/payments. Use the Docker-served frontend at http://localhost:3100 for Razorpay checkout, or add a /api/payments proxy to http://localhost:8087 in frontend/vite.config.ts for local checkout development.
cd frontend
npm ci
npm run build
npm run lint| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register a new user |
| POST | /api/auth/login |
Login and receive JWT token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
List all users (admin) |
| GET | /api/users/me |
Get current user profile |
| GET | /api/users/{id} |
Get user by ID (admin) |
| DELETE | /api/users/{id} |
Delete user (admin) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/products |
List products (paginated) |
| GET | /api/products/batch |
Get products by IDs (?ids=1,2,3) |
| GET | /api/products/{id} |
Get product by ID |
| GET | /api/products/category/{categoryId} |
List products by category |
| POST | /api/products |
Create product (admin) |
| PUT | /api/products/{id} |
Update product (admin) |
| DELETE | /api/products/{id} |
Delete product (admin) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/categories |
List categories (paginated) |
| GET | /api/categories/{id} |
Get category by ID |
| POST | /api/categories |
Create category (admin) |
| PUT | /api/categories/{id} |
Update category (admin) |
| DELETE | /api/categories/{id} |
Delete category (admin) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/carts |
Create cart for current user |
| GET | /api/carts |
Get current user's cart |
| GET | /api/carts/user/{userId} |
Get cart by user ID |
| POST | /api/carts/items |
Add item (?productId=&quantity=) |
| PUT | /api/carts/items/{productId} |
Update item quantity |
| DELETE | /api/carts/items/{productId} |
Remove item from cart |
| DELETE | /api/carts/items |
Clear cart |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/orders/checkout |
Preview cart for checkout |
| POST | /api/orders |
Place order (orchestrates inventory + cart) |
| POST | /api/orders/razorpay/checkout |
Create Razorpay checkout attempt for cart |
| POST | /api/orders/{orderId}/razorpay/checkout |
Pay an existing COD order online |
| GET | /api/orders/payment-attempt/{attemptId} |
Find order created from a payment attempt |
| GET | /api/orders |
Get current user's orders |
| GET | /api/orders/all |
Get all orders (admin) |
| GET | /api/orders/{orderId} |
Get order by ID |
| PATCH | /api/orders/{orderId}/status |
Update order status (admin) |
| DELETE | /api/orders/{orderId} |
Delete order (admin) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/inventory/{productId} |
Get inventory for product |
| POST | /api/inventory |
Create inventory record |
| POST | /api/inventory/{productId}/reserve |
Reserve stock (?quantity=) |
| POST | /api/inventory/{productId}/release |
Release reserved stock |
No REST endpoints. Listens to Kafka order-created topic and pushes WebSocket/STOMP notifications to /topic/orders/{userId}.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/payments/verify |
Verify Razorpay Checkout signature and provider payment status |
| GET | /api/payments/{attemptId} |
Read payment status (CREATED, AUTHORIZED, PAID, FAILED, CANCELLED, REFUND_PENDING, or REFUNDED) |
| POST | /api/payments/{attemptId}/cancel |
Mark an open checkout attempt cancelled |
| POST | /api/payments/webhook |
Receive signed Razorpay payment webhooks |
| Route | Component | Access |
|---|---|---|
/ |
Home | Public |
/login |
Login | Public |
/register |
Register | Public |
/menu |
Menu | Public |
/cart |
Cart | Public |
/my-orders |
MyOrders | Logged-in customer |
/admin |
Dashboard | Admin |
/admin/products |
Products | Admin |
/admin/categories |
Categories | Admin |
/admin/orders |
Orders | Admin |
/admin/users |
Users | Admin |
/admin/inventory |
Inventory | Admin |
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m "Add your feature") - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
- Add unit and integration tests for backend services
- Set up CI/CD with GitHub Actions
- Write API documentation with Swagger/OpenAPI
- Spring Boot — Backend framework
- React — Frontend framework
- Tailwind CSS — Styling
- shadcn/ui — UI component inspiration
- Motion — Animations
- Apache Kafka — Event-driven messaging
- Redis — Caching
- Docker — Containerization