# meghanasaivattikuti/tech-demo architecture

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

- Interactive diagram: https://gitdiagram.com/meghanasaivattikuti/tech-demo
- Repository: https://github.com/meghanasaivattikuti/tech-demo

## Overview

This is a Next.js demo for looking up fictional public disciplinary records and proposing reviewed sanction changes. The main workflow presents cached records and lets a user enter a natural-language search; the search endpoint uses an AI model to extract filters, applies a deterministic minor-safety rule, queries the database, and returns results with a call trace. Separately, users propose sanction updates, which pause for review before an approved change is written. The README documents Vercel AI Gateway and Workflows integrations; unsampled implementation details are shown only where documented.

Main entry points: [`lib/db.ts`](https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/db.ts) (Database access), [`app/page.tsx`](https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/page.tsx) (Home page), [`app/actions.ts`](https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/actions.ts) (Server actions), [`app/api/search/route.ts`](https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/api/search/route.ts) (Search endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lookup["Record lookup"]
  node_home["Home page<br/>[page.tsx]"]
  node_search_panel["Search panel<br/>[search-panel.tsx]"]
  node_records_table["Records table<br/>[records-table.tsx]"]
end

subgraph group_search["AI search"]
  node_search_api["Search endpoint<br/>[route.ts]"]
  node_search_rules["Filter and safety rules<br/>[pdd-search.ts]"]
  node_search_types["Search response types<br/>[search-types.ts]"]
end

subgraph group_review["Sanction review"]
  node_pending_reviews["Pending reviews"]
  node_simulate_update["Update picker"]
  node_simulate_form["Proposal form"]
  node_review_form["Review form"]
  node_session_state["Simulation state"]
  node_server_actions["Server actions<br/>[actions.ts]"]
  node_workflow["Approval workflow<br/>[sanction-update.ts]"]
end

subgraph group_data["Persistence"]
  node_database_access["Database access<br/>[db.ts]"]
  node_records_store[("Records and audit tables<br/>[schema.sql]")]
end

subgraph group_integrations["External services"]
  node_sql_server[("SQL Server")]
  node_ai_gateway{{"AI Gateway"}}
  node_workflow_service{{"Vercel Workflows"}}
end

node_visitor(("Database user"))

node_visitor -->|"opens"| node_home
node_home -->|"loads records"| node_database_access
node_home -->|"renders"| node_records_table
node_home -->|"renders"| node_search_panel
node_home -->|"renders"| node_simulate_update
node_home -->|"renders"| node_pending_reviews
node_search_panel -->|"posts query"| node_search_api
node_search_api -->|"resolves filters"| node_ai_gateway
node_search_api -->|"checks filters"| node_search_rules
node_search_api -->|"queries records"| node_database_access
node_search_api -->|"returns response"| node_search_types
node_search_panel -->|"renders results"| node_records_table
node_database_access -->|"builds predicates"| node_search_rules
node_database_access -->|"queries and writes"| node_sql_server
node_sql_server -.->|"stores records"| node_records_store
node_simulate_update -->|"loads choices"| node_database_access
node_simulate_update -->|"renders"| node_simulate_form
node_simulate_form -->|"proposes update"| node_server_actions
node_simulate_form -->|"tracks simulation"| node_session_state
node_pending_reviews -->|"loads pending entries"| node_server_actions
node_pending_reviews -->|"renders review"| node_review_form
node_pending_reviews -->|"tracks status"| node_session_state
node_review_form -->|"submits decision"| node_server_actions
node_server_actions -->|"reads and updates"| node_database_access
node_server_actions -->|"starts or resumes"| node_workflow
node_workflow -->|"coordinates update"| node_database_access
node_workflow -->|"runs durably"| node_workflow_service
node_server_actions -->|"writes on approval"| node_records_store

click node_home "https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/page.tsx"
click node_search_panel "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/search-panel.tsx"
click node_records_table "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/records-table.tsx"
click node_pending_reviews "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/pending-reviews.tsx"
click node_simulate_update "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/simulate-update.tsx"
click node_simulate_form "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/simulate-update-form.tsx"
click node_review_form "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/pending-review-form.tsx"
click node_session_state "https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/simulation-session.tsx"
click node_server_actions "https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/actions.ts"
click node_workflow "https://github.com/meghanasaivattikuti/tech-demo/blob/main/workflows/sanction-update.ts"
click node_search_api "https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/api/search/route.ts"
click node_search_rules "https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/pdd-search.ts"
click node_search_types "https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/search-types.ts"
click node_database_access "https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/db.ts"
click node_records_store "https://github.com/meghanasaivattikuti/tech-demo/blob/main/db/schema.sql"

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_search_panel,node_records_table toneBlue
class node_search_api,node_search_rules,node_search_types,node_visitor toneAmber
class node_pending_reviews,node_simulate_update,node_simulate_form,node_review_form,node_session_state,node_server_actions,node_workflow toneMint
class node_database_access,node_records_store toneRose
class node_sql_server,node_ai_gateway,node_workflow_service toneIndigo
```

## Components

### Record lookup

- [Home page](https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/page.tsx): `app/page.tsx`
- [Search panel](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/search-panel.tsx): `components/search-panel.tsx`
- [Records table](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/records-table.tsx): `components/records-table.tsx`

### AI search

- [Search endpoint](https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/api/search/route.ts): `app/api/search/route.ts`
- [Filter and safety rules](https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/pdd-search.ts): `lib/pdd-search.ts`
- [Search response types](https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/search-types.ts): `lib/search-types.ts`

### Sanction review

- [Pending reviews](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/pending-reviews.tsx): `components/pending-reviews.tsx`
- [Update picker](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/simulate-update.tsx): `components/simulate-update.tsx`
- [Proposal form](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/simulate-update-form.tsx): `components/simulate-update-form.tsx`
- [Review form](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/pending-review-form.tsx): `components/pending-review-form.tsx`
- [Simulation state](https://github.com/meghanasaivattikuti/tech-demo/blob/main/components/simulation-session.tsx): `components/simulation-session.tsx`
- [Server actions](https://github.com/meghanasaivattikuti/tech-demo/blob/main/app/actions.ts): `app/actions.ts`
- [Approval workflow](https://github.com/meghanasaivattikuti/tech-demo/blob/main/workflows/sanction-update.ts): `workflows/sanction-update.ts`

### Persistence

- [Database access](https://github.com/meghanasaivattikuti/tech-demo/blob/main/lib/db.ts): `lib/db.ts`
- [Records and audit tables](https://github.com/meghanasaivattikuti/tech-demo/blob/main/db/schema.sql): `db/schema.sql`

### External services

- **SQL Server**
- **AI Gateway**
- **Vercel Workflows**

### Other components

- **Database user**

## Connections

- Database user → Home page: opens (evidence: `README.md`)
- Home page → Database access: loads records (evidence: `app/page.tsx`)
- Home page → Records table: renders (evidence: `app/page.tsx`)
- Home page → Search panel: renders (evidence: `app/page.tsx`)
- Home page → Update picker: renders (evidence: `app/page.tsx`)
- Home page → Pending reviews: renders (evidence: `app/page.tsx`)
- Search panel → Search endpoint: posts query (evidence: `components/search-panel.tsx`)
- Search endpoint → AI Gateway: resolves filters (evidence: `README.md`)
- Search endpoint → Filter and safety rules: checks filters (evidence: `app/api/search/route.ts`)
- Search endpoint → Database access: queries records (evidence: `app/api/search/route.ts`)
- Search endpoint → Search response types: returns response (evidence: `app/api/search/route.ts`)
- Search panel → Records table: renders results (evidence: `components/search-panel.tsx`)
- Database access → Filter and safety rules: builds predicates (evidence: `lib/db.ts`)
- Database access → SQL Server: queries and writes (evidence: `README.md`)
- SQL Server → Records and audit tables: stores records
- Update picker → Database access: loads choices (evidence: `components/simulate-update.tsx`)
- Update picker → Proposal form: renders
- Proposal form → Server actions: proposes update (evidence: `components/simulate-update-form.tsx`)
- Proposal form → Simulation state: tracks simulation (evidence: `components/simulate-update-form.tsx`)
- Pending reviews → Server actions: loads pending entries (evidence: `components/pending-reviews.tsx`)
- Pending reviews → Review form: renders review (evidence: `components/pending-reviews.tsx`)
- Pending reviews → Simulation state: tracks status (evidence: `components/pending-reviews.tsx`)
- Review form → Server actions: submits decision (evidence: `components/pending-review-form.tsx`)
- Server actions → Database access: reads and updates (evidence: `app/actions.ts`)
- Server actions → Approval workflow: starts or resumes (evidence: `app/actions.ts`)
- Approval workflow → Database access: coordinates update (evidence: `workflows/sanction-update.ts`)
- Approval workflow → Vercel Workflows: runs durably (evidence: `README.md`)
- Server actions → Records and audit tables: writes on approval (evidence: `README.md`)
