# reem927/anton-cx architecture

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

- Interactive diagram: https://gitdiagram.com/reem927/anton-cx
- Repository: https://github.com/reem927/anton-cx

## Overview

Anton Cx is a medical-benefit drug policy intelligence platform. Its core workflow is payer policy upload, URL retrieval, or automatic fetch; AI extraction and normalization; structured storage; then search, comparison, change tracking, and role-specific review. The graph preserves documented capabilities, but several page-to-API links are not evidenced by the excerpts or source index, so those connections are omitted rather than inferred.

Main entry points: [`app/api/ingest/route.ts`](https://github.com/reem927/anton-cx/blob/main/app/api/ingest/route.ts) (Ingest endpoint), [`lib/supabase-server.ts`](https://github.com/reem927/anton-cx/blob/main/lib/supabase-server.ts) (Server database client), [`lib/extraction.ts`](https://github.com/reem927/anton-cx/blob/main/lib/extraction.ts) (Policy extraction), [`lib/db/policies.ts`](https://github.com/reem927/anton-cx/blob/main/lib/db/policies.ts) (Policy query helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Policy Ingestion"]
  node_ingestion_page["Ingestion workspace<br/>[page.tsx]"]
  node_ingestion_controls["Ingestion controls"]
  node_ingest_api["Ingest endpoint<br/>[route.ts]"]
  node_policy_fetch["Policy retrieval<br/>[policy-fetch.ts]"]
  node_extraction["Policy extraction<br/>[extraction.ts]"]
  node_extraction_prompt["Extraction briefing"]
end

subgraph group_data["Policy Data"]
  node_policy_types["Policy schemas<br/>[policy.ts]"]
  node_policy_database[("Policy database")]
  node_policy_queries["Policy query helpers<br/>[policies.ts]"]
end

subgraph group_intelligence["Policy Intelligence"]
  node_search_endpoint["Policy search API<br/>[route.ts]"]
  node_vector_search["Semantic search<br/>[vector-search.ts]"]
  node_embeddings["Embedding pipeline<br/>[embeddings.ts]"]
  node_compare_endpoint["Coverage comparison<br/>[route.ts]"]
  node_compare_engine["Policy compare engine<br/>[route.ts]"]
  node_compare_summary["AI comparison summary<br/>[route.ts]"]
  node_change_page["Change tracking view<br/>[page.tsx]"]
  node_change_tracker["Change tracker<br/>[changeTracker.ts]"]
end

subgraph group_experience["User Experience"]
  node_policy_library["Policy library<br/>[page.tsx]"]
  node_library_views["Library views"]
  node_dashboard["Coverage dashboard<br/>[page.tsx]"]
  node_comparison_view["Comparison workspace<br/>[page.tsx]"]
  node_search_view["Search workspace<br/>[page.tsx]"]
  node_pdf_export["Policy PDF export<br/>[route.ts]"]
  node_pdf_generator["PDF generation"]
end

subgraph group_platform["Platform Services"]
  node_supabase_client["Server database client<br/>[supabase-server.ts]"]
  node_rate_limit["Rate limiting<br/>[rate-limit.ts]"]
end

node_user(("Policy analyst"))
node_anthropic{{"Anthropic API"}}
node_voyage{{"VoyageAI"}}
node_supabase[("Supabase")]

node_user -->|"submits policies"| node_ingestion_page
node_ingestion_page -.->|"offers input modes"| node_ingestion_controls
node_ingestion_controls -.->|"sends policy input"| node_ingest_api
node_ingest_api -->|"retrieves policy"| node_policy_fetch
node_ingest_api -->|"extracts policy"| node_extraction
node_ingest_api -->|"saves policies"| node_policy_queries
node_ingest_api -->|"creates client"| node_supabase_client
node_ingest_api -->|"checks limits"| node_rate_limit
node_extraction -->|"uses briefing"| node_extraction_prompt
node_extraction -->|"extracts with AI"| node_anthropic
node_extraction -->|"validates output"| node_policy_types
node_policy_queries -->|"uses policy types"| node_policy_types
node_supabase_client -->|"connects to"| node_supabase
node_policy_queries -.->|"reads and writes"| node_policy_database
node_search_view -.->|"requests results"| node_search_endpoint
node_search_endpoint -->|"creates client"| node_supabase_client
node_vector_search -.->|"uses vectors"| node_embeddings
node_embeddings -->|"generates embeddings"| node_voyage
node_embeddings -->|"stores vectors"| node_supabase
node_comparison_view -.->|"requests comparison"| node_compare_endpoint
node_compare_endpoint -->|"creates client"| node_supabase_client
node_compare_engine -->|"creates client"| node_supabase_client
node_comparison_view -.->|"requests summary"| node_compare_summary
node_compare_summary -->|"generates summary"| node_anthropic
node_change_page -->|"uses tracker"| node_change_tracker
node_policy_library -->|"renders views"| node_library_views
node_user -->|"reviews policies"| node_policy_library
node_user -->|"compares coverage"| node_comparison_view
node_user -->|"reviews changes"| node_change_page
node_user -->|"searches policies"| node_search_view
node_pdf_export -->|"creates client"| node_supabase_client
node_pdf_export -->|"generates document"| node_pdf_generator
node_user -->|"reviews coverage"| node_dashboard

click node_ingestion_page "https://github.com/reem927/anton-cx/blob/main/app/(app)/ingestion/page.tsx"
click node_ingestion_controls "https://github.com/reem927/anton-cx/tree/main/components/ingestion"
click node_ingest_api "https://github.com/reem927/anton-cx/blob/main/app/api/ingest/route.ts"
click node_policy_fetch "https://github.com/reem927/anton-cx/blob/main/lib/mcp/policy-fetch.ts"
click node_extraction "https://github.com/reem927/anton-cx/blob/main/lib/extraction.ts"
click node_extraction_prompt "https://github.com/reem927/anton-cx/blob/main/lib/prompts/extraction-briefing.ts"
click node_policy_types "https://github.com/reem927/anton-cx/blob/main/lib/types/policy.ts"
click node_policy_queries "https://github.com/reem927/anton-cx/blob/main/lib/db/policies.ts"
click node_search_endpoint "https://github.com/reem927/anton-cx/blob/main/app/api/search/route.ts"
click node_vector_search "https://github.com/reem927/anton-cx/blob/main/lib/vector-search.ts"
click node_embeddings "https://github.com/reem927/anton-cx/blob/main/lib/embeddings.ts"
click node_compare_endpoint "https://github.com/reem927/anton-cx/blob/main/app/api/compare/route.ts"
click node_compare_engine "https://github.com/reem927/anton-cx/blob/main/app/api/compare-engine/route.ts"
click node_compare_summary "https://github.com/reem927/anton-cx/blob/main/app/api/compare-summary/route.ts"
click node_change_page "https://github.com/reem927/anton-cx/blob/main/app/(app)/changes/page.tsx"
click node_change_tracker "https://github.com/reem927/anton-cx/blob/main/lib/changeTracker.ts"
click node_policy_library "https://github.com/reem927/anton-cx/blob/main/app/(app)/policy-lib/page.tsx"
click node_library_views "https://github.com/reem927/anton-cx/tree/main/components/library"
click node_dashboard "https://github.com/reem927/anton-cx/blob/main/app/(app)/dashboard/page.tsx"
click node_comparison_view "https://github.com/reem927/anton-cx/blob/main/app/(app)/compare/page.tsx"
click node_search_view "https://github.com/reem927/anton-cx/blob/main/app/(app)/search/page.tsx"
click node_pdf_export "https://github.com/reem927/anton-cx/blob/main/app/api/generate-pdf/route.ts"
click node_pdf_generator "https://github.com/reem927/anton-cx/blob/main/lib/pdf/generate-policy-pdf.ts"
click node_supabase_client "https://github.com/reem927/anton-cx/blob/main/lib/supabase-server.ts"
click node_rate_limit "https://github.com/reem927/anton-cx/blob/main/lib/rate-limit.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_ingestion_page,node_ingestion_controls,node_ingest_api,node_policy_fetch,node_extraction,node_extraction_prompt toneBlue
class node_policy_types,node_policy_database,node_policy_queries,node_supabase toneAmber
class node_search_endpoint,node_vector_search,node_embeddings,node_compare_endpoint,node_compare_engine,node_compare_summary,node_change_page,node_change_tracker,node_anthropic toneMint
class node_policy_library,node_library_views,node_dashboard,node_comparison_view,node_search_view,node_pdf_export,node_pdf_generator toneRose
class node_supabase_client,node_rate_limit,node_user,node_voyage toneIndigo
```

## Components

### Policy Ingestion

- [Ingestion workspace](https://github.com/reem927/anton-cx/blob/main/app/(app)/ingestion/page.tsx): `app/(app)/ingestion/page.tsx`
- [Ingestion controls](https://github.com/reem927/anton-cx/tree/main/components/ingestion): `components/ingestion`
- [Ingest endpoint](https://github.com/reem927/anton-cx/blob/main/app/api/ingest/route.ts): `app/api/ingest/route.ts`
- [Policy retrieval](https://github.com/reem927/anton-cx/blob/main/lib/mcp/policy-fetch.ts): `lib/mcp/policy-fetch.ts`
- [Policy extraction](https://github.com/reem927/anton-cx/blob/main/lib/extraction.ts): `lib/extraction.ts`
- [Extraction briefing](https://github.com/reem927/anton-cx/blob/main/lib/prompts/extraction-briefing.ts): `lib/prompts/extraction-briefing.ts`

### Policy Data

- [Policy schemas](https://github.com/reem927/anton-cx/blob/main/lib/types/policy.ts): `lib/types/policy.ts`
- **Policy database**
- [Policy query helpers](https://github.com/reem927/anton-cx/blob/main/lib/db/policies.ts): `lib/db/policies.ts`

### Policy Intelligence

- [Policy search API](https://github.com/reem927/anton-cx/blob/main/app/api/search/route.ts): `app/api/search/route.ts`
- [Semantic search](https://github.com/reem927/anton-cx/blob/main/lib/vector-search.ts): `lib/vector-search.ts`
- [Embedding pipeline](https://github.com/reem927/anton-cx/blob/main/lib/embeddings.ts): `lib/embeddings.ts`
- [Coverage comparison](https://github.com/reem927/anton-cx/blob/main/app/api/compare/route.ts): `app/api/compare/route.ts`
- [Policy compare engine](https://github.com/reem927/anton-cx/blob/main/app/api/compare-engine/route.ts): `app/api/compare-engine/route.ts`
- [AI comparison summary](https://github.com/reem927/anton-cx/blob/main/app/api/compare-summary/route.ts): `app/api/compare-summary/route.ts`
- [Change tracking view](https://github.com/reem927/anton-cx/blob/main/app/(app)/changes/page.tsx): `app/(app)/changes/page.tsx`
- [Change tracker](https://github.com/reem927/anton-cx/blob/main/lib/changeTracker.ts): `lib/changeTracker.ts`

### User Experience

- [Policy library](https://github.com/reem927/anton-cx/blob/main/app/(app)/policy-lib/page.tsx): `app/(app)/policy-lib/page.tsx`
- [Library views](https://github.com/reem927/anton-cx/tree/main/components/library): `components/library`
- [Coverage dashboard](https://github.com/reem927/anton-cx/blob/main/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`
- [Comparison workspace](https://github.com/reem927/anton-cx/blob/main/app/(app)/compare/page.tsx): `app/(app)/compare/page.tsx`
- [Search workspace](https://github.com/reem927/anton-cx/blob/main/app/(app)/search/page.tsx): `app/(app)/search/page.tsx`
- [Policy PDF export](https://github.com/reem927/anton-cx/blob/main/app/api/generate-pdf/route.ts): `app/api/generate-pdf/route.ts`
- [PDF generation](https://github.com/reem927/anton-cx/blob/main/lib/pdf/generate-policy-pdf.ts): `lib/pdf/generate-policy-pdf.ts`

### Platform Services

- [Server database client](https://github.com/reem927/anton-cx/blob/main/lib/supabase-server.ts): `lib/supabase-server.ts`
- [Rate limiting](https://github.com/reem927/anton-cx/blob/main/lib/rate-limit.ts): `lib/rate-limit.ts`

### Other components

- **Policy analyst**
- **Anthropic API**
- **VoyageAI**
- **Supabase**

## Connections

- Policy analyst → Ingestion workspace: submits policies (evidence: `README.md`)
- Ingestion workspace → Ingestion controls: offers input modes
- Ingestion controls → Ingest endpoint: sends policy input
- Ingest endpoint → Policy retrieval: retrieves policy (evidence: `app/api/ingest/route.ts`)
- Ingest endpoint → Policy extraction: extracts policy (evidence: `app/api/ingest/route.ts`)
- Ingest endpoint → Policy query helpers: saves policies (evidence: `app/api/ingest/route.ts`)
- Ingest endpoint → Server database client: creates client (evidence: `app/api/ingest/route.ts`)
- Ingest endpoint → Rate limiting: checks limits (evidence: `app/api/ingest/route.ts`)
- Policy extraction → Extraction briefing: uses briefing (evidence: `lib/extraction.ts`)
- Policy extraction → Anthropic API: extracts with AI (evidence: `README.md`)
- Policy extraction → Policy schemas: validates output (evidence: `lib/extraction.ts`)
- Policy query helpers → Policy schemas: uses policy types (evidence: `lib/db/policies.ts`)
- Server database client → Supabase: connects to (evidence: `lib/supabase-server.ts`)
- Policy query helpers → Policy database: reads and writes
- Search workspace → Policy search API: requests results
- Policy search API → Server database client: creates client (evidence: `app/api/search/route.ts`)
- Semantic search → Embedding pipeline: uses vectors
- Embedding pipeline → VoyageAI: generates embeddings (evidence: `lib/embeddings.ts`)
- Embedding pipeline → Supabase: stores vectors (evidence: `lib/embeddings.ts`)
- Comparison workspace → Coverage comparison: requests comparison
- Coverage comparison → Server database client: creates client (evidence: `app/api/compare/route.ts`)
- Policy compare engine → Server database client: creates client (evidence: `app/api/compare-engine/route.ts`)
- Comparison workspace → AI comparison summary: requests summary
- AI comparison summary → Anthropic API: generates summary (evidence: `app/api/compare-summary/route.ts`)
- Change tracking view → Change tracker: uses tracker (evidence: `app/(app)/changes/page.tsx`)
- Policy library → Library views: renders views (evidence: `app/(app)/policy-lib/page.tsx`)
- Policy analyst → Policy library: reviews policies (evidence: `README.md`)
- Policy analyst → Comparison workspace: compares coverage (evidence: `README.md`)
- Policy analyst → Change tracking view: reviews changes (evidence: `README.md`)
- Policy analyst → Search workspace: searches policies (evidence: `README.md`)
- Policy PDF export → Server database client: creates client (evidence: `app/api/generate-pdf/route.ts`)
- Policy PDF export → PDF generation: generates document (evidence: `app/api/generate-pdf/route.ts`)
- Policy analyst → Coverage dashboard: reviews coverage (evidence: `README.md`)
