# lucasgeg/event-order architecture

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

- Interactive diagram: https://gitdiagram.com/lucasgeg/event-order
- Repository: https://github.com/lucasgeg/event-order

## Overview

This is a French-language, multi-tenant ordering application: organizations manage a product catalog and customer orders, with PIN-protected administration. The main workflow is staff creating or editing an order from the catalog, then managing orders; the repository also includes organization signup, PIN recovery, and menu-generation capabilities. Edges reflect the shown calls and SOURCE INDEX references; several page-to-API links are not shown in the excerpts, so they are omitted.

Main entry points: [`lib/prisma.ts`](https://github.com/lucasgeg/event-order/blob/main/lib/prisma.ts) (PostgreSQL data), [`app/api/admin-session/route.ts`](https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/route.ts) (PIN session API), [`lib/adminSession.ts`](https://github.com/lucasgeg/event-order/blob/main/lib/adminSession.ts) (Session security), [`app/api/admin-session/forgot/route.ts`](https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/forgot/route.ts) (PIN recovery API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer_ordering["Order taking"]
  node_order_form["Order form<br/>[OrderForm.tsx]"]
  node_order_manager["Order manager<br/>[OrdersManager.tsx]"]
  node_app_context["App data context<br/>[AppContext.tsx]"]
end

subgraph group_admin_catalog["Administration"]
  node_admin_page["Admin workspace<br/>[page.tsx]"]
  node_catalog_api["Catalog API<br/>[route.ts]"]
  node_menu_generation["Menu generation<br/>[route.ts]"]
end

subgraph group_access_onboarding["Access and onboarding"]
  node_signup["Organization signup<br/>[route.ts]"]
  node_pin_session_api["PIN session API<br/>[route.ts]"]
  node_pin_recovery["PIN recovery API<br/>[route.ts]"]
  node_pin_reset["PIN reset API<br/>[route.ts]"]
  node_session_security["Session security<br/>[adminSession.ts]"]
  node_pin_security["PIN security<br/>[pin.ts]"]
  node_tenant_contact["Tenant contact lookup<br/>[tenantContact.ts]"]
  node_welcome_email["Welcome email<br/>[WelcomeEmail.tsx]"]
  node_pin_reset_email["PIN reset email<br/>[PinResetEmail.tsx]"]
  node_lockout_email["Lockout email"]
end

subgraph group_server_data["API and persistence"]
  node_orders_api["Orders API<br/>[route.ts]"]
  node_order_detail_api["Order detail API<br/>[route.ts]"]
  node_database[("PostgreSQL data<br/>[prisma.ts]")]
end

node_staff(("Organization staff"))
node_customer(("Customer"))

node_staff -->|"enters orders"| node_order_form
node_order_form -->|"uses data"| node_app_context
node_admin_page -->|"uses data"| node_app_context
node_admin_page -->|"renders"| node_order_manager
node_admin_page -->|"renders"| node_order_form
node_app_context -->|"fetches catalog"| node_catalog_api
node_app_context -->|"sends order requests"| node_orders_api
node_catalog_api -->|"checks admin session"| node_session_security
node_catalog_api -->|"reads and writes"| node_database
node_orders_api -->|"checks admin session"| node_session_security
node_orders_api -->|"reads and writes"| node_database
node_order_detail_api -->|"checks admin session"| node_session_security
node_order_detail_api -->|"reads and writes"| node_database
node_menu_generation -->|"uses persistence"| node_database
node_signup -->|"creates organization"| node_database
node_signup -->|"hashes PIN"| node_pin_security
node_signup -->|"uses template"| node_welcome_email
node_pin_session_api -->|"reads and updates"| node_database
node_pin_session_api -->|"verifies PIN"| node_pin_security
node_pin_session_api -->|"uses session helpers"| node_session_security
node_pin_session_api -->|"looks up admin"| node_tenant_contact
node_pin_session_api -->|"uses template"| node_lockout_email
node_pin_recovery -->|"reads recovery data"| node_database
node_pin_recovery -->|"uses reset tokens"| node_session_security
node_pin_recovery -->|"looks up admin"| node_tenant_contact
node_pin_recovery -->|"uses template"| node_pin_reset_email
node_pin_reset -->|"updates PIN"| node_database
node_pin_reset -->|"hashes PIN"| node_pin_security
node_pin_reset -->|"validates reset"| node_session_security

click node_order_form "https://github.com/lucasgeg/event-order/blob/main/app/components/OrderForm.tsx"
click node_order_manager "https://github.com/lucasgeg/event-order/blob/main/app/components/OrdersManager.tsx"
click node_app_context "https://github.com/lucasgeg/event-order/blob/main/app/context/AppContext.tsx"
click node_admin_page "https://github.com/lucasgeg/event-order/blob/main/app/(authenticated)/admin/page.tsx"
click node_catalog_api "https://github.com/lucasgeg/event-order/blob/main/app/api/catalog/route.ts"
click node_menu_generation "https://github.com/lucasgeg/event-order/blob/main/app/api/generate-menu/route.ts"
click node_signup "https://github.com/lucasgeg/event-order/blob/main/app/api/public/create-organization/route.ts"
click node_pin_session_api "https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/route.ts"
click node_pin_recovery "https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/forgot/route.ts"
click node_pin_reset "https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/reset/route.ts"
click node_session_security "https://github.com/lucasgeg/event-order/blob/main/lib/adminSession.ts"
click node_pin_security "https://github.com/lucasgeg/event-order/blob/main/lib/pin.ts"
click node_tenant_contact "https://github.com/lucasgeg/event-order/blob/main/lib/tenantContact.ts"
click node_welcome_email "https://github.com/lucasgeg/event-order/blob/main/emails/WelcomeEmail.tsx"
click node_pin_reset_email "https://github.com/lucasgeg/event-order/blob/main/emails/PinResetEmail.tsx"
click node_lockout_email "https://github.com/lucasgeg/event-order/blob/main/emails/PinLockoutEmail.tsx"
click node_orders_api "https://github.com/lucasgeg/event-order/blob/main/app/api/orders/route.ts"
click node_order_detail_api "https://github.com/lucasgeg/event-order/blob/main/app/api/orders/%5Bid%5D/route.ts"
click node_database "https://github.com/lucasgeg/event-order/blob/main/lib/prisma.ts"

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_order_form,node_order_manager,node_app_context toneBlue
class node_admin_page,node_catalog_api,node_menu_generation toneAmber
class node_signup,node_pin_session_api,node_pin_recovery,node_pin_reset,node_session_security,node_pin_security,node_tenant_contact,node_welcome_email,node_pin_reset_email,node_lockout_email toneMint
class node_orders_api,node_order_detail_api,node_database toneRose
class node_staff,node_customer toneIndigo
```

## Components

### Order taking

- [Order form](https://github.com/lucasgeg/event-order/blob/main/app/components/OrderForm.tsx): `app/components/OrderForm.tsx`
- [Order manager](https://github.com/lucasgeg/event-order/blob/main/app/components/OrdersManager.tsx): `app/components/OrdersManager.tsx`
- [App data context](https://github.com/lucasgeg/event-order/blob/main/app/context/AppContext.tsx): `app/context/AppContext.tsx`

### Administration

- [Admin workspace](https://github.com/lucasgeg/event-order/blob/main/app/(authenticated)/admin/page.tsx): `app/(authenticated)/admin/page.tsx`
- [Catalog API](https://github.com/lucasgeg/event-order/blob/main/app/api/catalog/route.ts): `app/api/catalog/route.ts`
- [Menu generation](https://github.com/lucasgeg/event-order/blob/main/app/api/generate-menu/route.ts): `app/api/generate-menu/route.ts`

### Access and onboarding

- [Organization signup](https://github.com/lucasgeg/event-order/blob/main/app/api/public/create-organization/route.ts): `app/api/public/create-organization/route.ts`
- [PIN session API](https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/route.ts): `app/api/admin-session/route.ts`
- [PIN recovery API](https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/forgot/route.ts): `app/api/admin-session/forgot/route.ts`
- [PIN reset API](https://github.com/lucasgeg/event-order/blob/main/app/api/admin-session/reset/route.ts): `app/api/admin-session/reset/route.ts`
- [Session security](https://github.com/lucasgeg/event-order/blob/main/lib/adminSession.ts): `lib/adminSession.ts`
- [PIN security](https://github.com/lucasgeg/event-order/blob/main/lib/pin.ts): `lib/pin.ts`
- [Tenant contact lookup](https://github.com/lucasgeg/event-order/blob/main/lib/tenantContact.ts): `lib/tenantContact.ts`
- [Welcome email](https://github.com/lucasgeg/event-order/blob/main/emails/WelcomeEmail.tsx): `emails/WelcomeEmail.tsx`
- [PIN reset email](https://github.com/lucasgeg/event-order/blob/main/emails/PinResetEmail.tsx): `emails/PinResetEmail.tsx`
- [Lockout email](https://github.com/lucasgeg/event-order/blob/main/emails/PinLockoutEmail.tsx): `emails/PinLockoutEmail.tsx`

### API and persistence

- [Orders API](https://github.com/lucasgeg/event-order/blob/main/app/api/orders/route.ts): `app/api/orders/route.ts`
- [Order detail API](https://github.com/lucasgeg/event-order/blob/main/app/api/orders/%5Bid%5D/route.ts): `app/api/orders/[id]/route.ts`
- [PostgreSQL data](https://github.com/lucasgeg/event-order/blob/main/lib/prisma.ts): `lib/prisma.ts`

### Other components

- **Organization staff**
- **Customer**

## Connections

- Organization staff → Order form: enters orders
- Order form → App data context: uses data (evidence: `app/components/OrderForm.tsx`)
- Admin workspace → App data context: uses data (evidence: `app/(authenticated)/admin/page.tsx`)
- Admin workspace → Order manager: renders (evidence: `app/(authenticated)/admin/page.tsx`)
- Admin workspace → Order form: renders (evidence: `app/(authenticated)/admin/page.tsx`)
- App data context → Catalog API: fetches catalog (evidence: `app/context/AppContext.tsx`)
- App data context → Orders API: sends order requests (evidence: `app/context/AppContext.tsx`)
- Catalog API → Session security: checks admin session (evidence: `app/api/catalog/route.ts`)
- Catalog API → PostgreSQL data: reads and writes (evidence: `app/api/catalog/route.ts`)
- Orders API → Session security: checks admin session (evidence: `app/api/orders/route.ts`)
- Orders API → PostgreSQL data: reads and writes (evidence: `app/api/orders/route.ts`)
- Order detail API → Session security: checks admin session (evidence: `app/api/orders/[id]/route.ts`)
- Order detail API → PostgreSQL data: reads and writes (evidence: `app/api/orders/[id]/route.ts`)
- Menu generation → PostgreSQL data: uses persistence (evidence: `app/api/generate-menu/route.ts`)
- Organization signup → PostgreSQL data: creates organization (evidence: `app/api/public/create-organization/route.ts`)
- Organization signup → PIN security: hashes PIN (evidence: `app/api/public/create-organization/route.ts`)
- Organization signup → Welcome email: uses template (evidence: `app/api/public/create-organization/route.ts`)
- PIN session API → PostgreSQL data: reads and updates (evidence: `app/api/admin-session/route.ts`)
- PIN session API → PIN security: verifies PIN (evidence: `app/api/admin-session/route.ts`)
- PIN session API → Session security: uses session helpers (evidence: `app/api/admin-session/route.ts`)
- PIN session API → Tenant contact lookup: looks up admin (evidence: `app/api/admin-session/route.ts`)
- PIN session API → Lockout email: uses template (evidence: `app/api/admin-session/route.ts`)
- PIN recovery API → PostgreSQL data: reads recovery data (evidence: `app/api/admin-session/forgot/route.ts`)
- PIN recovery API → Session security: uses reset tokens (evidence: `app/api/admin-session/forgot/route.ts`)
- PIN recovery API → Tenant contact lookup: looks up admin (evidence: `app/api/admin-session/forgot/route.ts`)
- PIN recovery API → PIN reset email: uses template (evidence: `app/api/admin-session/forgot/route.ts`)
- PIN reset API → PostgreSQL data: updates PIN (evidence: `app/api/admin-session/reset/route.ts`)
- PIN reset API → PIN security: hashes PIN (evidence: `app/api/admin-session/reset/route.ts`)
- PIN reset API → Session security: validates reset (evidence: `app/api/admin-session/reset/route.ts`)
