Namora is a microservices-based food delivery platform built with Spring Boot. The system consists of multiple services including Identity, User, Restaurant, Order, Payment, Dispatch, Gateway, and Eureka Server.
- Gateway Service: API Gateway (Port 8090)
- Eureka Server: Service Discovery (Port 8761)
- Identity Service: Authentication & Authorization (Port 8082)
- User Service: User, Customer, Rider, Cart Management (Port 8086)
- Restaurant Service: Restaurant & Menu Management (Port 8085)
- Order Service: Order Processing (Port 8083)
- Payment Service: Payment Processing (Port 8084)
- Dispatch Service: Rider Dispatch & Location Tracking (Port 8087)
- Gateway:
http://localhost:8090 - Direct Service Access:
http://localhost:{service-port}
All authenticated endpoints require a JWT token passed via:
- Cookie:
accessToken - Header:
Authorization: Bearer {token}
The gateway automatically extracts user information and forwards it to downstream services via headers:
X-User-ID: User's unique identifierX-Role: User's role (CUSTOMER, RIDER, RESTAURANT_OWNER, ADMIN)
- CUSTOMER: Can order food, manage cart, addresses
- RIDER: Delivery personnel, can update location
- RESTAURANT_OWNER: Can manage restaurants, menus, schedules
- ADMIN: System administration
POST /auth/register
- Public: Yes
- Description: Create a new user account
- Request Body:
{
"email": "user@example.com",
"password": "password123",
"role": "CUSTOMER"
}- Response: Sets cookies (accessToken, refreshToken)
POST /auth/login
- Public: Yes
- Description: Authenticate user
- Request Body:
{
"email": "user@example.com",
"password": "password123"
}- Response: Sets cookies (accessToken, refreshToken)
POST /auth/refresh
- Public: Yes
- Description: Refresh access token using refresh token
- Headers: Requires refreshToken cookie
- Response: New accessToken and refreshToken
POST /auth/logout
- Public: Yes
- Description: Logout user and invalidate tokens
- Response: Clears authentication cookies
POST /users
- Auth Required: Yes (CUSTOMER or RIDER)
- Description: Create user profile after registration
- Request Body:
{
"name": "John Doe",
"phoneNumber": "+1234567890"
}PUT /users
- Auth Required: Yes (CUSTOMER or RIDER)
- Description: Update user profile
- Request Body:
{
"name": "John Updated",
"phoneNumber": "+1234567890"
}GET /users
- Auth Required: Yes (CUSTOMER or RIDER)
- Description: Get current user information
POST /customers/{customerId}/addresses
- Auth Required: Yes (CUSTOMER)
- Description: Add a new delivery address
- Request Body:
{
"latitude": 12.9716,
"longitude": 77.5946,
"address": "123 Main Street, Bangalore, Karnataka"
}PUT /customers/{customerId}/addresses/{addressId}
- Auth Required: Yes (CUSTOMER)
- Description: Update an existing address
- Request Body:
{
"latitude": 12.9716,
"longitude": 77.5946,
"address": "456 New Street, Bangalore, Karnataka"
}PUT /customers/{customerId}/addresses/{addressId}/default
- Auth Required: Yes (CUSTOMER)
- Description: Set an address as default
POST /riders/{riderId}/submit
- Auth Required: Yes (RIDER)
- Description: Submit rider credentials for approval
- Request Body:
{
"licenseNumber": "DL1234567890",
"vehicleNumber": "KA-01-AB-1234"
}POST /carts/add
- Auth Required: Yes (CUSTOMER)
- Description: Add or update item in cart
- Request Body:
{
"itemId": "item-uuid",
"quantity": 2
}POST /carts/clear
- Auth Required: Yes (CUSTOMER)
- Description: Remove all items from cart
POST /restaurants
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Register a new restaurant
- Request Body:
{
"name": "Pizza Palace",
"address": "789 Food Street, Bangalore",
"latitude": 12.9716,
"longitude": 77.5946,
"fssaiLicense": "12345678901234"
}PUT /restaurants/{restaurantId}
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Update restaurant details
- Request Body:
{
"name": "Pizza Palace Deluxe",
"address": "789 Food Street, Bangalore",
"latitude": 12.9716,
"longitude": 77.5946,
"fssaiLicense": "12345678901234"
}GET /restaurants/owner
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Get all restaurants owned by current user
PUT /restaurants/{restaurantId}/status
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Toggle restaurant open/closed status
GET /restaurants/{restaurantId}/location
- Auth Required: No
- Description: Get restaurant address and coordinates
POST /restaurants/{restaurantId}/items
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Add a new menu item
- Request Body:
{
"name": "Margherita Pizza",
"description": "Classic cheese pizza with tomato sauce",
"isVeg": true,
"price": 299.00
}PUT /restaurants/{restaurantId}/items/{itemId}
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Update menu item details
- Request Body:
{
"name": "Margherita Pizza Special",
"description": "Classic cheese pizza with extra cheese",
"isVeg": true,
"price": 349.00
}DELETE /restaurants/{restaurantId}/items/{itemId}
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Remove a menu item
GET /items/restaurants/{restaurantId}
- Auth Required: No
- Description: Get all menu items for a restaurant
GET /items?name={itemName}&latitude={lat}&longitude={lon}
- Auth Required: No
- Description: Search for items by name near a location
- Query Parameters:
name: Item name to searchlatitude: User's latitudelongitude: User's longitude
- Example:
/items?name=pizza&latitude=12.9716&longitude=77.5946
GET /items/{itemId}
- Auth Required: No
- Description: Get detailed information about a specific item
POST /restaurants/{restaurantId}/schedule
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Set operating hours for a day
- Request Body:
{
"weekDay": "MONDAY",
"startTime": "09:00:00",
"endTime": "22:00:00"
}GET /restaurants/{restaurantId}/schedule
- Auth Required: Yes (RESTAURANT_OWNER)
- Description: Get all operating hours
POST /orders/{addressId}
- Auth Required: Yes (CUSTOMER)
- Description: Place an order from cart items
- Path Parameter:
addressId- Delivery address ID - Process:
- Fetches cart items
- Groups items by restaurant
- Calculates pricing (items, tax, delivery fee, platform fee)
- Creates order(s)
- Publishes order event to Kafka
POST /orders/{orderId}/confirm
- Auth Required: Yes (CUSTOMER)
- Description: Confirm order after payment
- Process:
- Updates order status to CONFIRMED
- Publishes ORDER_CONFIRMED event to Kafka
- Triggers rider dispatch
PUT /orders/{orderId}/assign-rider?riderId={riderId}
- Auth Required: Internal (Called by Dispatch Service)
- Description: Assign a rider to an order
POST /payments/pay
- Auth Required: Yes
- Description: Process payment for an order
- Request Body:
{
"orderId": "order-uuid",
"amount": 450.00,
"paymentMode": "UPI"
}- Process:
- Creates payment record
- Processes payment (mock bank call)
- If successful, calls order service to confirm order
- Updates payment status
POST /dispatch/riders/{riderId}/location?lat={latitude}&lon={longitude}
- Auth Required: Yes (RIDER)
- Description: Update rider's current location
- Query Parameters:
lat: Latitudelon: Longitude
- Process: Stores location in Redis using geospatial data
- Topic:
order-events - Event:
ORDER_CONFIRMED - Process:
- Finds nearest available rider within 3km
- Assigns rider to order
- Calls order service to update order with rider ID
Total Item Amount: Sum of (item price * quantity)
Tax: 5% of total item amount
Delivery Fee: ₹30.00 (fixed)
Platform Fee: ₹5.00 (fixed)
Final Amount: Total Item Amount + Tax + Delivery Fee + Platform Fee
CREATED → CONFIRMED → PREPARING → OUT_FOR_DELIVERY → DELIVERED
↓
CANCELLED
PENDING → SUCCESS
↓
FAILED
- Producers: Order Service
- Consumers: Dispatch Service
- Events:
ORDER_CREATED: When order is first createdORDER_CONFIRMED: When payment is successful
- Key:
available_riders - Type: Geospatial (GEO)
- Purpose: Store and query rider locations
- Operations:
GEOADD: Add/update rider locationGEORADIUS: Find riders within radius
All services return standardized error responses:
{
"success": false,
"message": "Error description",
"data": null
}200 OK: Successful request201 Created: Resource created successfully400 Bad Request: Invalid input401 Unauthorized: Missing or invalid authentication403 Forbidden: Insufficient permissions404 Not Found: Resource not found409 Conflict: Resource already exists500 Internal Server Error: Server error
Required environment variables (stored in .env file):
ACCESS_TOKEN_SECRET=your-access-token-secret-min-256-bits
REFRESH_TOKEN_SECRET=your-refresh-token-secret-min-256-bits
ACCESS_TOKEN_EXPIRATION=900000
REFRESH_TOKEN_EXPIRATION=604800000auth_db: Identity Service (Port 5435)user_db: User Service (Port 5435)restaurant_db: Restaurant Service (Port 5435)order_db: Order Service (Port 5435)payment_db: Payment Service (Port 5435)
Restaurant and User services use PostGIS for geospatial queries:
- Restaurant location storage
- Distance calculations
- Radius-based searches
- Start Eureka Server (Port 8761)
- Start Gateway Service (Port 8090)
- Start required microservices
- Start PostgreSQL (Port 5435)
- Start Kafka (Port 9092)
- Start Redis (Port 6379)
- Register & Login
# Register
curl -X POST http://localhost:8090/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"customer@test.com","password":"test123","role":"CUSTOMER"}'
# Login
curl -X POST http://localhost:8090/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"customer@test.com","password":"test123"}' \
-c cookies.txt- Create User Profile
curl -X POST http://localhost:8090/users \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"name":"John Customer","phoneNumber":"+919876543210"}'- Add Delivery Address
curl -X POST http://localhost:8090/customers/{customerId}/addresses \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"latitude":12.9716,"longitude":77.5946,"address":"123 MG Road, Bangalore"}'- Search for Food
curl "http://localhost:8090/items?name=pizza&latitude=12.9716&longitude=77.5946" \
-b cookies.txt- Add Items to Cart
curl -X POST http://localhost:8090/carts/add \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"itemId":"item-uuid","quantity":2}'- Place Order
curl -X POST http://localhost:8090/orders/{addressId} \
-b cookies.txt- Make Payment
curl -X POST http://localhost:8090/payments/pay \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"orderId":"order-uuid","amount":450.00,"paymentMode":"UPI"}'- All monetary values are in INR (₹)
- Distances are in meters (API) and kilometers (responses)
- Coordinates use WGS84 (SRID 4326)
- Times are in IST (Asia/Kolkata)
- UUIDs are used for all entity IDs
- Passwords are hashed using BCrypt
- JWT tokens expire after 15 minutes (access) and 7 days (refresh)