# azideu/asingasing architecture

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

- Interactive diagram: https://gitdiagram.com/azideu/asingasing
- Repository: https://github.com/azideu/asingasing

## Overview

AsingAsing guides diners from receipt capture through correction, item assignment, proportional fee calculation, and a shareable or printable bill summary. Receipt photos are processed in the browser; a separate API route supports AI receipt parsing. The graph preserves the documented editing, fee, assignment, and rounding capabilities. Edges reflect the page wiring, sampled imports and calls, or README statements; unsampled implementation details are not inferred.

Main entry points: [`src/context/ReceiptContext.tsx`](https://github.com/azideu/asingasing/blob/main/src/context/ReceiptContext.tsx) (Receipt state), [`src/app/page.tsx`](https://github.com/azideu/asingasing/blob/main/src/app/page.tsx) (Workflow shell), [`src/lib/calculator.ts`](https://github.com/azideu/asingasing/blob/main/src/lib/calculator.ts) (Bill calculator), [`src/components/ocr/ReceiptCapture.tsx`](https://github.com/azideu/asingasing/blob/main/src/components/ocr/ReceiptCapture.tsx) (Receipt capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_page["Workflow shell<br/>[page.tsx]"]
  node_header["Header<br/>[Header.tsx]"]
  node_navigation["Step navigation<br/>[StepNavigation.tsx]"]
end

subgraph group_intake["Receipt intake"]
  node_capture["Receipt capture<br/>[ReceiptCapture.tsx]"]
  node_ocr["Image and text OCR<br/>[ocr.ts]"]
  node_ai_route["AI parse endpoint<br/>[route.ts]"]
end

subgraph group_workflow["Bill workflow"]
  node_editor["Receipt editor<br/>[ReceiptEditor.tsx]"]
  node_assign["Participant assignment"]
  node_context["Receipt state<br/>[ReceiptContext.tsx]"]
  node_storage[("Browser storage")]
end

subgraph group_calculation["Splitting and results"]
  node_calculator["Bill calculator<br/>[calculator.ts]"]
  node_summary["Bill summary<br/>[ReceiptSummary.tsx]"]
  node_lottery["Rounding lottery"]
end

subgraph group_domain["Domain and parsing"]
  node_receipt_types["Receipt types and fee presets<br/>[receipt.ts]"]
  node_validation["AI response validation<br/>[validation.ts]"]
  node_samples["Sample participants<br/>[sampleReceipts.ts]"]
end

node_diner(("Diner"))
node_gemini["Gemini Vision"]

node_diner -->|"uses"| node_page
node_page -->|"provides state"| node_context
node_page -->|"renders"| node_header
node_page -->|"renders"| node_navigation
node_page -->|"renders"| node_capture
node_page -->|"renders"| node_editor
node_page -->|"renders"| node_assign
node_page -->|"renders"| node_summary
node_capture -->|"parses text"| node_ocr
node_capture -->|"updates receipt"| node_context
node_capture -.->|"requests AI parsing"| node_ai_route
node_ai_route -->|"validates response"| node_validation
node_ai_route -->|"normalizes fees"| node_receipt_types
node_ai_route -.->|"requests analysis"| node_gemini
node_editor -->|"edits receipt"| node_context
node_editor -->|"checks totals"| node_calculator
node_editor -->|"parses pasted text"| node_ocr
node_assign -->|"edits assignments"| node_context
node_assign -->|"calculates breakdown"| node_calculator
node_context -->|"persists state"| node_storage
node_context -->|"calculates receipt"| node_calculator
node_context -->|"loads participants"| node_samples
node_context -->|"validates stored state"| node_validation
node_calculator -->|"uses models"| node_receipt_types
node_ocr -->|"normalizes fees"| node_receipt_types
node_summary -->|"reads calculation"| node_context
node_summary -->|"formats totals"| node_calculator
node_summary -->|"renders control"| node_lottery
node_lottery -->|"updates rounding choice"| node_context
node_lottery -->|"uses calculation"| node_calculator

click node_page "https://github.com/azideu/asingasing/blob/main/src/app/page.tsx"
click node_header "https://github.com/azideu/asingasing/blob/main/src/components/Header.tsx"
click node_navigation "https://github.com/azideu/asingasing/blob/main/src/components/StepNavigation.tsx"
click node_capture "https://github.com/azideu/asingasing/blob/main/src/components/ocr/ReceiptCapture.tsx"
click node_ocr "https://github.com/azideu/asingasing/blob/main/src/lib/ocr.ts"
click node_ai_route "https://github.com/azideu/asingasing/blob/main/src/app/api/parse-receipt/route.ts"
click node_editor "https://github.com/azideu/asingasing/blob/main/src/components/editor/ReceiptEditor.tsx"
click node_assign "https://github.com/azideu/asingasing/blob/main/src/components/assign/ParticipantMatrix.tsx"
click node_context "https://github.com/azideu/asingasing/blob/main/src/context/ReceiptContext.tsx"
click node_calculator "https://github.com/azideu/asingasing/blob/main/src/lib/calculator.ts"
click node_summary "https://github.com/azideu/asingasing/blob/main/src/components/summary/ReceiptSummary.tsx"
click node_lottery "https://github.com/azideu/asingasing/blob/main/src/components/summary/RoundingLottery.tsx"
click node_receipt_types "https://github.com/azideu/asingasing/blob/main/src/types/receipt.ts"
click node_validation "https://github.com/azideu/asingasing/blob/main/src/lib/validation.ts"
click node_samples "https://github.com/azideu/asingasing/blob/main/src/lib/sampleReceipts.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_page,node_header,node_navigation toneBlue
class node_capture,node_ocr,node_ai_route toneAmber
class node_editor,node_assign,node_context,node_storage toneMint
class node_calculator,node_summary,node_lottery toneRose
class node_receipt_types,node_validation,node_samples,node_diner,node_gemini toneIndigo
```

## Components

### App experience

- [Workflow shell](https://github.com/azideu/asingasing/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Header](https://github.com/azideu/asingasing/blob/main/src/components/Header.tsx): `src/components/Header.tsx`
- [Step navigation](https://github.com/azideu/asingasing/blob/main/src/components/StepNavigation.tsx): `src/components/StepNavigation.tsx`

### Receipt intake

- [Receipt capture](https://github.com/azideu/asingasing/blob/main/src/components/ocr/ReceiptCapture.tsx): `src/components/ocr/ReceiptCapture.tsx`
- [Image and text OCR](https://github.com/azideu/asingasing/blob/main/src/lib/ocr.ts): `src/lib/ocr.ts`
- [AI parse endpoint](https://github.com/azideu/asingasing/blob/main/src/app/api/parse-receipt/route.ts): `src/app/api/parse-receipt/route.ts`

### Bill workflow

- [Receipt editor](https://github.com/azideu/asingasing/blob/main/src/components/editor/ReceiptEditor.tsx): `src/components/editor/ReceiptEditor.tsx`
- [Participant assignment](https://github.com/azideu/asingasing/blob/main/src/components/assign/ParticipantMatrix.tsx): `src/components/assign/ParticipantMatrix.tsx`
- [Receipt state](https://github.com/azideu/asingasing/blob/main/src/context/ReceiptContext.tsx): `src/context/ReceiptContext.tsx`
- **Browser storage**

### Splitting and results

- [Bill calculator](https://github.com/azideu/asingasing/blob/main/src/lib/calculator.ts): `src/lib/calculator.ts`
- [Bill summary](https://github.com/azideu/asingasing/blob/main/src/components/summary/ReceiptSummary.tsx): `src/components/summary/ReceiptSummary.tsx`
- [Rounding lottery](https://github.com/azideu/asingasing/blob/main/src/components/summary/RoundingLottery.tsx): `src/components/summary/RoundingLottery.tsx`

### Domain and parsing

- [Receipt types and fee presets](https://github.com/azideu/asingasing/blob/main/src/types/receipt.ts): `src/types/receipt.ts`
- [AI response validation](https://github.com/azideu/asingasing/blob/main/src/lib/validation.ts): `src/lib/validation.ts`
- [Sample participants](https://github.com/azideu/asingasing/blob/main/src/lib/sampleReceipts.ts): `src/lib/sampleReceipts.ts`

### Other components

- **Diner**
- **Gemini Vision**

## Connections

- Diner → Workflow shell: uses (evidence: `README.md`)
- Workflow shell → Receipt state: provides state (evidence: `src/app/page.tsx`)
- Workflow shell → Header: renders (evidence: `src/app/page.tsx`)
- Workflow shell → Step navigation: renders (evidence: `src/app/page.tsx`)
- Workflow shell → Receipt capture: renders (evidence: `src/app/page.tsx`)
- Workflow shell → Receipt editor: renders (evidence: `src/app/page.tsx`)
- Workflow shell → Participant assignment: renders (evidence: `src/app/page.tsx`)
- Workflow shell → Bill summary: renders (evidence: `src/app/page.tsx`)
- Receipt capture → Image and text OCR: parses text (evidence: `src/components/ocr/ReceiptCapture.tsx`)
- Receipt capture → Receipt state: updates receipt (evidence: `src/context/ReceiptContext.tsx`)
- Receipt capture → AI parse endpoint: requests AI parsing
- AI parse endpoint → AI response validation: validates response (evidence: `src/app/api/parse-receipt/route.ts`)
- AI parse endpoint → Receipt types and fee presets: normalizes fees (evidence: `src/app/api/parse-receipt/route.ts`)
- AI parse endpoint → Gemini Vision: requests analysis
- Receipt editor → Receipt state: edits receipt (evidence: `src/components/editor/ReceiptEditor.tsx`)
- Receipt editor → Bill calculator: checks totals (evidence: `src/components/editor/ReceiptEditor.tsx`)
- Receipt editor → Image and text OCR: parses pasted text (evidence: `src/components/editor/ReceiptEditor.tsx`)
- Participant assignment → Receipt state: edits assignments (evidence: `src/components/assign/ParticipantMatrix.tsx`)
- Participant assignment → Bill calculator: calculates breakdown (evidence: `src/components/assign/ParticipantMatrix.tsx`)
- Receipt state → Browser storage: persists state (evidence: `src/context/ReceiptContext.tsx`)
- Receipt state → Bill calculator: calculates receipt (evidence: `src/context/ReceiptContext.tsx`)
- Receipt state → Sample participants: loads participants (evidence: `src/context/ReceiptContext.tsx`)
- Receipt state → AI response validation: validates stored state (evidence: `src/context/ReceiptContext.tsx`)
- Bill calculator → Receipt types and fee presets: uses models (evidence: `src/lib/calculator.ts`)
- Image and text OCR → Receipt types and fee presets: normalizes fees (evidence: `src/lib/ocr.ts`)
- Bill summary → Receipt state: reads calculation (evidence: `src/components/summary/ReceiptSummary.tsx`)
- Bill summary → Bill calculator: formats totals (evidence: `src/components/summary/ReceiptSummary.tsx`)
- Bill summary → Rounding lottery: renders control (evidence: `src/components/summary/ReceiptSummary.tsx`)
- Rounding lottery → Receipt state: updates rounding choice (evidence: `src/components/summary/RoundingLottery.tsx`)
- Rounding lottery → Bill calculator: uses calculation (evidence: `src/components/summary/RoundingLottery.tsx`)
