Overall architecture
Layered, event-driven Spring Boot design
A modular monolith with clean boundaries, DDD aggregate roots where they matter, asynchronous messaging, and hardened production operations.
Package structure
Enterprise package boundaries for controllers, services, repositories, DTOs, mappers, validation, integrations, analytics, and utilities.
- com.company.fooddelivery.config
- com.company.fooddelivery.security
- com.company.fooddelivery.controller.v1
- com.company.fooddelivery.service
- com.company.fooddelivery.service.impl
- com.company.fooddelivery.repository
- com.company.fooddelivery.entity
- com.company.fooddelivery.dto.request
- com.company.fooddelivery.dto.response
- com.company.fooddelivery.mapper
- com.company.fooddelivery.exception
- com.company.fooddelivery.validation
- com.company.fooddelivery.scheduler
- com.company.fooddelivery.notification
- com.company.fooddelivery.payment
- com.company.fooddelivery.delivery
- com.company.fooddelivery.analytics
- com.company.fooddelivery.utils
- com.company.fooddelivery.constants
Architecture diagram
flowchart LR
Client[Mobile and Web Clients] --> Gateway[API Gateway / Spring MVC]
Gateway --> Security[JWT Resource Server + RBAC]
Security --> Controllers[Versioned REST Controllers]
Controllers --> Facades[Application Facades]
Facades --> Services[Domain Services]
Services --> Repositories[Spring Data JPA Repositories]
Repositories --> Postgres[(PostgreSQL)]
Services --> Redis[(Redis Cache)]
Services --> MQ[RabbitMQ Exchanges]
MQ --> Workers[Async Workers and Schedulers]
Workers --> Mail[Email SMS Push Adapters]
Services --> S3[MinIO / AWS S3]
Actuator[Spring Actuator] --> Prometheus[Prometheus]
Prometheus --> Grafana[Grafana]Class diagram
classDiagram
class ApiResponse~T~ { boolean success; String message; T data }
class BaseEntity { UUID id; Instant createdAt; Instant updatedAt }
class OrderService { +createOrder(request) +transition(id,status) +cancel(id) }
class PaymentStrategy { <<interface>> +authorize(request) +refund(request) }
class CartPricingTemplate { +calculate(cart) #tax() #fees() #discounts() }
class NotificationObserver { <<interface>> +onOrderEvent(event) }
BaseEntity <|-- User
BaseEntity <|-- Order
BaseEntity <|-- Restaurant
OrderService --> CartPricingTemplate
OrderService --> PaymentStrategy
OrderService --> NotificationObserver