# hnam10/foundit architecture

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

- Interactive diagram: https://gitdiagram.com/hnam10/foundit
- Repository: https://github.com/hnam10/foundit

## Overview

Foundit is a campus lost-and-found platform. Students browse items and submit claims; security staff report and manage found items, review claims, and coordinate release. The graph covers the documented item, claim, matching, identity, notification, and photo-report flows. Connections use README statements or source-index references and excerpts; some routes and UI modules were not sampled, so their internal links are left out.

Main entry points: [`backend/src/routes/claims.ts`](https://github.com/hnam10/foundit/blob/main/backend/src/routes/claims.ts) (Claim workflow), [`backend/src/index.ts`](https://github.com/hnam10/foundit/blob/main/backend/src/index.ts) (API router), [`backend/src/routes/items.ts`](https://github.com/hnam10/foundit/blob/main/backend/src/routes/items.ts) (Item browsing), [`backend/src/lib/matching/ingest.ts`](https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/ingest.ts) (Embedding ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_web["Role-based pages"]
  node_api_client["API client<br/>[client.ts]"]
  node_auth_ui["Session utilities<br/>[auth.ts]"]
end

subgraph group_api["API and identity"]
  node_item_api["Item browsing<br/>[items.ts]"]
  node_claims_api["Claim workflow<br/>[claims.ts]"]
  node_auth_api["Account and login<br/>[auth.ts]"]
  node_photo_api["Photo sessions<br/>[photoSessions.ts]"]
  node_report_api["Report links<br/>[reportLinks.ts]"]
  node_api_entry["API router<br/>[index.ts]"]
end

subgraph group_recovery["Item recovery"]
  node_matching_ingest["Embedding ingestion<br/>[ingest.ts]"]
  node_embeddings["Text and image embeddings<br/>[embeddings.ts]"]
  node_suggestions["Match suggestions<br/>[suggestions.ts]"]
  node_search_text["Search text builders<br/>[searchText.ts]"]
end

subgraph group_services["Platform services"]
  node_db[("Application database<br/>[db.ts]")]
  node_notifications["In-app notifications<br/>[notifications.ts]"]
  node_email["Email delivery<br/>[email.ts]"]
  node_claim_email["Claim email notices"]
  node_object_store[("Image object storage<br/>[r2.ts]")]
end

node_student(("Student"))
node_security(("Security staff"))
node_embedding_service{{"OpenRouter"}}

node_student -->|"uses"| node_web
node_security -->|"uses"| node_web
node_web -.->|"requests through"| node_api_client
node_api_client -->|"reads tokens"| node_auth_ui
node_api_client -.->|"calls API"| node_api_entry
node_api_entry -->|"routes to"| node_auth_api
node_api_entry -->|"routes to"| node_claims_api
node_api_entry -->|"routes to"| node_report_api
node_api_entry -->|"routes to"| node_item_api
node_api_entry -->|"routes to"| node_photo_api
node_auth_api -->|"reads and writes"| node_db
node_auth_api -->|"sends verification"| node_email
node_item_api -->|"reads and writes"| node_db
node_claims_api -->|"reads and writes"| node_db
node_claims_api -->|"fans out notices"| node_notifications
node_claims_api -->|"delivers claim email"| node_claim_email
node_claims_api -->|"ingests embeddings"| node_matching_ingest
node_item_api -->|"ingests embeddings"| node_matching_ingest
node_claims_api -->|"requests suggestions"| node_suggestions
node_item_api -->|"requests suggestions"| node_suggestions
node_matching_ingest -->|"persists vectors"| node_db
node_matching_ingest -->|"computes vectors"| node_embeddings
node_matching_ingest -->|"builds search text"| node_search_text
node_embeddings -->|"requests embeddings"| node_embedding_service
node_photo_api -->|"stores session data"| node_db
node_photo_api -->|"creates upload URLs"| node_object_store
node_security -->|"reports found items"| node_item_api
node_student -->|"submits claims"| node_claims_api

click node_web "https://github.com/hnam10/foundit/tree/main/foundit-ui/app"
click node_api_client "https://github.com/hnam10/foundit/blob/main/foundit-ui/lib/api/client.ts"
click node_auth_ui "https://github.com/hnam10/foundit/blob/main/foundit-ui/utils/auth.ts"
click node_item_api "https://github.com/hnam10/foundit/blob/main/backend/src/routes/items.ts"
click node_claims_api "https://github.com/hnam10/foundit/blob/main/backend/src/routes/claims.ts"
click node_auth_api "https://github.com/hnam10/foundit/blob/main/backend/src/routes/auth.ts"
click node_photo_api "https://github.com/hnam10/foundit/blob/main/backend/src/routes/photoSessions.ts"
click node_report_api "https://github.com/hnam10/foundit/blob/main/backend/src/routes/reportLinks.ts"
click node_api_entry "https://github.com/hnam10/foundit/blob/main/backend/src/index.ts"
click node_db "https://github.com/hnam10/foundit/blob/main/backend/src/db.ts"
click node_matching_ingest "https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/ingest.ts"
click node_embeddings "https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/embeddings.ts"
click node_suggestions "https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/suggestions.ts"
click node_search_text "https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/searchText.ts"
click node_notifications "https://github.com/hnam10/foundit/blob/main/backend/src/lib/notifications.ts"
click node_email "https://github.com/hnam10/foundit/blob/main/backend/src/lib/email.ts"
click node_claim_email "https://github.com/hnam10/foundit/blob/main/backend/src/lib/claimEmailNotifications.ts"
click node_object_store "https://github.com/hnam10/foundit/blob/main/backend/src/lib/r2.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_web,node_api_client,node_auth_ui toneBlue
class node_item_api,node_claims_api,node_auth_api,node_photo_api,node_report_api,node_api_entry toneAmber
class node_matching_ingest,node_embeddings,node_suggestions,node_search_text,node_embedding_service toneMint
class node_db,node_notifications,node_email,node_claim_email,node_object_store toneRose
class node_student,node_security toneIndigo
```

## Components

### Web experience

- [Role-based pages](https://github.com/hnam10/foundit/tree/main/foundit-ui/app): `foundit-ui/app`
- [API client](https://github.com/hnam10/foundit/blob/main/foundit-ui/lib/api/client.ts): `foundit-ui/lib/api/client.ts`
- [Session utilities](https://github.com/hnam10/foundit/blob/main/foundit-ui/utils/auth.ts): `foundit-ui/utils/auth.ts`

### API and identity

- [Item browsing](https://github.com/hnam10/foundit/blob/main/backend/src/routes/items.ts): `backend/src/routes/items.ts`
- [Claim workflow](https://github.com/hnam10/foundit/blob/main/backend/src/routes/claims.ts): `backend/src/routes/claims.ts`
- [Account and login](https://github.com/hnam10/foundit/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Photo sessions](https://github.com/hnam10/foundit/blob/main/backend/src/routes/photoSessions.ts): `backend/src/routes/photoSessions.ts`
- [Report links](https://github.com/hnam10/foundit/blob/main/backend/src/routes/reportLinks.ts): `backend/src/routes/reportLinks.ts`
- [API router](https://github.com/hnam10/foundit/blob/main/backend/src/index.ts): `backend/src/index.ts`

### Item recovery

- [Embedding ingestion](https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/ingest.ts): `backend/src/lib/matching/ingest.ts`
- [Text and image embeddings](https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/embeddings.ts): `backend/src/lib/matching/embeddings.ts`
- [Match suggestions](https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/suggestions.ts): `backend/src/lib/matching/suggestions.ts`
- [Search text builders](https://github.com/hnam10/foundit/blob/main/backend/src/lib/matching/searchText.ts): `backend/src/lib/matching/searchText.ts`

### Platform services

- [Application database](https://github.com/hnam10/foundit/blob/main/backend/src/db.ts): `backend/src/db.ts`
- [In-app notifications](https://github.com/hnam10/foundit/blob/main/backend/src/lib/notifications.ts): `backend/src/lib/notifications.ts`
- [Email delivery](https://github.com/hnam10/foundit/blob/main/backend/src/lib/email.ts): `backend/src/lib/email.ts`
- [Claim email notices](https://github.com/hnam10/foundit/blob/main/backend/src/lib/claimEmailNotifications.ts): `backend/src/lib/claimEmailNotifications.ts`
- [Image object storage](https://github.com/hnam10/foundit/blob/main/backend/src/lib/r2.ts): `backend/src/lib/r2.ts`

### Other components

- **Student**
- **Security staff**
- **OpenRouter**

## Connections

- Student → Role-based pages: uses (evidence: `README.md`)
- Security staff → Role-based pages: uses (evidence: `README.md`)
- Role-based pages → API client: requests through
- API client → Session utilities: reads tokens (evidence: `foundit-ui/lib/api/client.ts`)
- API client → API router: calls API
- API router → Account and login: routes to (evidence: `backend/src/index.ts`)
- API router → Claim workflow: routes to (evidence: `backend/src/index.ts`)
- API router → Report links: routes to (evidence: `backend/src/index.ts`)
- API router → Item browsing: routes to (evidence: `backend/src/index.ts`)
- API router → Photo sessions: routes to (evidence: `backend/src/index.ts`)
- Account and login → Application database: reads and writes (evidence: `backend/src/routes/auth.ts`)
- Account and login → Email delivery: sends verification (evidence: `backend/src/routes/auth.ts`)
- Item browsing → Application database: reads and writes (evidence: `backend/src/routes/items.ts`)
- Claim workflow → Application database: reads and writes (evidence: `backend/src/routes/claims.ts`)
- Claim workflow → In-app notifications: fans out notices (evidence: `backend/src/routes/claims.ts`)
- Claim workflow → Claim email notices: delivers claim email (evidence: `backend/src/routes/claims.ts`)
- Claim workflow → Embedding ingestion: ingests embeddings (evidence: `backend/src/routes/claims.ts`)
- Item browsing → Embedding ingestion: ingests embeddings (evidence: `backend/src/routes/items.ts`)
- Claim workflow → Match suggestions: requests suggestions (evidence: `backend/src/routes/claims.ts`)
- Item browsing → Match suggestions: requests suggestions (evidence: `backend/src/routes/items.ts`)
- Embedding ingestion → Application database: persists vectors (evidence: `backend/src/lib/matching/ingest.ts`)
- Embedding ingestion → Text and image embeddings: computes vectors (evidence: `backend/src/lib/matching/ingest.ts`)
- Embedding ingestion → Search text builders: builds search text (evidence: `backend/src/lib/matching/ingest.ts`)
- Text and image embeddings → OpenRouter: requests embeddings (evidence: `backend/src/lib/matching/embeddings.ts`)
- Photo sessions → Application database: stores session data (evidence: `backend/src/routes/photoSessions.ts`)
- Photo sessions → Image object storage: creates upload URLs (evidence: `backend/src/routes/photoSessions.ts`)
- Security staff → Item browsing: reports found items (evidence: `README.md`)
- Student → Claim workflow: submits claims (evidence: `README.md`)
