# retsu28/cookmate-recipe architecture

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

- Interactive diagram: https://gitdiagram.com/retsu28/cookmate-recipe
- Repository: https://github.com/retsu28/cookmate-recipe

## Overview

CookMate is a recipe and meal-planning product with web and mobile clients, an Express/PostgreSQL API, and an optional ML analytics service for the admin panel. The user-facing flow is browsing recipes and planning meals through a client, with the API handling domain requests and persistent data; authentication also exchanges Firebase identity with the backend. The graph preserves major documented capabilities, including camera/AI features, offline support, notifications, and analytics. Several links are dashed where the supplied excerpts do not show the runtime wiring directly.

Main entry points: [`src/App.tsx`](https://github.com/retsu28/cookmate-recipe/blob/main/src/App.tsx) (Web application), [`api/src/server.js`](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/server.js) (HTTP API), [`ml_service/routers/ml_router.py`](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/routers/ml_router.py) (Analytics routes), [`ml_service/main.py`](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/main.py) (Analytics service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_web["Web application<br/>[App.tsx]"]
  node_mobile["Mobile application<br/>[App.js]"]
  node_recipe_search["Recipe discovery<br/>[Search.tsx]"]
  node_camera["AI camera<br/>[AICamera.tsx]"]
  node_planner_ui["Meal planning UI<br/>[MealPlanner.tsx]"]
  node_offline["Offline support<br/>[cacheService.ts]"]
  node_admin_analytics["Admin analytics<br/>[MLAnalytics.tsx]"]
end

subgraph group_api["Product API"]
  node_api_server["HTTP API<br/>[server.js]"]
  node_auth["Authentication<br/>[authController.js]"]
  node_recipes["Recipe management"]
  node_planner["Meal planning"]
  node_notifications["Planner reminders"]
  node_chat["AI chat<br/>[chatService.js]"]
  node_api_ml["ML integration<br/>[mlController.js]"]
end

subgraph group_ml["ML analytics"]
  node_ml_service["Analytics service<br/>[main.py]"]
  node_ml_router["Analytics routes<br/>[ml_router.py]"]
  node_forecasts["Forecast models<br/>[trend.py]"]
  node_churn["Churn model<br/>[churn.py]"]
  node_gaps["Ingredient gaps<br/>[gaps.py]"]
  node_traffic["Traffic model<br/>[traffic.py]"]
end

subgraph group_stores["Data and identity"]
  node_postgres[("PostgreSQL<br/>[db.js]")]
  node_firebase(("Firebase Auth"))
end

node_user(("CookMate user"))

node_user -->|"uses"| node_web
node_user -->|"uses"| node_mobile
node_web -->|"routes to"| node_recipe_search
node_recipe_search -->|"requests data"| node_web
node_web -.->|"calls"| node_api_server
node_mobile -.->|"calls"| node_api_server
node_api_server -->|"routes to"| node_recipes
node_api_server -->|"checks connection"| node_postgres
node_recipes -->|"queries"| node_postgres
node_planner -->|"queries"| node_postgres
node_auth -->|"queries"| node_postgres
node_web -->|"authenticates with"| node_firebase
node_web -->|"exchanges identity"| node_api_server
node_planner -->|"schedules reminders"| node_notifications
node_camera -.->|"submits analysis"| node_api_server
node_web -.->|"uses cache"| node_offline
node_api_server -.->|"routes ML requests"| node_api_ml
node_api_ml -.->|"requests analytics"| node_ml_service
node_admin_analytics -->|"uses analytics"| node_ml_service
node_ml_service -->|"mounts routes"| node_ml_router
node_ml_service -->|"trains models"| node_forecasts
node_ml_router -->|"calls predictions"| node_forecasts
node_ml_router -->|"calls predictions"| node_churn
node_ml_router -->|"calls predictions"| node_gaps
node_ml_router -->|"calls predictions"| node_traffic

click node_web "https://github.com/retsu28/cookmate-recipe/blob/main/src/App.tsx"
click node_mobile "https://github.com/retsu28/cookmate-recipe/blob/main/mobile/App.js"
click node_recipe_search "https://github.com/retsu28/cookmate-recipe/blob/main/src/pages/Search.tsx"
click node_camera "https://github.com/retsu28/cookmate-recipe/blob/main/src/pages/AICamera.tsx"
click node_planner_ui "https://github.com/retsu28/cookmate-recipe/blob/main/src/pages/MealPlanner.tsx"
click node_offline "https://github.com/retsu28/cookmate-recipe/blob/main/src/offline/cacheService.ts"
click node_api_server "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/server.js"
click node_auth "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/authController.js"
click node_recipes "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/recipeController.js"
click node_planner "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/mealPlannerController.js"
click node_notifications "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/services/plannerReminderService.js"
click node_chat "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/services/chatService.js"
click node_api_ml "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/mlController.js"
click node_postgres "https://github.com/retsu28/cookmate-recipe/blob/main/api/src/config/db.js"
click node_ml_service "https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/main.py"
click node_ml_router "https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/routers/ml_router.py"
click node_forecasts "https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/trend.py"
click node_churn "https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/churn.py"
click node_gaps "https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/gaps.py"
click node_traffic "https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/traffic.py"
click node_admin_analytics "https://github.com/retsu28/cookmate-recipe/blob/main/src/admin/pages/MLAnalytics.tsx"

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_web,node_mobile,node_recipe_search,node_camera,node_planner_ui,node_offline,node_admin_analytics,node_user toneBlue
class node_api_server,node_auth,node_recipes,node_planner,node_notifications,node_chat,node_api_ml toneAmber
class node_ml_service,node_ml_router,node_forecasts,node_churn,node_gaps,node_traffic toneMint
class node_postgres,node_firebase toneRose
```

## Components

### User clients

- [Web application](https://github.com/retsu28/cookmate-recipe/blob/main/src/App.tsx): `src/App.tsx`
- [Mobile application](https://github.com/retsu28/cookmate-recipe/blob/main/mobile/App.js): `mobile/App.js`
- [Recipe discovery](https://github.com/retsu28/cookmate-recipe/blob/main/src/pages/Search.tsx): `src/pages/Search.tsx`
- [AI camera](https://github.com/retsu28/cookmate-recipe/blob/main/src/pages/AICamera.tsx): `src/pages/AICamera.tsx`
- [Meal planning UI](https://github.com/retsu28/cookmate-recipe/blob/main/src/pages/MealPlanner.tsx): `src/pages/MealPlanner.tsx`
- [Offline support](https://github.com/retsu28/cookmate-recipe/blob/main/src/offline/cacheService.ts): `src/offline/cacheService.ts`
- [Admin analytics](https://github.com/retsu28/cookmate-recipe/blob/main/src/admin/pages/MLAnalytics.tsx): `src/admin/pages/MLAnalytics.tsx`

### Product API

- [HTTP API](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/server.js): `api/src/server.js`
- [Authentication](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/authController.js): `api/src/controllers/authController.js`
- [Recipe management](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/recipeController.js): `api/src/controllers/recipeController.js`
- [Meal planning](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/mealPlannerController.js): `api/src/controllers/mealPlannerController.js`
- [Planner reminders](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/services/plannerReminderService.js): `api/src/services/plannerReminderService.js`
- [AI chat](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/services/chatService.js): `api/src/services/chatService.js`
- [ML integration](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/controllers/mlController.js): `api/src/controllers/mlController.js`

### ML analytics

- [Analytics service](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/main.py): `ml_service/main.py`
- [Analytics routes](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/routers/ml_router.py): `ml_service/routers/ml_router.py`
- [Forecast models](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/trend.py): `ml_service/models/trend.py`
- [Churn model](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/churn.py): `ml_service/models/churn.py`
- [Ingredient gaps](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/gaps.py): `ml_service/models/gaps.py`
- [Traffic model](https://github.com/retsu28/cookmate-recipe/blob/main/ml_service/models/traffic.py): `ml_service/models/traffic.py`

### Data and identity

- [PostgreSQL](https://github.com/retsu28/cookmate-recipe/blob/main/api/src/config/db.js): `api/src/config/db.js`
- **Firebase Auth**

### Other components

- **CookMate user**

## Connections

- CookMate user → Web application: uses (evidence: `README.md`)
- CookMate user → Mobile application: uses (evidence: `README.md`)
- Web application → Recipe discovery: routes to (evidence: `src/App.tsx`)
- Recipe discovery → Web application: requests data (evidence: `src/pages/Search.tsx`)
- Web application → HTTP API: calls
- Mobile application → HTTP API: calls
- HTTP API → Recipe management: routes to (evidence: `api/src/server.js`)
- HTTP API → PostgreSQL: checks connection (evidence: `api/src/server.js`)
- Recipe management → PostgreSQL: queries (evidence: `api/src/controllers/recipeController.js`)
- Meal planning → PostgreSQL: queries (evidence: `api/src/controllers/mealPlannerController.js`)
- Authentication → PostgreSQL: queries (evidence: `api/src/controllers/authController.js`)
- Web application → Firebase Auth: authenticates with
- Web application → HTTP API: exchanges identity
- Meal planning → Planner reminders: schedules reminders (evidence: `api/src/controllers/mealPlannerController.js`)
- AI camera → HTTP API: submits analysis
- Web application → Offline support: uses cache
- HTTP API → ML integration: routes ML requests
- ML integration → Analytics service: requests analytics
- Admin analytics → Analytics service: uses analytics (evidence: `README.md`)
- Analytics service → Analytics routes: mounts routes (evidence: `ml_service/main.py`)
- Analytics service → Forecast models: trains models (evidence: `ml_service/main.py`)
- Analytics routes → Forecast models: calls predictions (evidence: `ml_service/routers/ml_router.py`)
- Analytics routes → Churn model: calls predictions (evidence: `ml_service/routers/ml_router.py`)
- Analytics routes → Ingredient gaps: calls predictions (evidence: `ml_service/routers/ml_router.py`)
- Analytics routes → Traffic model: calls predictions (evidence: `ml_service/routers/ml_router.py`)
