# tarunmaddipati/food-app-java architecture

> Architecture diagram of the GitHub repository tarunmaddipati/food-app-java, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tarunmaddipati/food-app-java
- Repository: https://github.com/tarunmaddipati/food-app-java

## Overview

##### Project Type and Purpose
- Type: Java-based CLI (command-line interface) application
- Purpose: Offer a “Foodie” ordering experience via terminal—customers register/login, browse restaurants and dishes, place orders, view order history
- Persistence: CSV files under data/ (customer.csv, restaurants.csv, dishes.csv, orders.csv inferred)

##### File Structure
- Entry point: src/main/java/org/food/Main.java
- UI layer: src/.../ui/*Menu.java classes drive CLI prompts and user input
- Controller layer: src/.../controller/*Controller.java handle UI requests and translate to service calls
- Service layer: src/.../service/*ServiceImpl.java implement business logic, transaction-like workflows
- Repository layer: src/.../repository/*Repository.java load/save Model objects from/to CSV via CSVReader (src/.../util/CSVReader.java)
- Model layer: src/.../model/*.java define domain objects (Customer, Restaurant, Dish, Order)
- Factory: src/.../factory/Factory.java wires together controllers, services, repositories
- Exceptions: src/.../exception/*Exception.java define error cases (NotFound, AlreadyExists)

##### Key Insights from README
- Sequential user flow: register/login → browse restaurants → view dishes → place order → view history
- No external services (purely local CSV-based persistence)
- Text-based UI, not a web front end

##### Main Components & Relationships
a. UI Layer (CLI)
– Components: Menu classes
b. Controller Layer
– Components: CustomerController, RestaurantController, DishController, OrderController
c. Service Layer
– Components: CustomerServiceImpl, RestaurantServiceImpl, DishServiceImpl, OrderServiceImpl (+ interfaces)
d. Repository Layer & Data Store
– Components: CustomerRepository, RestaurantRepository, DishRepository, OrderRepository
e. Utility
– Component: CSVReader (used by repositories)
f. Factory
– Component: Factory class that assembles controllers with their dependencies
g. Models
– Domain objects (Customer, Restaurant, Dish, Order) can be annotated or shown alongside repositories/services

##### Data Flow & Interactions
UI → Controller → Service → Repository → CSVReader → Data Store
Service ← Exceptions ← Repository
Factory → Controllers & Services (dependency injection)

##### Architectural Patterns & Design Principles
- Layered architecture (UI → Controller → Service → Repository → Data)
- Factory pattern for wiring dependencies
- Separation of concerns:
– UI handles user interaction
– Controllers manage request translation and validation
– Services encapsulate business rules
– Repositories abstract persistence
- Exception handling bubble up from repository to UI via controllers

##### Detail
- Six sub-packages (ui, controller, service, repository, util, exception, factory)
- Relationships between models and where they are used
- Exception flow—how a “NotFoundException” propagates from repository up to UI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry and Factory
    Main["Main"]:::entry
    Factory["Factory (Dependency Injection)"]:::factory

    Main --> Factory
    click Main "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/Main.java"
    click Factory "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/factory/Factory.java"

    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        BaseMenu["Menu (Base)"]:::ui
        CustomerMenu["CustomerMenu"]:::ui
        RestaurantMenu["RestaurantMenu"]:::ui
        DishesMenu["DishesMenu"]:::ui
        OrdersMenu["OrdersMenu"]:::ui
    end

    Main --> BaseMenu
    click BaseMenu "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/ui/Menu.java"
    BaseMenu --> CustomerMenu
    BaseMenu --> RestaurantMenu
    BaseMenu --> DishesMenu
    BaseMenu --> OrdersMenu
    click CustomerMenu "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/ui/CustomerMenu.java"
    click RestaurantMenu "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/ui/RestaurantMenu.java"
    click DishesMenu "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/ui/DishesMenu.java"
    click OrdersMenu "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/ui/OrdersMenu.java"

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        CustCtrl["CustomerController"]:::controller
        RestCtrl["RestaurantController"]:::controller
        DishCtrl["DishController"]:::controller
        OrderCtrl["OrderController"]:::controller
    end

    CustomerMenu --> CustCtrl
    RestaurantMenu --> RestCtrl
    DishesMenu --> DishCtrl
    OrdersMenu --> OrderCtrl

    click CustCtrl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/controller/CustomerController.java"
    click RestCtrl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/controller/RestaurantController.java"
    click DishCtrl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/controller/DishController.java"
    click OrderCtrl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/controller/OrderController.java"

    Factory --> CustCtrl
    Factory --> RestCtrl
    Factory --> DishCtrl
    Factory --> OrderCtrl

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        CustSvcInt["CustomerService (interface)"]:::service
        CustSvcImpl["CustomerServiceImpl"]:::service
        RestSvcInt["RestaurantService (interface)"]:::service
        RestSvcImpl["RestaurantServiceImpl"]:::service
        DishSvcInt["DishService (interface)"]:::service
        DishSvcImpl["DishServiceImpl"]:::service
        OrderSvcInt["OrderService (interface)"]:::service
        OrderSvcImpl["OrderServiceImpl"]:::service
    end

    CustCtrl --> CustSvcImpl
    RestCtrl --> RestSvcImpl
    DishCtrl --> DishSvcImpl
    OrderCtrl --> OrderSvcImpl

    CustSvcInt --> CustSvcImpl
    RestSvcInt --> RestSvcImpl
    DishSvcInt --> DishSvcImpl
    OrderSvcInt --> OrderSvcImpl

    Factory --> CustSvcImpl
    Factory --> RestSvcImpl
    Factory --> DishSvcImpl
    Factory --> OrderSvcImpl

    click CustSvcInt "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/CustomerService.java"
    click CustSvcImpl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/CustomerServiceImpl.java"
    click RestSvcInt "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/RestaurantService.java"
    click RestSvcImpl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/RestaurantServiceImpl.java"
    click DishSvcInt "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/DishService.java"
    click DishSvcImpl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/DishServiceImpl.java"
    click OrderSvcInt "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/OrderService.java"
    click OrderSvcImpl "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/service/OrderServiceImpl.java"

    %% Repository Layer
    subgraph "Repository Layer"
        direction TB
        CustRepo["CustomerRepository"]:::repository
        RestRepo["RestaurantRepository"]:::repository
        DishRepo["DishRepository"]:::repository
        OrderRepo["OrderRepository"]:::repository
    end

    CustSvcImpl --> CustRepo
    RestSvcImpl --> RestRepo
    DishSvcImpl --> DishRepo
    OrderSvcImpl --> OrderRepo

    click CustRepo "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/repository/CustomerRepository.java"
    click RestRepo "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/repository/RestaurantRepository.java"
    click DishRepo "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/repository/DishRepository.java"
    click OrderRepo "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/repository/OrderRepository.java"

    %% Utility and Data Store
    CSVReader["CSVReader"]:::util
    CustRepo --> CSVReader
    RestRepo --> CSVReader
    DishRepo --> CSVReader
    OrderRepo --> CSVReader
    click CSVReader "https://github.com/tarunmaddipati/food-app-java/blob/main/src/main/java/org/food/util/CSVReader.java"

    subgraph "Data Store (CSV Files)"
        direction TB
        CustCSV["customer.csv"]:::datastore
        RestCSV["restaurants.csv"]:::datastore
        DishCSV["dishes.csv"]:::datastore
        OrderCSV["orders.csv"]:::datastore
    end

    CSVReader --> CustCSV
    CSVReader --> RestCSV
    CSVReader --> DishCSV
    CSVReader --> OrderCSV

    %% Legend / Models / Exceptions
    subgraph "Models & Exceptions"
        direction TB
        Customer["Customer"]:::model
        Restaurant["Restaurant"]:::model
        Dish["Dish"]:::model
        Order["Order"]:::model
        Exception["Exceptions (NotFound, Exists)"]:::exception
    end

    CustRepo --> Customer
    RestRepo --> Restaurant
    DishRepo --> Dish
    OrderRepo --> Order
    CustRepo --> Exception
    RestRepo --> Exception
    DishRepo --> Exception
    OrderRepo --> Exception

    %% Styles
    classDef entry fill:#CCCCFF,stroke:#333,stroke-width:1px;
    classDef ui fill:#AEDFF7,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef controller fill:#8FBC8F,stroke:#333,stroke-width:1px;
    classDef service fill:#F7E26B,stroke:#333,stroke-width:1px;
    classDef repository fill:#F4A460,stroke:#333,stroke-width:1px;
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef factory fill:#DDA0DD,stroke:#333,stroke-width:1px;
    classDef datastore fill:#FFA500,stroke:#333,stroke-width:1px,shape:cylinder;
    classDef model fill:#FFFFFF,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2;
    classDef exception fill:#FFC0CB,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2;
```
