# roodhadson/amorhorneado architecture

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

- Interactive diagram: https://gitdiagram.com/roodhadson/amorhorneado
- Repository: https://github.com/roodhadson/amorhorneado

## Overview

1. **Overall shape**
   - This is a single **Android app** built in **Kotlin** with **Jetpack Compose**.
   - The architecture follows a clear **MVVM** split: UI screens in `ui/`, state holders in `ViewModel`s, and data access in `data/`.
   - The app is primarily **offline-first** through **Room**, with one external API integration for weather.

2. **App entry and wiring**
   - `MainActivity` is the UI entry point.
   - `BakeryApplication` is the application-level bootstrap class, likely used to initialize the database/repositories.
   - `AppViewModelProvider` centralizes ViewModel creation and dependency wiring for the Compose screens.

3. **Presentation layer**
   - The `ui/` package is organized by feature: `dashboard`, `ingredients`, `inventory`, `production`, `recipes`, `debts`, and `raffle`.
   - Each feature typically has a **screen composable** plus a **ViewModel** that owns its state.
   - Shared UI primitives live in `ui/components/BakeryComponents.kt`, while the app’s dark visual system is defined in `ui/theme/`.

4. **Navigation and user flows**
   - The app appears to be centered around a **dashboard-first experience** with feature screens reachable from there.
   - The README mentions a **bottom navigation bar** with a central **FAB** for quick production entry, so the main interaction model is likely dashboard + docked nav + action button.
   - Screens such as `DashboardScreen`, `SalesSummaryScreen`, `InventoryScreen`, `ProductionScreen`, `RecipesScreen`, and `DebtsScreen` represent the primary navigation targets.

5. **State management**
   - ViewModels in each feature package expose UI state and user actions.
   - The README mentions **StateFlow** and **Coroutines**, so UI state is reactive and updated asynchronously from database/network sources.
   - This keeps Compose screens thin: they render state and forward events, while logic sits in ViewModels.

6. **Persistence layer**
   - The `data/` package contains the app’s local data model and persistence boundary.
   - `AppDatabase` is the Room database entry point.
   - `IngredientDao` and `IngredientRepository` show a repository pattern on top of Room.
   - The data entities cover core bakery concepts: `Ingredient`, `Recipe`, `ProductionRecord`, `ProductionCost`, `SaleRecord`, `Debt`, `Customer`, `ExchangeRate`, and `UserConfig`.

7. **Core business domains**
   - **Ingredients / inventory:** manage raw materials, costs, and stock.
   - **Recipes / production:** define product formulas and compute production cost from ingredients plus fixed expenses.
   - **Sales / customer finance:** track sales, customers, debts, and payments.
   - **Dashboard analytics:** aggregate KPI-style summaries for sales and operational status.
   - **Raffle:** a separate feature with its own screen and ViewModel, likely for promotional/customer engagement.

8. **Important data relationships**
   - Ingredient pricing changes are a key business rule: the README says updating an ingredient price should propagate to all linked recipes and their costs.
   - Recipe and production screens therefore depend on ingredient data, not just display it.
   - Production cost calculation combines **ingredient costs** with **fixed operating expenses** like gas, electricity, and labor.
   - Debt and customer data feed finance views and ranking-style summaries.

9. **External integration**
   - `network/WeatherApiService.kt` is the only explicit network boundary.
   - Weather data is used by the dashboard for demand forecasting or context-aware analytics.
   - Everything else is designed to function locally, which is important for the diagram: local Room data is the system of record, weather is an auxiliary signal.

10. **Cross-feature reporting**
   - `DashboardViewModel` and `SalesSummaryViewModel` likely aggregate data from multiple sources: sales records, inventory status, and weather.
   - This means the dashboard is not a separate subsystem; it is a composition layer over the operational modules.
   - If drawing boundaries, treat analytics as a read-only consumer of the transactional data model.

11. **Resources and UI identity**
   - The app has a strong branded presentation layer: dark theme colors, custom launcher assets, and a raffle animation in `res/raw/ruleta_anim.json`.
   - These assets support the premium bakery-themed UX but do not change the core data architecture.
   - `ui/theme/Color.kt`, `Theme.kt`, and `Type.kt` define the visual system used across screens.

