How amruta-katkar/food-calculator works
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: BreakfastServlet.java BreakfastServlet · GenerateBillServlet.java Bill Servlet · BreakfastOrder.java BreakfastOrder · Data.java Data
Components 8
Runtime
Servlet container and deployment boundary
- Tomcat · Apache Tomcat hosts the servlet app
Web UI
Static pages that collect user input
Controllers
Servlets that handle requests and responses
- BreakfastServlet · Captures breakfast order submission
webapp/java/com/calculator/BreakfastServlet.java - Bill Servlet · Generates the final bill
webapp/java/com/calculator/GenerateBillServlet.java
Order Model
Ephemeral in-memory order state
- Data · Temporary shared order state
webapp/java/com/calculator/Data.java - BreakfastOrder · Breakfast order representation
webapp/java/com/calculator/BreakfastOrder.java
Connections 11
- 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