How madhusudan785/foodordering-backend works
1. Overall shape
- This is a single Spring Boot backend monolith built with Maven (pom.xml, Maven wrapper) and started from FoodorderingApplication.
- The repository is organized by standard backend layers: controller → service → repository → model/entity, with separate DTO/request/response objects for API contracts.
2. API boundary
- The HTTP entry points are split by domain:
- AuthController
- UserController
- RestaurantController / AdminRestaurantController
- FoodController / AdminFoodController
- CategoryController
- IngredientsController
- This suggests a REST API with a public surface plus admin-oriented management endpoints.
3. Security and authentication boundary
- Security is centralized in config/SecurityConfig.
- JWT handling is implemented through:
- filters/JwtAuthenticationFilter
- services/impl/JwtServiceImpl
- config/JwtAuthenticationEntryPoint
- exception/CustomAccessDeniedhandler
- Authentication flow is likely: login request → auth service → JWT issued → subsequent requests validated by filter → security context populated.
4. User identity and authorization
- CustomUserDetailService and UserServiceImpl indicate Spring Security is backed by the application’s user store.
- Domain models User and Role define identity and authorization data.
- Authorization errors are handled separately from authentication failures, which is important for diagramming the security boundary.
5. Business service layer
- Core domain logic is isolated in service interfaces and implementations:
- CategoryService / CategoryImpl
- FoodService / FoodServiceImpl
- IngredientsService / IngredientsServiceImpl
- RestaurantService / RestaurantServiceImpl
- UserService / UserServiceImpl
- This layer is the main coordination point between controllers and persistence.
6. Persistence layer
- Data access is handled through Spring Data repositories under repositories/*:
- UserRepository
- RestaurantRepo
- FoodRepo
- CategoryRepo
- IngredientsItemRepo
- IngredientItemCategoryRepo
- CartRepository
- AddressRepo
- The README says MySQL is used, so these repositories are the application’s persistence boundary to the database.
7. Domain model
- The models package contains the core entities and relationships:
- User, Role
- Restaurant, Food, Category
- IngredientsItem, IngredientItemCategory
- Cart, CartItem
- Order, OrderItem
- Address, ContactInformation
- This indicates the domain centers on restaurant menus, ingredient customization, user carts, and order processing.
8. API contracts / transport objects
- Request and response classes are separated from persistence models:
- Requests: LoginRequest, CreateFoodRequest, CreateRestaurantRequest, IngredientItemRequest, IngredientItemCategoryRequest
- Responses: AuthResponse, MessageResponse
- DTO: RestaurantDto
- This boundary helps prevent leaking entity structure directly over the API.
9. Functional subsystems
- The visible code naturally clusters into:
- Authentication and user management
- Restaurant management
- Food/catalog management
- Category and ingredient management
- Cart/order domain modeling
- The controllers and services align with these subsystems, which makes them the best units for an architecture diagram.
10. Order and payment status
- The README advertises order management and payment integration, and the models include Order and OrderItem.
- However, the visible tree does not show dedicated order/payment controllers, services, or payment adapters, so those areas appear modeled but not fully represented in the current source tree.
11. Configuration and deployment
- Runtime configuration is in src/main/resources/application.properties.
- The README mentions Docker, but no Dockerfile or compose file is present in the tree, so containerization is likely external or incomplete in this snapshot.
12. Testing
- Test coverage is minimal in the tree: only FoodorderingApplicationTests, which suggests a basic Spring context test rather than deep domain or integration coverage.
Main entry points: UserService.java User Service · SecurityConfig.java Security Config · AuthController.java Auth API · FoodorderingApplication.java FoodorderingApp
Components 20
Bootstrap
Application entrypoint and runtime configuration
- FoodorderingApp · Main application entrypoint
src/main/java/com/authapi/foodordering/FoodorderingApplication.java
API Layer
HTTP controllers for public and admin domains
- Auth API · Login and authentication endpoints
src/main/java/com/authapi/foodordering/controller/AuthController.java - User API · User profile and user-facing endpoints
src/main/java/com/authapi/foodordering/controller/UserController.java - Restaurant API · Public restaurant endpoints
src/main/java/com/authapi/foodordering/controller/RestaurantController.java - Admin Restaurant · Admin restaurant management endpoints
src/main/java/com/authapi/foodordering/controller/AdminRestaurantController.java - Food API · Public food endpoints
src/main/java/com/authapi/foodordering/controller/FoodController.java - Admin Food · Admin food management endpoints
src/main/java/com/authapi/foodordering/controller/AdminFoodController.java - Category API · Category endpoints
src/main/java/com/authapi/foodordering/controller/CategoryController.java - Ingredients API · Ingredient endpoints
src/main/java/com/authapi/foodordering/controller/IngredientsController.java
Security
JWT authentication and authorization boundary
- Security Config · Main security configuration
src/main/java/com/authapi/foodordering/config/SecurityConfig.java - JWT Filter · Validates bearer tokens on requests
src/main/java/com/authapi/foodordering/filters/JwtAuthenticationFilter.java - Auth Entry · Handles authentication failures
src/main/java/com/authapi/foodordering/config/JwtAuthenticationEntryPoint.java - Access Denied · Handles authorization failures
src/main/java/com/authapi/foodordering/exception/CustomAccessDeniedhandler.java
Services
Business orchestration and domain logic
- User Service · User and auth-backed business logic
src/main/java/com/authapi/foodordering/services/UserService.java - Catalog Services · Category, food, ingredient, and restaurant orchestration
- User Details · Loads application users for Spring Security
src/main/java/com/authapi/foodordering/services/CustomUserDetailService.java - JWT Service · Issues and validates JWTs
src/main/java/com/authapi/foodordering/services/impl/JwtServiceImpl.java
Persistence
Spring Data repositories to database
- Repositories · Spring Data repositories for core aggregates
Domain Model
Core entities and aggregate data
- Domain Models · Core entities for users, catalog, carts, and orders
Contracts
Request and response objects for API payloads
- API Contracts · Transport objects for auth and catalog APIs
Connections 23
- FoodorderingApp → Security Config: configures · Bootstraps security and application wiring
- FoodorderingApp → Auth API: starts · Exposes HTTP API through controllers
- Security Config → JWT Filter: registers · Adds JWT validation into request flow
- Security Config → Auth Entry: uses · Authentication failure handling
- Security Config → Access Denied: uses · Authorization failure handling
- JWT Filter → User Details: loads user · Resolves authenticated principal from token
- Auth API → User Service: calls · Delegates login and user logic
- Auth API → API Contracts: uses · Consumes login and auth payloads
- User API → User Service: calls · User-oriented operations
- Restaurant API → Catalog Services: calls · Public restaurant operations
- Admin Restaurant → Catalog Services: calls · Admin restaurant management
- Food API → Catalog Services: calls · Public food browsing
- Admin Food → Catalog Services: calls · Admin food management
- Category API → Catalog Services: calls · Category operations
- Ingredients API → Catalog Services: calls · Ingredient operations
- User Service → Repositories: persists via · Reads and writes user data
- Catalog Services → Repositories: persists via · Coordinates catalog persistence
- User Service → Domain Models: uses · Works with user and role entities
- Catalog Services → Domain Models: uses · Works with menu and order entities
- Repositories → Domain Models: maps · Repository entities
- API Contracts → Domain Models: adapts · Separates API payloads from persistence models
- JWT Service → API Contracts: returns · Produces auth responses and token payloads
- JWT Service → User Service: integrates · Authentication token flow uses user services