How tarunmaddipati/food-app-java works
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