How abdulalimswe/foodies works
1. Repository shape
- This is a three-app full-stack system:
- foodiesapi: Spring Boot REST backend
- foodies: customer-facing React app
- adminpanel: admin React app
- The frontend apps are separate deployments, but both talk to the same backend API.
2. Core architectural style
- The backend is a layered monolith: HTTP controllers → service layer → MongoDB repositories → document entities.
- The frontend apps are thin clients: route/page components call service modules, which wrap API requests to the backend.
3. Backend entry points and boundaries
- FoodiesapiApplication is the Spring Boot startup class.
- API surface is organized by domain controllers:
- AuthController
- UserController
- FoodController
- CartController
- OrderController
- PaymentController
- This makes the backend the main integration boundary for both user and admin flows.
4. Backend domain model
- Persistent data is modeled as MongoDB documents in Entity/:
- UserEntity
- FoodEntity
- CartEntity
- OrderEntity
- Request/response payloads are separated into DTO-style classes in io/, so the API contract is not the same as the database model.
5. Backend business services
- Business logic lives in service/ and service/impl/.
- Key capabilities:
- authentication and user management
- food catalog CRUD
- cart operations
- order creation and lifecycle updates
- payment initiation/validation
- AuthenticationFacade and AppUserDetailsService support user-context handling and Spring Security integration.
6. Security and auth flow
- Security is JWT-based.
- SecurityConfig, JwtAuthenticationFilter, and JwtUtils define the auth boundary.
- Login/register happen through AuthController; subsequent protected calls use Authorization: Bearer <token>.
- CustomAuthenticationEntryPoint handles unauthorized access responses.
7. Payment and external integrations
- Payments are first-class backend concerns, not frontend-only flows.
- PaymentController and SSLCommerzPaymentService coordinate checkout with external gateways.
- Supported flows include:
- SSLCommerz for Bangladesh
- Razorpay for international payments
- Cash on delivery
- Payment callbacks (success, failure, cancel) return to backend endpoints, which then update order state.
8. Infrastructure dependencies
- MongoDB is the primary datastore.
- AWS S3 is used for food image storage via AWSConfig.
- The backend is configured through application properties and environment variables for database, JWT, S3, and payment gateway secrets.
9. Customer frontend architecture
- foodies is a React/Vite app with page-level routing under pages/ and reusable UI in components/.
- Important pieces:
- StoreContext for shared state
- authService, cartService, foodService, orderService for backend calls
- cartUtils for client-side cart manipulation
- The app covers browsing, item details, cart, checkout, auth, and payment result pages.
10. Admin panel architecture
- adminpanel is a separate React/Vite interface for operational staff.
- Its UI is organized around management tasks:
- AddFood
- ListFood
- Orders
- It uses its own service layer to call the same backend, but exposes admin-oriented workflows rather than customer flows.
11. Main data flows
- Catalog flow: backend food records → customer browsing and admin maintenance.
- Cart flow: customer actions update cart state in the frontend and persist through backend cart APIs.
- Order flow: checkout payload → order creation → payment gateway initialization → callback validation → order status update.
- Admin flow: admin updates food and order records through protected backend endpoints.
12. What to diagram as boundaries
- Draw three client boundaries: customer app, admin app, backend API.
- Inside the backend, show three sub-boundaries: security/auth, domain services, persistence/integration.
- Outside the backend, show MongoDB, AWS S3, SSLCommerz, and Razorpay as external dependencies.
Main entry points: FoodController.java Domain APIs · FoodRepository.java Repositories · orderService.js API Services · SSLCommerzPaymentServiceImpl.java Payment Service
Components 22
Customer App
React/Vite client for browsing, cart, checkout, and payment result flows.
- Foodies UI · Customer-facing frontend for browsing, cart, checkout, and payment outcomes.
foodies/src/main.jsx - Pages · Customer page-level routes for home, food details, cart, order placement, and payment states.
foodies/src/pages/Home/Home.jsx - API Services · Frontend wrappers for backend auth, food, cart, and order requests.
foodies/src/service/orderService.js - Store Context · Client-side shared state for user and cart data.
foodies/src/context/StoreContext.jsx
Admin App
React/Vite client for catalog and order administration.
- Admin UI · Operational frontend for catalog and order maintenance.
adminpanel/src/main.jsx - Admin Pages · Admin workflows for adding food, listing food, and reviewing orders.
adminpanel/src/pages/AddFood/AddFood.jsx - Admin API · Admin frontend service layer for backend catalog operations.
adminpanel/src/services/foodService.js
Backend API
Spring Boot REST monolith exposing auth, catalog, cart, order, and payment endpoints.
- Startup · Application entry point for the REST backend.
foodiesapi/src/main/java/swe/utin/foodiesapi/FoodiesapiApplication.java - Auth API · Login and registration boundary for client authentication.
foodiesapi/src/main/java/swe/utin/foodiesapi/controller/AuthController.java - Domain APIs · Controllers for users, food, cart, orders, and payment flows.
foodiesapi/src/main/java/swe/utin/foodiesapi/controller/FoodController.java
Security/Auth
JWT-based authentication and request protection.
- Security Config · Configures authentication, authorization, and unauthorized responses.
foodiesapi/src/main/java/swe/utin/foodiesapi/config/SecurityConfig.java - JWT Filter · Extracts and validates bearer tokens on protected requests.
foodiesapi/src/main/java/swe/utin/foodiesapi/filters/JwtAuthenticationFilter.java
Domain Services
Business logic for users, food, cart, orders, and payments.
- User Service · User management and account-related business logic.
foodiesapi/src/main/java/swe/utin/foodiesapi/service/impl/UserServiceImpl.java - Food Service · Food catalog CRUD and related business logic.
foodiesapi/src/main/java/swe/utin/foodiesapi/service/impl/FoodServiceImpl.java - Cart & Order · Cart operations, order creation, and lifecycle updates.
foodiesapi/src/main/java/swe/utin/foodiesapi/service/impl/CartServiceImpl.java
Persistence/Integration
MongoDB persistence plus external storage and payment gateway integrations.
- Payment Service · Payment initiation and validation across supported gateways.
foodiesapi/src/main/java/swe/utin/foodiesapi/service/impl/SSLCommerzPaymentServiceImpl.java - Repositories · MongoDB access layer for users, food, cart, and orders.
foodiesapi/src/main/java/swe/utin/foodiesapi/repository/FoodRepository.java - Documents · Persistent document models for users, food, cart, and orders.
foodiesapi/src/main/java/swe/utin/foodiesapi/Entity/FoodEntity.java
External Dependencies
Datastore and third-party services used by the backend.
- AWS S3 · Food image storage integration.
foodiesapi/src/main/java/swe/utin/foodiesapi/config/AWSConfig.java - MongoDB · Primary backend datastore.
- SSLCommerz · Primary payment gateway for Bangladesh checkout flows.
- Razorpay · International payment gateway option.
Connections 25
- Foodies UI → Pages: renders · The React app is composed from route/page views.
- Foodies UI → Store Context: shares state · Pages read and update shared customer state.
- Pages → API Services: calls API · Pages use service modules for backend requests.
- Store Context → API Services: persists cart · Client state feeds cart and checkout requests.
- Admin UI → Admin Pages: renders · The admin app is composed from operational pages.
- Admin Pages → Admin API: calls API · Admin screens use service modules for backend requests.
- API Services → Auth API: auth · Customer login and registration go through the auth boundary.
- API Services → Domain APIs: customer flows · Customer browsing, cart, order, and payment flows hit domain controllers.
- Admin API → Domain APIs: admin flows · Admin maintenance uses protected catalog and order endpoints.
- Startup → Security Config: loads · Backend startup wires the security configuration.
- Security Config → JWT Filter: enables · Security configuration installs JWT request filtering.
- JWT Filter → Auth API: guards · Protected requests are validated before controller access.
- Auth API → User Service: delegates · Auth endpoints use user management and authentication services.
- Domain APIs → Food Service: delegates · Food-related endpoints call the catalog service.
- Domain APIs → Cart & Order: delegates · Cart, order, and user-facing domain endpoints call business services.
- Domain APIs → Payment Service: delegates · Payment endpoints coordinate gateway initiation and validation.
- User Service → Repositories: persists · User operations go through Mongo repositories.
- Food Service → Repositories: persists · Catalog operations go through Mongo repositories.
- Cart & Order → Repositories: persists · Cart and order state is stored through repositories.
- Repositories → Documents: maps · Repositories read and write Mongo document models.
- Payment Service → SSLCommerz: initiates · Primary payment checkout uses SSLCommerz.
- Payment Service → Razorpay: supports · Alternative payment flow uses Razorpay.
- Food Service → AWS S3: images · Catalog items rely on S3-backed image storage.
- Repositories → MongoDB: stores · MongoDB is the primary persistence backend.
- Cart & Order → Payment Service: checkout · Order creation hands off to payment initialization.