# scanurag/foodfrenzy architecture

> Architecture diagram of the GitHub repository scanurag/foodfrenzy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/scanurag/foodfrenzy
- Repository: https://github.com/scanurag/foodfrenzy

## Overview

1. **Overall shape**
   FoodFrenzy is a single Spring Boot monolith built around the classic MVC + service + repository pattern. It serves server-rendered Thymeleaf pages rather than a separate frontend app.

2. **Application entry and runtime**
   `FoodFrenzyApplication` is the bootstrapping class. The project is built with Maven (`pom.xml`, Maven wrapper) and targets a Java 8/Spring Boot runtime.

3. **Request handling layer**
   The main HTTP entry points are the controllers under `src/main/java/com/example/demo/controllers`:
   `HomeController`, `UserController`, `AdminController`, `ProductController`, and `OrderController`.
   These controllers are responsible for page navigation and user actions like login, CRUD operations, and order flow.

4. **Business logic boundary**
   The service layer (`AdminServices`, `UserServices`, `ProductServices`, `OrderServices`) sits between controllers and persistence. This is where domain rules and orchestration belong, keeping controllers thin and repositories focused on data access.

5. **Persistence layer**
   Spring Data JPA repositories (`AdminRepository`, `UserRepository`, `ProductRepository`, `OrderRepository`) handle database interaction. The README and naming indicate a MySQL-backed store using Hibernate/JPA mappings.

6. **Domain model**
   Core persisted entities are `Admin`, `User`, `Product`, and `Orders` in the `entities` package. These are the data objects that represent the system’s main business concepts: staff/admin accounts, customers/users, inventory items, and placed orders.

7. **Authentication and authorization**
   Security is centralized in `config/SecurityConfig`. Separate login DTOs/forms (`AdminLogin`, `UserLogin`) indicate role-aware authentication flows, likely distinguishing admin/staff access from customer/user access.

8. **UI and view structure**
   The UI is Thymeleaf-based, with templates for Home, Login, Products, Add/Update screens, Buy Product, Order Success, About, and Locate Us. Static CSS, JavaScript, and image assets live under `src/main/resources/static`, supporting a mostly server-rendered interface with some client-side behavior (`Products.js`).

9. **Error handling**
   `Exceptions.java` and the `exception.html` template suggest a centralized user-facing error path for application failures or invalid operations, rather than exposing raw stack traces.

10. **Main data flow**
   Typical flow is: browser submits a form or requests a page → controller receives the request → service applies business rules → repository reads/writes MySQL → controller returns a Thymeleaf view populated with model data. Orders and product management likely follow this same path, with authentication gating access to admin-only pages.

11. **Project organization and deployment signals**
   The repo includes `buildspec.yml`, which suggests CI/CD integration, likely for a build pipeline such as AWS CodeBuild. The test scaffold (`FoodFrenzyApplicationTests`) confirms it is set up as a standard Spring Boot application with automated build/test support.

12. **Diagram boundary hints**
   For an architecture diagram, the main boundaries are:
   - **Web/UI layer**: Thymeleaf templates + static assets
   - **Controller layer**: request routing and page actions
   - **Service layer**: business logic
   - **Repository/persistence layer**: JPA access
   - **Database**: MySQL
   - **Security layer**: login and role-based access

Main entry points: [`src/main/java/com/example/demo/FoodFrenzyApplication.java`](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/FoodFrenzyApplication.java) (FoodFrenzy), [`src/main/java/com/example/demo/services/OrderServices.java`](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/OrderServices.java) (Order svc), [`src/main/java/com/example/demo/config/SecurityConfig.java`](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/config/SecurityConfig.java) (Security), [`src/main/java/com/example/demo/controllers/UserController.java`](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/UserController.java) (User)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_runtime["Runtime"]
  node_app(("FoodFrenzy<br/>Spring Boot app"))
  node_config["App config<br/>runtime config"]
  node_build["Build<br/>Maven/CI<br/>[pom.xml]"]
end

subgraph group_grp_web["Web"]
  node_home_controller["Home<br/>MVC controller"]
  node_user_controller["User<br/>MVC controller"]
  node_admin_controller["Admin<br/>MVC controller"]
  node_product_controller["Product<br/>MVC controller"]
  node_order_controller["Order<br/>MVC controller"]
  node_views["Thymeleaf views<br/>server templates<br/>[Home.html]"]
  node_assets["Static assets<br/>css-js-images<br/>[Home.css]"]
  node_errors["Errors<br/>error handling<br/>[exception.html]"]
end