12. **Tests and build structure**
   - Standard Android unit and instrumentation test locations exist under `app/src/test` and `app/src/androidTest`.
   - The root Gradle files indicate a conventional single-module Android build.
   - There are also top-level `BakeryDao.kt` and `BakeryModels.kt` files outside `app/src`, which look like shared or legacy source files and should be shown separately if they are actually compiled into the app.

13. **What to emphasize in an architecture diagram**
   - Show the flow: **Compose screens → ViewModels → Repository/DAO → Room database**, with **Weather API** as a side input to dashboard logic.
   - Treat **Ingredients, Recipes, Production, Debts, and Sales** as the main business domains.
   - Highlight that **inventory and pricing changes propagate into production cost and recipe views**, while **dashboard screens aggregate data from all domains**.

Main entry points: [`app/src/main/java/com/example/amorhorneado/ui/AppViewModelProvider.kt`](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/AppViewModelProvider.kt) (VM Provider), [`app/src/main/java/com/example/amorhorneado/data/AppDatabase.kt`](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/AppDatabase.kt) (Room DB), [`app/src/main/java/com/example/amorhorneado/ui/dashboard/DashboardViewModel.kt`](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/dashboard/DashboardViewModel.kt) (Dashboard VM), [`app/src/main/java/com/example/amorhorneado/ui/dashboard/SalesSummaryViewModel.kt`](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/dashboard/SalesSummaryViewModel.kt) (Sales VM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app_shell["App shell"]
  node_main_activity["MainActivity<br/>entry point<br/>[MainActivity.kt]"]
  node_app_class["App"]
end

subgraph group_presentation["Presentation"]
  node_viewmodel_provider["VM Provider<br/>wiring"]
  node_dashboard_vm["Dashboard VM<br/>state holder"]
  node_sales_summary_vm["Sales VM<br/>state holder"]
  node_ingredients_vm["Ingredients VM<br/>state holder"]
  node_inventory_screen["Inventory<br/>screen<br/>[InventoryScreen.kt]"]
  node_production_vm["Production VM<br/>state holder"]
  node_production_cost_vm["Cost VM<br/>state holder"]
  node_recipes_vm["Recipes VM<br/>state holder"]
  node_debt_vm["Debt VM<br/>state holder<br/>[DebtViewModel.kt]"]
  node_raffle_vm["Raffle VM<br/>state holder<br/>[RaffleViewModel.kt]"]
  node_components["Components<br/>ui primitives"]
end

subgraph group_data["Data layer"]
  node_room_db[("Room DB<br/>database<br/>[AppDatabase.kt]")]
  node_ingredient_repo["Ingredient Repo"]
  node_ingredient_dao["Ingredient DAO<br/>[IngredientDao.kt]"]
  node_models["Models<br/>[Models.kt]"]
end

subgraph group_integration["Integration"]
  node_weather_api["Weather API<br/>external api"]
end

subgraph group_assets["Assets"]
  node_theme["Theme<br/>design system<br/>[Theme.kt]"]
  node_branding["Brand assets<br/>[ruleta_anim.json]"]
end

node_main_activity -->|"uses"| node_viewmodel_provider
node_app_class -->|"initializes"| node_room_db
node_viewmodel_provider -->|"creates"| node_dashboard_vm
node_viewmodel_provider -->|"creates"| node_sales_summary_vm
node_viewmodel_provider -->|"creates"| node_ingredients_vm
node_viewmodel_provider -->|"creates"| node_production_vm
node_viewmodel_provider -->|"creates"| node_production_cost_vm
node_viewmodel_provider -->|"creates"| node_recipes_vm
node_viewmodel_provider -->|"creates"| node_debt_vm
node_viewmodel_provider -->|"creates"| node_raffle_vm
node_dashboard_vm -->|"reads"| node_weather_api
node_dashboard_vm -->|"aggregates"| node_room_db
node_sales_summary_vm -->|"aggregates"| node_room_db
node_ingredients_vm -->|"uses"| node_ingredient_repo
node_ingredient_repo -->|"persists"| node_ingredient_dao
node_ingredient_dao -->|"queries"| node_room_db
node_production_vm -->|"reads"| node_room_db
node_production_cost_vm -->|"calculates"| node_models
node_recipes_vm -->|"reads"| node_room_db
node_debt_vm -->|"reads"| node_room_db
node_raffle_vm -->|"reads"| node_room_db
node_dashboard_vm -->|"composes"| node_sales_summary_vm
node_theme -->|"styles"| node_components
node_branding -->|"supports"| node_theme
node_models -->|"defines"| node_room_db

click node_main_activity "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/MainActivity.kt"
click node_app_class "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/BakeryApplication.kt"
click node_viewmodel_provider "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/AppViewModelProvider.kt"
click node_dashboard_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/dashboard/DashboardViewModel.kt"
click node_sales_summary_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/dashboard/SalesSummaryViewModel.kt"
click node_ingredients_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/ingredients/IngredientsViewModel.kt"
click node_inventory_screen "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/inventory/InventoryScreen.kt"
click node_production_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/production/ProductionViewModel.kt"
click node_production_cost_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/production/ProductionCostViewModel.kt"
click node_recipes_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/recipes/RecipesViewModel.kt"
click node_debt_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/debts/DebtViewModel.kt"
click node_raffle_vm "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/raffle/RaffleViewModel.kt"
click node_components "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/components/BakeryComponents.kt"
click node_room_db "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/AppDatabase.kt"
click node_ingredient_repo "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/IngredientRepository.kt"
click node_ingredient_dao "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/IngredientDao.kt"
click node_models "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/Models.kt"
click node_weather_api "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/network/WeatherApiService.kt"
click node_theme "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/theme/Theme.kt"
click node_branding "https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/res/raw/ruleta_anim.json"

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_main_activity,node_app_class toneBlue
class node_viewmodel_provider,node_dashboard_vm,node_sales_summary_vm,node_ingredients_vm,node_inventory_screen,node_production_vm,node_production_cost_vm,node_recipes_vm,node_debt_vm,node_raffle_vm,node_components toneAmber
class node_room_db,node_ingredient_repo,node_ingredient_dao,node_models toneMint
class node_weather_api toneRose
class node_theme,node_branding toneIndigo
```

## Components

### App shell

Application bootstrap and entry points.

- [MainActivity](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/MainActivity.kt): entry point · Compose entry activity for the Android app. · `app/src/main/java/com/example/amorhorneado/MainActivity.kt`
- [App](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/BakeryApplication.kt): application · Application bootstrap class for app-wide initialization. · `app/src/main/java/com/example/amorhorneado/BakeryApplication.kt`

### Presentation

Compose UI, feature screens, and ViewModels.

- [VM Provider](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/AppViewModelProvider.kt): wiring · Central factory for ViewModel creation and dependency injection. · `app/src/main/java/com/example/amorhorneado/ui/AppViewModelProvider.kt`
- [Dashboard VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/dashboard/DashboardViewModel.kt): state holder · Aggregates operational data for the main overview screen. · `app/src/main/java/com/example/amorhorneado/ui/dashboard/DashboardViewModel.kt`
- [Sales VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/dashboard/SalesSummaryViewModel.kt): state holder · Builds sales summary and reporting state. · `app/src/main/java/com/example/amorhorneado/ui/dashboard/SalesSummaryViewModel.kt`
- [Ingredients VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/ingredients/IngredientsViewModel.kt): state holder · Manages ingredient list, edits, and creation flows. · `app/src/main/java/com/example/amorhorneado/ui/ingredients/IngredientsViewModel.kt`
- [Inventory](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/inventory/InventoryScreen.kt): screen · Inventory view for stock status and operational use. · `app/src/main/java/com/example/amorhorneado/ui/inventory/InventoryScreen.kt`
- [Production VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/production/ProductionViewModel.kt): state holder · Coordinates production workflow and related data. · `app/src/main/java/com/example/amorhorneado/ui/production/ProductionViewModel.kt`
- [Cost VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/production/ProductionCostViewModel.kt): state holder · Calculates production cost from ingredients and fixed expenses. · `app/src/main/java/com/example/amorhorneado/ui/production/ProductionCostViewModel.kt`
- [Recipes VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/recipes/RecipesViewModel.kt): state holder · Manages recipe browsing, details, and editing state. · `app/src/main/java/com/example/amorhorneado/ui/recipes/RecipesViewModel.kt`
- [Debt VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/debts/DebtViewModel.kt): state holder · Handles customer debt and payment-related state. · `app/src/main/java/com/example/amorhorneado/ui/debts/DebtViewModel.kt`
- [Raffle VM](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/raffle/RaffleViewModel.kt): state holder · Controls the raffle feature state and actions. · `app/src/main/java/com/example/amorhorneado/ui/raffle/RaffleViewModel.kt`
- [Components](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/components/BakeryComponents.kt): ui primitives · Shared reusable Compose components. · `app/src/main/java/com/example/amorhorneado/ui/components/BakeryComponents.kt`

### Data layer

Local persistence and core business data models.

- [Room DB](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/AppDatabase.kt): database · App database entry point and persistence hub. · `app/src/main/java/com/example/amorhorneado/data/AppDatabase.kt`
- [Ingredient Repo](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/IngredientRepository.kt): repository · Repository boundary over ingredient persistence. · `app/src/main/java/com/example/amorhorneado/data/IngredientRepository.kt`
- [Ingredient DAO](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/IngredientDao.kt): dao · Room access object for ingredient operations. · `app/src/main/java/com/example/amorhorneado/data/IngredientDao.kt`
- [Models](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/data/Models.kt): domain models · Core bakery entities for ingredients, recipes, production, sales, debts, customers, exchange rates, and config. · `app/src/main/java/com/example/amorhorneado/data/Models.kt`

### Integration

External services and API boundaries.

- [Weather API](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/network/WeatherApiService.kt): external api · External weather integration used as a contextual dashboard signal. · `app/src/main/java/com/example/amorhorneado/network/WeatherApiService.kt`

### Assets

Theme, resources, and branded UI assets.

- [Theme](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/java/com/example/amorhorneado/ui/theme/Theme.kt): design system · Compose theme, colors, and typography for the app. · `app/src/main/java/com/example/amorhorneado/ui/theme/Theme.kt`
- [Brand assets](https://github.com/roodhadson/amorhorneado/blob/main/app/src/main/res/raw/ruleta_anim.json): assets · Launcher art, colors, strings, and raffle animation resources. · `app/src/main/res/raw/ruleta_anim.json`

## Connections

- MainActivity → VM Provider: uses · Activity enters the Compose app and resolves feature ViewModels.
- App → Room DB: initializes · Application bootstrap is the likely place for app-wide persistence setup.
- VM Provider → Dashboard VM: creates · Provides the dashboard state holder.
- VM Provider → Sales VM: creates · Provides the sales reporting state holder.
- VM Provider → Ingredients VM: creates · Provides the ingredients feature state holder.
- VM Provider → Production VM: creates · Provides the production workflow state holder.
- VM Provider → Cost VM: creates · Provides the production cost calculator state holder.
- VM Provider → Recipes VM: creates · Provides the recipes feature state holder.
- VM Provider → Debt VM: creates · Provides the debts feature state holder.
- VM Provider → Raffle VM: creates · Provides the raffle feature state holder.
- Dashboard VM → Weather API: reads · Dashboard uses weather as an auxiliary input for analytics or forecasting.
- Dashboard VM → Room DB: aggregates · Dashboard composes data from the local system of record.
- Sales VM → Room DB: aggregates · Sales summaries are derived from local transactional data.
- Ingredients VM → Ingredient Repo: uses · Ingredient flows go through the repository boundary.
- Ingredient Repo → Ingredient DAO: persists · Repository delegates ingredient operations to Room DAO methods.
- Ingredient DAO → Room DB: queries · DAO accesses the Room database.
- Production VM → Room DB: reads · Production workflow reads persisted recipes, ingredients, and records.
- Cost VM → Models: calculates · Cost logic combines domain entities and business rules.
- Recipes VM → Room DB: reads · Recipes depend on persisted ingredient and recipe data.
- Debt VM → Room DB: reads · Debt management is backed by local customer and debt records.
- Raffle VM → Room DB: reads · Raffle state likely uses persisted customer or campaign data.
- Dashboard VM → Sales VM: composes · Dashboard surfaces reporting summaries as part of the overview.
- Theme → Components: styles · Shared components render with the app theme.
- Brand assets → Theme: supports · Resources back the branded visual system.
- Models → Room DB: defines · Domain entities are stored and queried through Room.
