# kumardhananjaya/prebite architecture

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

- Interactive diagram: https://gitdiagram.com/kumardhananjaya/prebite
- Repository: https://github.com/kumardhananjaya/prebite

## Overview

PreBite helps diners discover unfamiliar dishes, understand their taste and dietary context, and communicate an order to restaurant staff. The frontend presents onboarding, browsing, dish details, and a waiter phrase; the documented backend separately provides catalog, account, community, and passport APIs backed by MongoDB. The README describes curated demo content and backend capabilities, but does not establish that the frontend pages call those APIs. Backend route/controller connections follow the source index; frontend flow edges reflect documented screens and workflow.

Main entry points: [`backend/app/dependencies.py`](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/dependencies.py) (Request dependencies), [`backend/app/main.py`](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/main.py) (API application), [`backend/app/db.py`](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/db.py) (Database initialization), [`frontend/app/scan/page.tsx`](https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/scan/page.tsx) (Menu discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Diner experience"]
  node_home["Home<br/>[page.tsx]"]
  node_login["Login<br/>[page.tsx]"]
  node_scan["Menu discovery<br/>[page.tsx]"]
  node_dishdetail["Dish details<br/>[page.tsx]"]
  node_waiter["Waiter phrase<br/>[page.tsx]"]
  node_speech["Speech playback<br/>[speech-button.tsx]"]
  node_sensory["Sensory meter<br/>[sensory-meter.tsx]"]
end

subgraph group_catalog["Dish discovery"]
  node_cuisines["Cuisine profiles<br/>[cuisines.ts]"]
  node_frontenddishes["Demo dishes<br/>[dishes.ts]"]
  node_dishapi["Dish catalog API<br/>[dish_controller.py]"]
  node_dishroutes["Dish routes<br/>[dishes.py]"]
end

subgraph group_community["Community and passport"]
  node_communityroutes["Community routes<br/>[community.py]"]
  node_communitylogic["Community guides"]
  node_passportroutes["Passport routes<br/>[passport.py]"]
  node_passportlogic["Passport stamps"]
end

subgraph group_backend["API and identity"]
  node_authroutes["Auth routes<br/>[auth.py]"]
  node_usersroutes["Profile routes<br/>[users.py]"]
  node_authlogic["Account logic<br/>[auth_controller.py]"]
  node_security["Token security<br/>[security.py]"]
  node_dependencies["Request dependencies<br/>[dependencies.py]"]
  node_app["API application<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_config["Settings<br/>[config.py]"]
end

subgraph group_storage["Persistence"]
  node_dbinit["Database initialization<br/>[db.py]"]
  node_mongodb[("MongoDB")]
  node_seed["Starter catalog<br/>[dishes.json]"]
end

node_diner(("Diner"))

node_diner -->|"opens"| node_home
node_home -->|"starts discovery"| node_scan
node_diner -->|"sets up profile"| node_login
node_scan -->|"selects dish"| node_dishdetail
node_dishdetail -->|"shows phrase"| node_waiter
node_dishdetail -->|"previews pronunciation"| node_speech
node_dishdetail -->|"presents sensory detail"| node_sensory
node_scan -.->|"uses demo catalog"| node_frontenddishes
node_scan -.->|"offers cuisine profiles"| node_cuisines
node_app -->|"registers"| node_dishroutes
node_app -->|"registers"| node_communityroutes
node_app -->|"registers"| node_passportroutes
node_app -->|"registers"| node_authroutes
node_app -->|"registers"| node_usersroutes
node_dishroutes -->|"calls"| node_dishapi
node_communityroutes -->|"calls"| node_communitylogic
node_passportroutes -->|"calls"| node_passportlogic
node_authroutes -->|"calls"| node_authlogic
node_usersroutes -->|"calls"| node_authlogic
node_authlogic -->|"uses"| node_security
node_authroutes -->|"resolves identity and database"| node_dependencies
node_communityroutes -->|"resolves identity and database"| node_dependencies
node_dishroutes -->|"resolves database"| node_dependencies
node_passportroutes -->|"resolves identity and database"| node_dependencies
node_usersroutes -->|"resolves identity and database"| node_dependencies
node_dependencies -->|"decodes token"| node_security
node_dependencies -->|"gets database"| node_dbinit
node_app -->|"initializes and closes"| node_dbinit
node_dbinit -->|"seeds and indexes"| node_mongodb
node_dbinit -->|"loads when empty"| node_seed
node_dbinit -->|"reads settings"| node_config
node_security -->|"reads token settings"| node_config
node_authroutes -->|"validates payloads"| node_schemas
node_communityroutes -->|"validates payloads"| node_schemas
node_passportroutes -->|"validates payloads"| node_schemas
node_usersroutes -->|"validates payloads"| node_schemas
node_communitylogic -->|"looks up dishes"| node_dishapi

click node_home "https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/page.tsx"
click node_login "https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/login/page.tsx"
click node_scan "https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/scan/page.tsx"
click node_dishdetail "https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/dish/%5Bid%5D/page.tsx"
click node_waiter "https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/waiter/%5Bid%5D/page.tsx"
click node_speech "https://github.com/kumardhananjaya/prebite/blob/main/frontend/components/speech-button.tsx"
click node_sensory "https://github.com/kumardhananjaya/prebite/blob/main/frontend/components/sensory-meter.tsx"
click node_cuisines "https://github.com/kumardhananjaya/prebite/blob/main/frontend/lib/cuisines.ts"
click node_frontenddishes "https://github.com/kumardhananjaya/prebite/blob/main/frontend/lib/dishes.ts"
click node_dishapi "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/dish_controller.py"
click node_dishroutes "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/dishes.py"
click node_communityroutes "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/community.py"
click node_communitylogic "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/community_controller.py"
click node_passportroutes "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/passport.py"
click node_passportlogic "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/passport_controller.py"
click node_authroutes "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/auth.py"
click node_usersroutes "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/users.py"
click node_authlogic "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/auth_controller.py"
click node_security "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/core/security.py"
click node_dependencies "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/dependencies.py"
click node_app "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/main.py"
click node_schemas "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/schemas.py"
click node_dbinit "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/db.py"
click node_seed "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/data/dishes.json"
click node_config "https://github.com/kumardhananjaya/prebite/blob/main/backend/app/core/config.py"

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_home,node_login,node_scan,node_dishdetail,node_waiter,node_speech,node_sensory toneBlue
class node_cuisines,node_frontenddishes,node_dishapi,node_dishroutes toneAmber
class node_communityroutes,node_communitylogic,node_passportroutes,node_passportlogic toneMint
class node_authroutes,node_usersroutes,node_authlogic,node_security,node_dependencies,node_app,node_schemas,node_config toneRose
class node_dbinit,node_mongodb,node_seed,node_diner toneIndigo
```

## Components

### Diner experience

- [Home](https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Login](https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`
- [Menu discovery](https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/scan/page.tsx): `frontend/app/scan/page.tsx`
- [Dish details](https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/dish/%5Bid%5D/page.tsx): `frontend/app/dish/[id]/page.tsx`
- [Waiter phrase](https://github.com/kumardhananjaya/prebite/blob/main/frontend/app/waiter/%5Bid%5D/page.tsx): `frontend/app/waiter/[id]/page.tsx`
- [Speech playback](https://github.com/kumardhananjaya/prebite/blob/main/frontend/components/speech-button.tsx): `frontend/components/speech-button.tsx`
- [Sensory meter](https://github.com/kumardhananjaya/prebite/blob/main/frontend/components/sensory-meter.tsx): `frontend/components/sensory-meter.tsx`

### Dish discovery

- [Cuisine profiles](https://github.com/kumardhananjaya/prebite/blob/main/frontend/lib/cuisines.ts): `frontend/lib/cuisines.ts`
- [Demo dishes](https://github.com/kumardhananjaya/prebite/blob/main/frontend/lib/dishes.ts): `frontend/lib/dishes.ts`
- [Dish catalog API](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/dish_controller.py): `backend/app/controllers/dish_controller.py`
- [Dish routes](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/dishes.py): `backend/app/routes/dishes.py`

### Community and passport

- [Community routes](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/community.py): `backend/app/routes/community.py`
- [Community guides](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/community_controller.py): `backend/app/controllers/community_controller.py`
- [Passport routes](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/passport.py): `backend/app/routes/passport.py`
- [Passport stamps](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/passport_controller.py): `backend/app/controllers/passport_controller.py`

### API and identity

- [Auth routes](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Profile routes](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/routes/users.py): `backend/app/routes/users.py`
- [Account logic](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/controllers/auth_controller.py): `backend/app/controllers/auth_controller.py`
- [Token security](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [Request dependencies](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/dependencies.py): `backend/app/dependencies.py`
- [API application](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/main.py): `backend/app/main.py`
- [Request schemas](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Settings](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Persistence

- [Database initialization](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/db.py): `backend/app/db.py`
- **MongoDB**
- [Starter catalog](https://github.com/kumardhananjaya/prebite/blob/main/backend/app/data/dishes.json): `backend/app/data/dishes.json`

### Other components

- **Diner**

## Connections

- Diner → Home: opens (evidence: `readme.md`)
- Home → Menu discovery: starts discovery (evidence: `readme.md`)
- Diner → Login: sets up profile (evidence: `readme.md`)
- Menu discovery → Dish details: selects dish (evidence: `readme.md`)
- Dish details → Waiter phrase: shows phrase (evidence: `readme.md`)
- Dish details → Speech playback: previews pronunciation (evidence: `readme.md`)
- Dish details → Sensory meter: presents sensory detail (evidence: `readme.md`)
- Menu discovery → Demo dishes: uses demo catalog
- Menu discovery → Cuisine profiles: offers cuisine profiles
- API application → Dish routes: registers (evidence: `backend/app/main.py`)
- API application → Community routes: registers (evidence: `backend/app/main.py`)
- API application → Passport routes: registers (evidence: `backend/app/main.py`)
- API application → Auth routes: registers (evidence: `backend/app/main.py`)
- API application → Profile routes: registers (evidence: `backend/app/main.py`)
- Dish routes → Dish catalog API: calls (evidence: `backend/app/routes/dishes.py`)
- Community routes → Community guides: calls (evidence: `backend/app/routes/community.py`)
- Passport routes → Passport stamps: calls (evidence: `backend/app/routes/passport.py`)
- Auth routes → Account logic: calls (evidence: `backend/app/routes/auth.py`)
- Profile routes → Account logic: calls (evidence: `backend/app/routes/users.py`)
- Account logic → Token security: uses (evidence: `backend/app/controllers/auth_controller.py`)
- Auth routes → Request dependencies: resolves identity and database (evidence: `backend/app/routes/auth.py`)
- Community routes → Request dependencies: resolves identity and database (evidence: `backend/app/routes/community.py`)
- Dish routes → Request dependencies: resolves database (evidence: `backend/app/routes/dishes.py`)
- Passport routes → Request dependencies: resolves identity and database (evidence: `backend/app/routes/passport.py`)
- Profile routes → Request dependencies: resolves identity and database (evidence: `backend/app/routes/users.py`)
- Request dependencies → Token security: decodes token (evidence: `backend/app/dependencies.py`)
- Request dependencies → Database initialization: gets database (evidence: `backend/app/dependencies.py`)
- API application → Database initialization: initializes and closes (evidence: `backend/app/main.py`)
- Database initialization → MongoDB: seeds and indexes (evidence: `backend/app/db.py`)
- Database initialization → Starter catalog: loads when empty (evidence: `backend/app/db.py`)
- Database initialization → Settings: reads settings (evidence: `backend/app/db.py`)
- Token security → Settings: reads token settings (evidence: `backend/app/core/security.py`)
- Auth routes → Request schemas: validates payloads (evidence: `backend/app/routes/auth.py`)
- Community routes → Request schemas: validates payloads (evidence: `backend/app/routes/community.py`)
- Passport routes → Request schemas: validates payloads (evidence: `backend/app/routes/passport.py`)
- Profile routes → Request schemas: validates payloads (evidence: `backend/app/routes/users.py`)
- Community guides → Dish catalog API: looks up dishes (evidence: `backend/app/controllers/community_controller.py`)
