# amruta-katkar/food-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/amruta-katkar/food-calculator
- Repository: https://github.com/amruta-katkar/food-calculator

## Overview

1. **Project shape**
   - This is a small **Java web application** packaged under `webapp/` and designed to run on **Apache Tomcat** from **Eclipse IDE**.
   - The architecture is classic servlet-based MVC-lite: **HTML pages collect input**, **servlets process requests**, and a **Java class holds order state**.

2. **Presentation layer**
   - The visible UI is made of static HTML pages:
     - `welcome.html` as the entry/landing page.
     - `Menu.html` as a menu selection page.
     - `breakfast.html` as an order entry page for breakfast items.
   - These pages are the user-facing boundary and likely submit form data to servlets.

3. **Request-processing layer**
   - The main server-side logic lives in `webapp/java/com/calculator/`.
   - `BreakfastServlet.java` handles breakfast order submission and likely validates/extracts item quantities or selections.
   - `GenerateBillServlet.java` appears to be the final billing endpoint that computes or renders the total bill.

4. **Order/state model**
   - `BreakfastOrder.java` and `Data.java` are the supporting Java classes.
   - `Data.java` is described in the README as a **temporary order store**, so it likely acts as shared mutable state across requests.
   - `BreakfastOrder.java` likely models one breakfast order or a set of breakfast line items.

5. **Core data flow**
   - The flow is probably:
     1. User opens `welcome.html`.
     2. User navigates to `Menu.html`.
     3. User chooses breakfast and submits `breakfast.html`.
     4. `BreakfastServlet` captures the request and stores order details in `Data` / `BreakfastOrder`.
     5. `GenerateBillServlet` reads the stored order state and returns the final bill.
   - The bill calculation is therefore centered in the servlet layer rather than in the HTML.

6. **Boundary between client and server**
   - The HTML pages are the client-side boundary; they only gather and send form data.
   - The servlets are the server-side boundary; they interpret request parameters and produce the response.
   - There is no indication of a database or external persistence layer, so the application likely keeps order data **in memory during the session/request flow**.

7. **Persistence and lifetime**
   - Based on the README, the “temporary order” class suggests order data is not permanently stored.
   - This means the system is likely intended for a single checkout flow rather than long-lived carts or historical records.
   - An architecture diagram should therefore show **ephemeral in-memory state**, not a DB-backed domain model.

8. **Technology and deployment**
   - The project uses:
     - **Java servlets**
     - **Apache Tomcat**
     - **Eclipse**
   - `webapp/` is the web root, which is consistent with deployment as a servlet application into a servlet container.

9. **Subsystem boundaries to show in a diagram**
   - **Web UI subsystem:** HTML pages.
   - **Controller subsystem:** `BreakfastServlet`, `GenerateBillServlet`.
   - **Order/model subsystem:** `BreakfastOrder`, `Data`.
   - **Container/runtime boundary:** Tomcat hosting servlet endpoints.

10. **What is most important to capture**
   - The key architectural idea is that the app is a **simple bill calculator**, not a full commerce platform.
   - Its main interaction pattern is **form submission → servlet processing → temporary order state → bill generation**.
   - There are no visible integrations with databases, APIs, or authentication systems in the provided tree.

Main entry points: [`webapp/java/com/calculator/BreakfastServlet.java`](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/BreakfastServlet.java) (BreakfastServlet), [`webapp/java/com/calculator/GenerateBillServlet.java`](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/GenerateBillServlet.java) (Bill Servlet), [`webapp/java/com/calculator/BreakfastOrder.java`](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/BreakfastOrder.java) (BreakfastOrder), [`webapp/java/com/calculator/Data.java`](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/Data.java) (Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_tomcat[("Tomcat<br/>container")]
end

subgraph group_ui["Web UI"]
  node_welcome["Welcome<br/>html page<br/>[welcome.html]"]
  node_menu["Menu<br/>html page<br/>[Menu.html]"]
  node_breakfast_page["Breakfast<br/>html form<br/>[breakfast.html]"]
end

subgraph group_controllers["Controllers"]
  node_breakfast_servlet["BreakfastServlet"]
  node_bill_servlet["Bill Servlet"]
end

subgraph group_model["Order Model"]
  node_data[("Data<br/>temp store<br/>[Data.java]")]
  node_order{{"BreakfastOrder<br/>order model"}}
end

node_tomcat -->|"serves"| node_welcome
node_tomcat -->|"runs"| node_breakfast_servlet
node_tomcat -->|"runs"| node_bill_servlet
node_welcome -->|"navigate"| node_menu
node_menu -->|"choose breakfast"| node_breakfast_page
node_breakfast_page -->|"submit form"| node_breakfast_servlet
node_breakfast_servlet -->|"builds"| node_order
node_breakfast_servlet -->|"stores"| node_data
node_bill_servlet -->|"reads"| node_data
node_bill_servlet -->|"calculates"| node_order
node_order -.->|"persists temp"| node_data

click node_welcome "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/welcome.html"
click node_menu "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/Menu.html"
click node_breakfast_page "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/breakfast.html"
click node_breakfast_servlet "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/BreakfastServlet.java"
click node_bill_servlet "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/GenerateBillServlet.java"
click node_data "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/Data.java"
click node_order "https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/BreakfastOrder.java"

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_tomcat toneBlue
class node_welcome,node_menu,node_breakfast_page toneAmber
class node_breakfast_servlet,node_bill_servlet toneMint
class node_data,node_order toneRose
```

## Components

### Runtime

Servlet container and deployment boundary

- **Tomcat**: container · Apache Tomcat hosts the servlet app

### Web UI

Static pages that collect user input

- [Welcome](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/welcome.html): html page · Entry and landing page · `webapp/welcome.html`
- [Menu](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/Menu.html): html page · Menu selection page · `webapp/Menu.html`
- [Breakfast](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/breakfast.html): html form · Breakfast order entry page · `webapp/breakfast.html`

### Controllers

Servlets that handle requests and responses

- [BreakfastServlet](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/BreakfastServlet.java): servlet · Captures breakfast order submission · `webapp/java/com/calculator/BreakfastServlet.java`
- [Bill Servlet](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/GenerateBillServlet.java): servlet · Generates the final bill · `webapp/java/com/calculator/GenerateBillServlet.java`

### Order Model

Ephemeral in-memory order state

- [Data](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/Data.java): temp store · Temporary shared order state · `webapp/java/com/calculator/Data.java`
- [BreakfastOrder](https://github.com/amruta-katkar/food-calculator/blob/main/webapp/java/com/calculator/BreakfastOrder.java): order model · Breakfast order representation · `webapp/java/com/calculator/BreakfastOrder.java`

## Connections

- Tomcat → Welcome: serves · Container hosts the entry page
- Tomcat → BreakfastServlet: runs · Container executes servlet endpoints
- Tomcat → Bill Servlet: runs · Container executes servlet endpoints
- Welcome → Menu: navigate · User moves from landing page to menu
- Menu → Breakfast: choose breakfast · Menu leads into breakfast ordering
- Breakfast → BreakfastServlet: submit form · Breakfast form posts order data
- BreakfastServlet → BreakfastOrder: builds · Servlet creates or updates order data
- BreakfastServlet → Data: stores · Order details are kept temporarily in memory
- Bill Servlet → Data: reads · Billing endpoint retrieves stored order state
- Bill Servlet → BreakfastOrder: calculates · Bill generation uses the order model
- BreakfastOrder → Data: persists temp · Order state is held in the temporary store
