# rupertz/tropico-resipetanaw architecture

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

- Interactive diagram: https://gitdiagram.com/rupertz/tropico-resipetanaw
- Repository: https://github.com/rupertz/tropico-resipetanaw

## Overview

ResipeTanaw is a commissary production planner: production heads maintain ingredients and recipes, plan scaled batches, and kitchen staff start and complete them while recording actual yield. The React app provides login, overview, and management workflows; its shared API client sends requests to PHP endpoints, which enforce roles and batch rules server-side and persist operational data in MySQL. The README documents transactional stock deduction and refusal on shortages. Some endpoint relationships are based on explicit README behavior because their source was not sampled.

Main entry points: [`frontend/src/App.jsx`](https://github.com/rupertz/tropico-resipetanaw/blob/main/frontend/src/App.jsx) (Planner interface), [`api/_db.php`](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/_db.php) (Database connection), [`frontend/src/api.js`](https://github.com/rupertz/tropico-resipetanaw/blob/main/frontend/src/api.js) (API client), [`api/batches.php`](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/batches.php) (Batch API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React application"]
  node_app["Planner interface<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["PHP API"]
  node_auth_endpoint["Authentication<br/>[auth.php]"]
  node_ingredient_endpoint["Ingredient API<br/>[ingredients.php]"]
  node_recipe_endpoint["Recipe API<br/>[recipes.php]"]
  node_batch_endpoint["Batch API<br/>[batches.php]"]
  node_health["Health endpoint<br/>[health.php]"]
  node_notes["Notes endpoint<br/>[notes.php]"]
end

subgraph group_domain["Production domain"]
  node_auth_guards["Session and roles<br/>[_auth.php]"]
  node_batch_rules["Batch rules<br/>[rules.php]"]
end

subgraph group_storage["Persistence"]
  node_database[("Operational database<br/>[database.sql]")]
  node_db_connection["Database connection<br/>[_db.php]"]
  node_legacy_db["Alternate DB helpers<br/>[db.php]"]
end

node_production_head(("Production head"))
node_kitchen_staff(("Kitchen staff"))

node_production_head -->|"manages production"| node_app
node_kitchen_staff -->|"works batches"| node_app
node_app -->|"calls"| node_api_client
node_app -->|"requests login"| node_auth_endpoint
node_app -->|"manages stock"| node_ingredient_endpoint
node_app -->|"manages recipes"| node_recipe_endpoint
node_app -->|"plans and updates"| node_batch_endpoint
node_api_client -->|"sends HTTP"| node_auth_endpoint
node_api_client -->|"sends HTTP"| node_ingredient_endpoint
node_api_client -->|"sends HTTP"| node_recipe_endpoint
node_api_client -->|"sends HTTP"| node_batch_endpoint
node_auth_endpoint -->|"uses sessions"| node_auth_guards
node_ingredient_endpoint -->|"checks roles"| node_auth_guards
node_recipe_endpoint -->|"checks roles"| node_auth_guards
node_batch_endpoint -->|"checks roles"| node_auth_guards
node_batch_endpoint -->|"checks transitions"| node_batch_rules
node_auth_endpoint -->|"queries users"| node_db_connection
node_ingredient_endpoint -->|"reads and writes"| node_db_connection
node_recipe_endpoint -->|"reads and writes"| node_db_connection
node_batch_endpoint -->|"reads and writes"| node_db_connection
node_batch_rules -->|"queries stock"| node_db_connection
node_db_connection -.->|"connects to"| node_database
node_health -->|"uses helpers"| node_legacy_db
node_notes -->|"uses helpers"| node_legacy_db

click node_app "https://github.com/rupertz/tropico-resipetanaw/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/rupertz/tropico-resipetanaw/blob/main/frontend/src/api.js"
click node_auth_endpoint "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/auth.php"
click node_ingredient_endpoint "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/ingredients.php"
click node_recipe_endpoint "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/recipes.php"
click node_batch_endpoint "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/batches.php"
click node_auth_guards "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/_auth.php"
click node_batch_rules "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/rules.php"
click node_database "https://github.com/rupertz/tropico-resipetanaw/blob/main/database.sql"
click node_db_connection "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/_db.php"
click node_legacy_db "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/db.php"
click node_health "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/health.php"
click node_notes "https://github.com/rupertz/tropico-resipetanaw/blob/main/api/notes.php"

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_app,node_api_client toneBlue
class node_auth_endpoint,node_ingredient_endpoint,node_recipe_endpoint,node_batch_endpoint,node_health,node_notes toneAmber
class node_auth_guards,node_batch_rules toneMint
class node_database,node_db_connection,node_legacy_db toneRose
class node_production_head,node_kitchen_staff toneIndigo
```

## Components

### React application

- [Planner interface](https://github.com/rupertz/tropico-resipetanaw/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/rupertz/tropico-resipetanaw/blob/main/frontend/src/api.js): `frontend/src/api.js`

### PHP API

- [Authentication](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/auth.php): `api/auth.php`
- [Ingredient API](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/ingredients.php): `api/ingredients.php`
- [Recipe API](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/recipes.php): `api/recipes.php`
- [Batch API](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/batches.php): `api/batches.php`
- [Health endpoint](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/health.php): `api/health.php`
- [Notes endpoint](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/notes.php): `api/notes.php`

### Production domain

- [Session and roles](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/_auth.php): `api/_auth.php`
- [Batch rules](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/rules.php): `api/rules.php`

### Persistence

- [Operational database](https://github.com/rupertz/tropico-resipetanaw/blob/main/database.sql): `database.sql`
- [Database connection](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/_db.php): `api/_db.php`
- [Alternate DB helpers](https://github.com/rupertz/tropico-resipetanaw/blob/main/api/db.php): `api/db.php`

### Other components

- **Production head**
- **Kitchen staff**

## Connections

- Production head → Planner interface: manages production (evidence: `README.md`)
- Kitchen staff → Planner interface: works batches (evidence: `README.md`)
- Planner interface → API client: calls (evidence: `frontend/src/App.jsx`)
- Planner interface → Authentication: requests login (evidence: `frontend/src/App.jsx`)
- Planner interface → Ingredient API: manages stock (evidence: `frontend/src/App.jsx`)
- Planner interface → Recipe API: manages recipes (evidence: `frontend/src/App.jsx`)
- Planner interface → Batch API: plans and updates (evidence: `frontend/src/App.jsx`)
- API client → Authentication: sends HTTP (evidence: `frontend/src/api.js`)
- API client → Ingredient API: sends HTTP (evidence: `frontend/src/api.js`)
- API client → Recipe API: sends HTTP (evidence: `frontend/src/api.js`)
- API client → Batch API: sends HTTP (evidence: `frontend/src/api.js`)
- Authentication → Session and roles: uses sessions (evidence: `api/auth.php`)
- Ingredient API → Session and roles: checks roles (evidence: `api/ingredients.php`)
- Recipe API → Session and roles: checks roles (evidence: `api/recipes.php`)
- Batch API → Session and roles: checks roles (evidence: `api/batches.php`)
- Batch API → Batch rules: checks transitions (evidence: `api/batches.php`)
- Authentication → Database connection: queries users (evidence: `api/auth.php`)
- Ingredient API → Database connection: reads and writes (evidence: `api/ingredients.php`)
- Recipe API → Database connection: reads and writes (evidence: `api/recipes.php`)
- Batch API → Database connection: reads and writes (evidence: `api/batches.php`)
- Batch rules → Database connection: queries stock (evidence: `api/rules.php`)
- Database connection → Operational database: connects to
- Health endpoint → Alternate DB helpers: uses helpers (evidence: `api/health.php`)
- Notes endpoint → Alternate DB helpers: uses helpers (evidence: `api/notes.php`)
