How jitashi-arora/smart-kitchen works
This is a single-process Java CLI application (no server, no database, no networked components) whose purpose is to:
• Maintain an in-memory fridge inventory
• Track expiration dates (perishable vs non-perishable)
• Maintain an in-memory recipe book
• Run a matching/priority engine that finds cookable recipes and prioritizes those that prevent waste (expiring ingredients)
• Entry point + UI flow
• Domain models
• Engine/service logic
• Data stores (in-memory collections)
• Key algorithms (expiry checks + recipe matching)
File structure analysis (what components exist)
Only two code files exist:
• KitchenApp.java
• Application entry point
• CLI menus, user prompts, input parsing
• Calls into core logic
• Models.java
• Domain entities + engine:
• Ingredient (abstract)
• Perishable, NonPerishable
• Recipe (with HashMap of ingredient requirements)
• KitchenEngine (manages lists and smart matching)
There are no persistence, external APIs, or deployment concerns in this repo; everything is local and in-memory.
What the README reveals (important behaviors to represent)
• Expiry tracking using java.time.LocalDate and ChronoUnit
• “Expiring soon” threshold (within 3 days) and UI flagging
• Matching engine that:
• Scans inventory vs recipe requirements
• Produces classifications: [READY] vs [URGENT - SAVE FOOD]
• Collections:
• ArrayList for inventory and recipe book
• HashMap inside Recipe for ingredient->quantity requirements
Domain Model Layer
• Ingredient (abstract)
• Common fields: name, quantity, unit, food group (as implied)
• Common behaviors: toString()
• Perishable extends Ingredient
• expiry date
• isExpiringSoon() logic (or equivalent)
• NonPerishable extends Ingredient
• no expiry date, or always “not expiring”
Recipe Model
• Recipe
• name
• requirements: HashMap<IngredientName/Key, Quantity> (key specifics depend on code)
• methods to add requirement lines, render details
Application / Service Layer
• KitchenEngine
• owns/manages:
• inventory: ArrayList<Ingredient>
• recipes: ArrayList<Recipe>
• operations:
• Ingredient
• Recipe
• Fridge (and mark expiring soon)
• match recipes against inventory
• prioritize “urgent” recipes that use expiring-soon ingredients
Runtime / Libraries
• Java Runtime + standard library
• java.time.LocalDate
• ChronoUnit
• ArrayList, HashMap
Even though “Java standard library” isn’t usually a component, here it’s architecturally relevant because expiration and matching depend on those APIs.
Primary control flow:
• User → KitchenApp (CLI) → KitchenEngine
• “Add Ingredient” command calls engine add method
• “Add Recipe” command calls engine add method
• “Show Fridge” calls engine list method
• “Find What I Can Cook” calls engine match method
Domain usage:
• KitchenEngine → uses/contains → Ingredient instances (Perishable/NonPerishable)
• KitchenEngine → uses/contains → Recipe instances
• Recipe → contains → HashMap of requirements
Expiration logic:
• KitchenEngine and/or Perishable → uses → LocalDate/ChronoUnit
• KitchenApp → displays → “expiring soon” flag (data comes from engine/model)
• KitchenEngine.matchRecipes()
• reads inventory (ArrayList<Ingredient>)
• reads recipes (ArrayList<Recipe>) + each recipe’s requirements (HashMap)
• produces MatchResult conceptually (even if not a class) that includes:
• status: READY / URGENT / NOT READY
• missing ingredients and/or soon-to-expire ingredients used
Even if the code prints directly instead of returning structured results, represent the *conceptual output* of the engine to the UI.
Architectural patterns/design principles used
• Layering: CLI (presentation) vs Engine (application logic) vs Models (domain)
• OOP inheritance & polymorphism:
• Ingredient → (Perishable, NonPerishable)
• different toString() / expiration behavior
• In-memory repository pattern (implicit):
• KitchenEngine acts like a repository/service holding lists (no DB)
• Rules/Policy:
• “expiring soon = within 3 days” is a business rule; annotate it near the expiry component
Technologies/frameworks
In labels or side notes:
• Language: Java (JDK 8+)
• Collections: ArrayList, HashMap
• Dates: LocalDate, ChronoUnit
• Execution: CLI single JVM process