subgraph group_grp_core["Core"]
  node_security["Security"]
  node_user_service["User svc<br/>[UserServices.java]"]
  node_admin_service["Admin svc<br/>[AdminServices.java]"]
  node_product_service["Product svc"]
  node_order_service["Order svc<br/>[OrderServices.java]"]
  node_admin_entity["Admin<br/>entity<br/>[Admin.java]"]
  node_user_entity["User<br/>entity<br/>[User.java]"]
  node_product_entity["Product<br/>entity<br/>[Product.java]"]
  node_order_entity["Orders<br/>entity<br/>[Orders.java]"]
  node_login_dto["Login DTOs<br/>form models<br/>[AdminLogin.java]"]
end

subgraph group_grp_data["Data"]
  node_user_repo["User repo<br/>JPA repository"]
  node_admin_repo["Admin repo<br/>JPA repository"]
  node_product_repo["Product repo<br/>JPA repository"]
  node_order_repo["Order repo<br/>JPA repository"]
end

node_app -->|"loads"| node_config
node_app -->|"enables"| node_security
node_app -->|"starts"| node_home_controller
node_app -.->|"built by"| node_build
node_home_controller -->|"renders"| node_views
node_user_controller -->|"uses"| node_user_service
node_user_controller -.->|"guards"| node_security
node_admin_controller -->|"uses"| node_admin_service
node_admin_controller -.->|"guards"| node_security
node_product_controller -->|"uses"| node_product_service
node_order_controller -->|"uses"| node_order_service
node_user_service -->|"persists"| node_user_repo
node_admin_service -->|"persists"| node_admin_repo
node_product_service -->|"persists"| node_product_repo
node_order_service -->|"persists"| node_order_repo
node_user_repo -.->|"maps"| node_user_entity
node_admin_repo -.->|"maps"| node_admin_entity
node_product_repo -.->|"maps"| node_product_entity
node_order_repo -.->|"maps"| node_order_entity
node_security -->|"auth forms"| node_login_dto
node_user_controller -.->|"accepts"| node_login_dto
node_admin_controller -.->|"accepts"| node_login_dto
node_views -->|"depends on"| node_assets
node_errors -.->|"pairs with"| node_views
node_order_service -.->|"checks"| node_product_service
node_order_service -.->|"associates"| node_user_service

