# nandalalshukla/photomatch architecture

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

- Interactive diagram: https://gitdiagram.com/nandalalshukla/photomatch
- Repository: https://github.com/nandalalshukla/photomatch

## Overview

PhotoMatch AI lets organizers create events and upload albums, then lets guests find their own event photos through a selfie sent to WhatsApp or Telegram. The organizer flow fingerprints and uploads photos, registers them with the API, and background workers index faces. The guest flow starts at an event QR page, proceeds through a bot selfie search, and returns a private gallery; protected events add a live-face check. The README documents the major flows and capabilities; some worker, gallery, and UI internals are unsampled, so their links rely on that documentation.

Main entry points: [`apps/api/src/app.ts`](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/app.ts) (HTTP application), [`apps/api/src/modules/events/events.service.ts`](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/events.service.ts) (Event operations), [`apps/api/src/modules/galleries/galleries.routes.ts`](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/galleries/galleries.routes.ts) (Gallery and liveness), [`apps/api/src/lib/db.ts`](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/db.ts) (PostgreSQL + pgvector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Web app routes<br/>[App.tsx]"]
  node_event_ui["Event workspace"]
  node_guest_ui["Guest entry<br/>[GuestEventPage.tsx]"]
  node_gallery_ui["Private gallery<br/>[GalleryPage.tsx]"]
  node_live_check["Live face check<br/>[LivenessCheck.tsx]"]
  node_web_api["Web API client<br/>[api.ts]"]
end

subgraph group_events["Event management"]
  node_api_app["HTTP application<br/>[app.ts]"]
  node_event_routes["Event endpoints<br/>[events.routes.ts]"]
  node_event_service["Event operations<br/>[events.service.ts]"]
  node_contribute["Contributor uploads"]
  node_public_routes["Public event info<br/>[public.routes.ts]"]
  node_cloudinary["Image storage<br/>[cloudinary.ts]"]
end

subgraph group_matching["Photo matching"]
  node_queue["Index job queue<br/>[queue.ts]"]
  node_worker["Photo index worker<br/>[worker.ts]"]
  node_search_job["Selfie search job<br/>[search-selfie.ts]"]
  node_ai_client["AI HTTP client<br/>[ai-client.ts]"]
  node_face_engine["Face engine<br/>[face_engine.py]"]
  node_ai_service["AI service API<br/>[main.py]"]
  node_face_store["Face matching store<br/>[face-store.ts]"]
  node_gallery_routes["Gallery and liveness"]
  node_database[("PostgreSQL + pgvector<br/>[db.ts]")]
end

subgraph group_messaging["Guest messaging"]
  node_webhooks["Bot webhooks<br/>[webhooks.routes.ts]"]
  node_bot_service["Shared bot flow<br/>[bot.service.ts]"]
  node_telegram["Telegram adapter<br/>[telegram.ts]"]
  node_whatsapp["WhatsApp adapter<br/>[whatsapp.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_auth_middleware["Auth middleware<br/>[auth.ts]"]
end

node_organizer(("Organizer"))
node_guest(("Guest"))
node_messaging_platforms(("Messaging platforms"))

node_organizer -->|"uses"| node_webapp
node_guest -->|"opens"| node_webapp
node_webapp -->|"routes to"| node_event_ui
node_webapp -->|"routes to"| node_guest_ui
node_webapp -->|"routes to"| node_gallery_ui
node_event_ui -->|"requests"| node_web_api
node_guest_ui -.->|"requests"| node_web_api
node_gallery_ui -.->|"requests"| node_web_api
node_gallery_ui -.->|"renders"| node_live_check
node_web_api -.->|"calls"| node_api_app
node_api_app -->|"mounts"| node_event_routes
node_api_app -->|"mounts"| node_public_routes
node_api_app -->|"mounts"| node_gallery_routes
node_api_app -->|"mounts"| node_webhooks
node_api_app -->|"mounts"| node_contribute
node_event_routes -->|"requires"| node_auth_middleware
node_event_routes -->|"calls"| node_event_service
node_contribute -->|"calls"| node_event_service
node_event_service -->|"enqueues indexing"| node_queue
node_event_service -->|"manages images"| node_cloudinary
node_event_service -->|"reads and writes"| node_database
node_organizer -->|"uploads photos"| node_cloudinary
node_event_service -->|"signs uploads"| node_cloudinary
node_worker -->|"consumes jobs"| node_queue
node_worker -->|"downloads images"| node_cloudinary
node_worker -->|"requests embeddings"| node_ai_client
node_worker -->|"stores faces"| node_face_store
node_ai_client -->|"sends images"| node_ai_service
node_ai_service -->|"uses"| node_face_engine
node_face_engine -.->|"returns embeddings"| node_database
node_messaging_platforms -->|"sends messages"| node_webhooks
node_webhooks -->|"parses Telegram"| node_telegram
node_webhooks -->|"parses WhatsApp"| node_whatsapp
node_webhooks -->|"dispatches messages"| node_bot_service
node_bot_service -->|"queues selfie search"| node_search_job
node_bot_service -->|"reads event state"| node_database
node_search_job -.->|"gets selfie embedding"| node_ai_client
node_search_job -.->|"matches faces"| node_face_store
node_search_job -.->|"records search"| node_database
node_bot_service -->|"shares gallery link"| node_gallery_routes
node_guest -->|"opens gallery"| node_gallery_routes
node_gallery_routes -->|"checks liveness"| node_ai_client
node_gallery_routes -->|"compares identity"| node_face_store
node_gallery_routes -->|"loads matches"| node_database
node_auth_middleware -->|"checks sessions"| node_auth
node_auth -->|"uses"| node_database

click node_webapp "https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/App.tsx"
click node_event_ui "https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/pages/EventDetailPage.tsx"
click node_guest_ui "https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/pages/GuestEventPage.tsx"
click node_gallery_ui "https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/pages/GalleryPage.tsx"
click node_live_check "https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/components/LivenessCheck.tsx"
click node_web_api "https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/lib/api.ts"
click node_api_app "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/app.ts"
click node_event_routes "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/events.routes.ts"
click node_event_service "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/events.service.ts"
click node_contribute "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/contribute.routes.ts"
click node_public_routes "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/public/public.routes.ts"
click node_cloudinary "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/cloudinary.ts"
click node_queue "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/queue.ts"
click node_worker "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/worker.ts"
click node_search_job "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/jobs/search-selfie.ts"
click node_ai_client "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/ai-client.ts"
click node_face_engine "https://github.com/nandalalshukla/photomatch/blob/main/apps/ai/app/face_engine.py"
click node_ai_service "https://github.com/nandalalshukla/photomatch/blob/main/apps/ai/app/main.py"
click node_face_store "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/face-store.ts"
click node_gallery_routes "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/galleries/galleries.routes.ts"
click node_database "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/db.ts"
click node_webhooks "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/webhooks.routes.ts"
click node_bot_service "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/bot.service.ts"
click node_telegram "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/telegram.ts"
click node_whatsapp "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/whatsapp.ts"
click node_auth "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/auth.ts"
click node_auth_middleware "https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/middleware/auth.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_webapp,node_event_ui,node_guest_ui,node_gallery_ui,node_live_check,node_web_api toneBlue
class node_api_app,node_event_routes,node_event_service,node_contribute,node_public_routes,node_cloudinary toneAmber
class node_queue,node_worker,node_search_job,node_ai_client,node_face_engine,node_ai_service,node_face_store,node_gallery_routes,node_database toneMint
class node_webhooks,node_bot_service,node_telegram,node_whatsapp toneRose
class node_auth,node_auth_middleware,node_organizer,node_guest,node_messaging_platforms toneIndigo
```

## Components

### Web experience

- [Web app routes](https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Event workspace](https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/pages/EventDetailPage.tsx): `apps/web/src/pages/EventDetailPage.tsx`
- [Guest entry](https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/pages/GuestEventPage.tsx): `apps/web/src/pages/GuestEventPage.tsx`
- [Private gallery](https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/pages/GalleryPage.tsx): `apps/web/src/pages/GalleryPage.tsx`
- [Live face check](https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/components/LivenessCheck.tsx): `apps/web/src/components/LivenessCheck.tsx`
- [Web API client](https://github.com/nandalalshukla/photomatch/blob/main/apps/web/src/lib/api.ts): `apps/web/src/lib/api.ts`

### Event management

- [HTTP application](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Event endpoints](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/events.routes.ts): `apps/api/src/modules/events/events.routes.ts`
- [Event operations](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/events.service.ts): `apps/api/src/modules/events/events.service.ts`
- [Contributor uploads](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/events/contribute.routes.ts): `apps/api/src/modules/events/contribute.routes.ts`
- [Public event info](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/public/public.routes.ts): `apps/api/src/modules/public/public.routes.ts`
- [Image storage](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/cloudinary.ts): `apps/api/src/lib/cloudinary.ts`

### Photo matching

- [Index job queue](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/queue.ts): `apps/api/src/lib/queue.ts`
- [Photo index worker](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/worker.ts): `apps/api/src/worker.ts`
- [Selfie search job](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/jobs/search-selfie.ts): `apps/api/src/jobs/search-selfie.ts`
- [AI HTTP client](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/ai-client.ts): `apps/api/src/lib/ai-client.ts`
- [Face engine](https://github.com/nandalalshukla/photomatch/blob/main/apps/ai/app/face_engine.py): `apps/ai/app/face_engine.py`
- [AI service API](https://github.com/nandalalshukla/photomatch/blob/main/apps/ai/app/main.py): `apps/ai/app/main.py`
- [Face matching store](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/face-store.ts): `apps/api/src/lib/face-store.ts`
- [Gallery and liveness](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/galleries/galleries.routes.ts): `apps/api/src/modules/galleries/galleries.routes.ts`
- [PostgreSQL + pgvector](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/db.ts): `apps/api/src/lib/db.ts`

### Guest messaging

- [Bot webhooks](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/webhooks.routes.ts): `apps/api/src/modules/bots/webhooks.routes.ts`
- [Shared bot flow](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/bot.service.ts): `apps/api/src/modules/bots/bot.service.ts`
- [Telegram adapter](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/telegram.ts): `apps/api/src/modules/bots/telegram.ts`
- [WhatsApp adapter](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/modules/bots/whatsapp.ts): `apps/api/src/modules/bots/whatsapp.ts`

### Identity and access

- [Authentication](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/lib/auth.ts): `apps/api/src/lib/auth.ts`
- [Auth middleware](https://github.com/nandalalshukla/photomatch/blob/main/apps/api/src/middleware/auth.ts): `apps/api/src/middleware/auth.ts`

### Other components

- **Organizer**
- **Guest**
- **Messaging platforms**

## Connections

- Organizer → Web app routes: uses (evidence: `apps/web/src/App.tsx`)
- Guest → Web app routes: opens (evidence: `apps/web/src/App.tsx`)
- Web app routes → Event workspace: routes to (evidence: `apps/web/src/App.tsx`)
- Web app routes → Guest entry: routes to (evidence: `apps/web/src/App.tsx`)
- Web app routes → Private gallery: routes to (evidence: `apps/web/src/App.tsx`)
- Event workspace → Web API client: requests (evidence: `apps/web/src/pages/EventDetailPage.tsx`)
- Guest entry → Web API client: requests
- Private gallery → Web API client: requests
- Private gallery → Live face check: renders
- Web API client → HTTP application: calls
- HTTP application → Event endpoints: mounts (evidence: `apps/api/src/app.ts`)
- HTTP application → Public event info: mounts (evidence: `apps/api/src/app.ts`)
- HTTP application → Gallery and liveness: mounts (evidence: `apps/api/src/app.ts`)
- HTTP application → Bot webhooks: mounts (evidence: `apps/api/src/app.ts`)
- HTTP application → Contributor uploads: mounts (evidence: `apps/api/src/app.ts`)
- Event endpoints → Auth middleware: requires (evidence: `apps/api/src/modules/events/events.routes.ts`)
- Event endpoints → Event operations: calls (evidence: `apps/api/src/modules/events/events.routes.ts`)
- Contributor uploads → Event operations: calls (evidence: `apps/api/src/modules/events/contribute.routes.ts`)
- Event operations → Index job queue: enqueues indexing (evidence: `apps/api/src/modules/events/events.service.ts`)
- Event operations → Image storage: manages images (evidence: `apps/api/src/modules/events/events.service.ts`)
- Event operations → PostgreSQL + pgvector: reads and writes (evidence: `apps/api/src/modules/events/events.service.ts`)
- Organizer → Image storage: uploads photos (evidence: `README.md`)
- Event operations → Image storage: signs uploads (evidence: `README.md`)
- Photo index worker → Index job queue: consumes jobs (evidence: `README.md`)
- Photo index worker → Image storage: downloads images (evidence: `README.md`)
- Photo index worker → AI HTTP client: requests embeddings (evidence: `README.md`)
- Photo index worker → Face matching store: stores faces (evidence: `README.md`)
- AI HTTP client → AI service API: sends images (evidence: `apps/api/src/lib/ai-client.ts`)
- AI service API → Face engine: uses (evidence: `apps/ai/app/main.py`)
- Face engine → PostgreSQL + pgvector: returns embeddings
- Messaging platforms → Bot webhooks: sends messages (evidence: `apps/api/src/modules/bots/webhooks.routes.ts`)
- Bot webhooks → Telegram adapter: parses Telegram (evidence: `apps/api/src/modules/bots/webhooks.routes.ts`)
- Bot webhooks → WhatsApp adapter: parses WhatsApp (evidence: `apps/api/src/modules/bots/webhooks.routes.ts`)
- Bot webhooks → Shared bot flow: dispatches messages (evidence: `apps/api/src/modules/bots/webhooks.routes.ts`)
- Shared bot flow → Selfie search job: queues selfie search (evidence: `apps/api/src/modules/bots/bot.service.ts`)
- Shared bot flow → PostgreSQL + pgvector: reads event state (evidence: `apps/api/src/modules/bots/bot.service.ts`)
- Selfie search job → AI HTTP client: gets selfie embedding
- Selfie search job → Face matching store: matches faces
- Selfie search job → PostgreSQL + pgvector: records search
- Shared bot flow → Gallery and liveness: shares gallery link (evidence: `README.md`)
- Guest → Gallery and liveness: opens gallery (evidence: `README.md`)
- Gallery and liveness → AI HTTP client: checks liveness (evidence: `apps/api/src/modules/galleries/galleries.routes.ts`)
- Gallery and liveness → Face matching store: compares identity (evidence: `apps/api/src/modules/galleries/galleries.routes.ts`)
- Gallery and liveness → PostgreSQL + pgvector: loads matches (evidence: `apps/api/src/modules/galleries/galleries.routes.ts`)
- Auth middleware → Authentication: checks sessions (evidence: `apps/api/src/middleware/auth.ts`)
- Authentication → PostgreSQL + pgvector: uses (evidence: `apps/api/src/lib/auth.ts`)