click node_app "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/FoodFrenzyApplication.java"
click node_security "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/config/SecurityConfig.java"
click node_home_controller "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/HomeController.java"
click node_user_controller "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/UserController.java"
click node_admin_controller "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/AdminController.java"
click node_product_controller "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/ProductController.java"
click node_order_controller "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/OrderController.java"
click node_user_service "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/UserServices.java"
click node_admin_service "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/AdminServices.java"
click node_product_service "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/ProductServices.java"
click node_order_service "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/OrderServices.java"
click node_user_repo "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/UserRepository.java"
click node_admin_repo "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/AdminRepository.java"
click node_product_repo "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/ProductRepository.java"
click node_order_repo "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/OrderRepository.java"
click node_admin_entity "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/Admin.java"
click node_user_entity "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/User.java"
click node_product_entity "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/Product.java"
click node_order_entity "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/Orders.java"
click node_login_dto "https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/loginCredentials/AdminLogin.java"
click node_views "https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/templates/Home.html"
click node_assets "https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/static/css/Home.css"
click node_errors "https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/templates/exception.html"
click node_config "https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/application.properties"
click node_build "https://github.com/scanurag/foodfrenzy/blob/master/pom.xml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_config,node_build toneBlue
class node_home_controller,node_user_controller,node_admin_controller,node_product_controller,node_order_controller,node_views,node_assets,node_errors toneAmber
class node_security,node_user_service,node_admin_service,node_product_service,node_order_service,node_admin_entity,node_user_entity,node_product_entity,node_order_entity,node_login_dto toneMint
class node_user_repo,node_admin_repo,node_product_repo,node_order_repo toneRose
```

## Components

### Runtime

Build and application bootstrapping

- [FoodFrenzy](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/FoodFrenzyApplication.java): Spring Boot app · Application entry point and runtime bootstrap · `src/main/java/com/example/demo/FoodFrenzyApplication.java`
- [App config](https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/application.properties): runtime config · Externalized application properties and environment settings · `src/main/resources/application.properties`
- [Build](https://github.com/scanurag/foodfrenzy/blob/master/pom.xml): Maven/CI · Maven build wrapper and CI buildspec · `pom.xml`

### Web

Request handling and server-rendered views

- [Home](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/HomeController.java): MVC controller · Landing pages and public navigation · `src/main/java/com/example/demo/controllers/HomeController.java`
- [User](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/UserController.java): MVC controller · User registration, login, and customer actions · `src/main/java/com/example/demo/controllers/UserController.java`
- [Admin](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/AdminController.java): MVC controller · Admin navigation and management actions · `src/main/java/com/example/demo/controllers/AdminController.java`
- [Product](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/ProductController.java): MVC controller · Product browsing and CRUD actions · `src/main/java/com/example/demo/controllers/ProductController.java`
- [Order](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/controllers/OrderController.java): MVC controller · Order placement and order lifecycle actions · `src/main/java/com/example/demo/controllers/OrderController.java`
- [Thymeleaf views](https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/templates/Home.html): server templates · Rendered pages for navigation, forms, products, and order success · `src/main/resources/templates/Home.html`
- [Static assets](https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/static/css/Home.css): css-js-images · Stylesheets, scripts, and images supporting the UI · `src/main/resources/static/css/Home.css`
- [Errors](https://github.com/scanurag/foodfrenzy/blob/master/src/main/resources/templates/exception.html): error handling · Central user-facing error page and exception handling · `src/main/resources/templates/exception.html`

### Core

Security, business logic, and domain model

- [Security](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/config/SecurityConfig.java): Spring Security · Central authentication and access control configuration · `src/main/java/com/example/demo/config/SecurityConfig.java`
- [User svc](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/UserServices.java): service · User domain orchestration and rules · `src/main/java/com/example/demo/services/UserServices.java`
- [Admin svc](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/AdminServices.java): service · Admin domain orchestration and rules · `src/main/java/com/example/demo/services/AdminServices.java`
- [Product svc](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/ProductServices.java): service · Product catalog and inventory logic · `src/main/java/com/example/demo/services/ProductServices.java`
- [Order svc](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/services/OrderServices.java): service · Order processing and coordination · `src/main/java/com/example/demo/services/OrderServices.java`
- [Admin](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/Admin.java): entity · Admin account model · `src/main/java/com/example/demo/entities/Admin.java`
- [User](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/User.java): entity · Customer account model · `src/main/java/com/example/demo/entities/User.java`
- [Product](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/Product.java): entity · Menu item or inventory model · `src/main/java/com/example/demo/entities/Product.java`
- [Orders](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/entities/Orders.java): entity · Placed order model · `src/main/java/com/example/demo/entities/Orders.java`
- [Login DTOs](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/loginCredentials/AdminLogin.java): form models · Role-specific login payloads for admin and user · `src/main/java/com/example/demo/loginCredentials/AdminLogin.java`

### Data

Persistence and database access

- [User repo](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/UserRepository.java): JPA repository · Data access for users · `src/main/java/com/example/demo/repositories/UserRepository.java`
- [Admin repo](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/AdminRepository.java): JPA repository · Data access for admins · `src/main/java/com/example/demo/repositories/AdminRepository.java`
- [Product repo](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/ProductRepository.java): JPA repository · Data access for products · `src/main/java/com/example/demo/repositories/ProductRepository.java`
- [Order repo](https://github.com/scanurag/foodfrenzy/blob/master/src/main/java/com/example/demo/repositories/OrderRepository.java): JPA repository · Data access for orders · `src/main/java/com/example/demo/repositories/OrderRepository.java`

## Connections

- FoodFrenzy → App config: loads · Bootstraps runtime configuration
- FoodFrenzy → Security: enables · Wires security configuration into the application
- FoodFrenzy → Home: starts · Hosts HTTP entry points
- FoodFrenzy → Build: built by · Project is packaged and tested through Maven/CI
- Home → Thymeleaf views: renders · Returns server-side pages
- User → User svc: uses · Delegates user workflows
- User → Security: guards · Protected by role-aware login flows
- Admin → Admin svc: uses · Delegates admin workflows
- Admin → Security: guards · Admin access is restricted
- Product → Product svc: uses · Delegates product operations
- Order → Order svc: uses · Delegates order flows
- User svc → User repo: persists · Reads and writes user data
- Admin svc → Admin repo: persists · Reads and writes admin data
- Product svc → Product repo: persists · Reads and writes product data
- Order svc → Order repo: persists · Reads and writes order data
- User repo → User: maps · JPA entity mapping
- Admin repo → Admin: maps · JPA entity mapping
- Product repo → Product: maps · JPA entity mapping
- Order repo → Orders: maps · JPA entity mapping
- Security → Login DTOs: auth forms · Uses role-specific login payloads
- User → Login DTOs: accepts · Consumes login/registration forms
- Admin → Login DTOs: accepts · Consumes admin login forms
- Thymeleaf views → Static assets: depends on · Templates are styled and scripted by static assets
- Errors → Thymeleaf views: pairs with · Centralized fallback user experience
- Order svc → Product svc: checks · Order flow depends on product state
- Order svc → User svc: associates · Orders are tied to users
