# academic-and-personal-projects/tontine-pilot architecture

> Architecture diagram of the GitHub repository academic-and-personal-projects/tontine-pilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/academic-and-personal-projects/tontine-pilot
- Repository: https://github.com/academic-and-personal-projects/tontine-pilot

## Overview

TontinePilot is a bilingual web app for managing community rotating-savings groups. Members sign in, work with group and cycle data, declare contributions by text or receipt, and use alerts, recommendations, audio summaries, assistant actions, and ledger export to manage the tontine. The README documents AppSync dispatch to Lambda workflows and storage; sampled handlers confirm several data reads and external-service calls. Some UI-to-backend wiring and unsampled workflow internals are represented only where the README explicitly describes them.

Main entry points: [`amplify/data/resource.ts`](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/data/resource.ts) (AppSync data API), [`amplify/functions/parse-receipt/handler.ts`](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/parse-receipt/handler.ts) (Receipt OCR), [`amplify/functions/reminders-worker/handler.ts`](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/reminders-worker/handler.ts) (Scheduled reminders), [`lib/remote.ts`](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/lib/remote.ts) (Remote data adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_auth_ui["Sign-in UI<br/>[auth-card.tsx]"]
  node_workspace["Group workspace<br/>[page.tsx]"]
  node_declaration_ui["Declare payment<br/>[page.tsx]"]
  node_alerts_ui["Alerts and mediation<br/>[page.tsx]"]
  node_assistant_ui["Tonti assistant<br/>[assistant-chat.tsx]"]
  node_export_ui["Ledger export<br/>[page.tsx]"]
end

subgraph group_data["Identity and ledger"]
  node_auth_service["Cognito auth<br/>[resource.ts]"]
  node_remote["Remote data adapter<br/>[remote.ts]"]
  node_api["AppSync data API<br/>[resource.ts]"]
  node_ledger[("Group ledger<br/>[resource.ts]")]
  node_storage[("Receipt and audio storage<br/>[resource.ts]")]
end

subgraph group_workflows["Tontine workflows"]
  node_declaration["Declaration parsing<br/>[handler.ts]"]
  node_receipt["Receipt OCR<br/>[handler.ts]"]
  node_mediation["Empathic mediation<br/>[handler.ts]"]
  node_rotation["Rotation recommendation<br/>[handler.ts]"]
  node_digest["Audio digest<br/>[handler.ts]"]
  node_assistant["Assistant actions<br/>[handler.ts]"]
  node_reminders["Scheduled reminders<br/>[handler.ts]"]
  node_welcome["Group welcome notices<br/>[handler.ts]"]
end

subgraph group_messaging["Messaging and AI"]
  node_bedrock{{"Bedrock models"}}
  node_email_sms{{"SES and SNS"}}
end

subgraph group_media["Media services"]
  node_textract{{"Textract OCR"}}
  node_polly{{"Polly speech"}}
  node_scheduler["EventBridge Scheduler"]
end

node_member(("Group member"))

node_member -->|"signs in"| node_auth_ui
node_auth_ui -->|"authenticates"| node_auth_service
node_member -->|"manages group"| node_workspace
node_workspace -->|"requests data"| node_remote
node_declaration_ui -->|"submits payment"| node_remote
node_alerts_ui -->|"manages alerts"| node_remote
node_export_ui -->|"requests ledger"| node_remote
node_assistant_ui -->|"asks assistant"| node_api
node_remote -->|"queries and mutates"| node_api
node_api -->|"reads and writes"| node_ledger
node_api -->|"dispatches"| node_declaration
node_api -->|"dispatches"| node_receipt
node_api -->|"dispatches"| node_mediation
node_api -->|"dispatches"| node_rotation
node_api -->|"dispatches"| node_digest
node_api -->|"dispatches"| node_assistant
node_api -->|"dispatches"| node_reminders
node_api -->|"dispatches"| node_welcome
node_declaration -->|"reads group context"| node_ledger
node_declaration -.->|"extracts details"| node_bedrock
node_receipt -->|"reads group context"| node_ledger
node_receipt -->|"reads receipt"| node_storage
node_receipt -->|"extracts text"| node_textract
node_receipt -.->|"parses image"| node_bedrock
node_mediation -->|"reads alert context"| node_ledger
node_mediation -.->|"drafts proposal"| node_bedrock
node_rotation -->|"reads member history"| node_ledger
node_rotation -.->|"writes reasons"| node_bedrock
node_digest -->|"reads cycle data"| node_ledger
node_digest -.->|"synthesizes speech"| node_polly
node_digest -.->|"stores audio"| node_storage
node_assistant -->|"reads and updates"| node_ledger
node_assistant -->|"answers and routes tools"| node_bedrock
node_assistant -.->|"sends email"| node_email_sms
node_reminders -->|"reads and updates alerts"| node_ledger
node_reminders -.->|"drafts reminder"| node_bedrock
node_reminders -.->|"sends reminders"| node_email_sms
node_scheduler -.->|"triggers worker"| node_reminders
node_welcome -->|"reads group members"| node_ledger
node_welcome -.->|"sends welcome"| node_email_sms

click node_auth_ui "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/components/auth/auth-card.tsx"
click node_workspace "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/dashboard/page.tsx"
click node_declaration_ui "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/declare/page.tsx"
click node_alerts_ui "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/alerts/page.tsx"
click node_assistant_ui "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/components/app/assistant-chat.tsx"
click node_export_ui "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/export/page.tsx"
click node_auth_service "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/auth/resource.ts"
click node_remote "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/lib/remote.ts"
click node_api "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/data/resource.ts"
click node_ledger "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/data/resource.ts"
click node_storage "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/storage/resource.ts"
click node_declaration "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/parse-declaration/handler.ts"
click node_receipt "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/parse-receipt/handler.ts"
click node_mediation "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/mediate/handler.ts"
click node_rotation "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/recommend-rotation/handler.ts"
click node_digest "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/digest-audio/handler.ts"
click node_assistant "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/assistant/handler.ts"
click node_reminders "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/reminders-worker/handler.ts"
click node_welcome "https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/notify/handler.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_auth_ui,node_workspace,node_declaration_ui,node_alerts_ui,node_assistant_ui,node_export_ui toneBlue
class node_auth_service,node_remote,node_api,node_ledger,node_storage toneAmber
class node_declaration,node_receipt,node_mediation,node_rotation,node_digest,node_assistant,node_reminders,node_welcome toneMint
class node_bedrock,node_email_sms toneRose
class node_textract,node_polly,node_scheduler,node_member toneIndigo
```

## Components

### Web experience

- [Sign-in UI](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/components/auth/auth-card.tsx): `components/auth/auth-card.tsx`
- [Group workspace](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`
- [Declare payment](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/declare/page.tsx): `app/(app)/declare/page.tsx`
- [Alerts and mediation](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/alerts/page.tsx): `app/(app)/alerts/page.tsx`
- [Tonti assistant](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/components/app/assistant-chat.tsx): `components/app/assistant-chat.tsx`
- [Ledger export](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/app/(app)/export/page.tsx): `app/(app)/export/page.tsx`

### Identity and ledger

- [Cognito auth](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/auth/resource.ts): `amplify/auth/resource.ts`
- [Remote data adapter](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/lib/remote.ts): `lib/remote.ts`
- [AppSync data API](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/data/resource.ts): `amplify/data/resource.ts`
- [Group ledger](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/data/resource.ts): `amplify/data/resource.ts`
- [Receipt and audio storage](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/storage/resource.ts): `amplify/storage/resource.ts`

### Tontine workflows

- [Declaration parsing](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/parse-declaration/handler.ts): `amplify/functions/parse-declaration/handler.ts`
- [Receipt OCR](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/parse-receipt/handler.ts): `amplify/functions/parse-receipt/handler.ts`
- [Empathic mediation](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/mediate/handler.ts): `amplify/functions/mediate/handler.ts`
- [Rotation recommendation](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/recommend-rotation/handler.ts): `amplify/functions/recommend-rotation/handler.ts`
- [Audio digest](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/digest-audio/handler.ts): `amplify/functions/digest-audio/handler.ts`
- [Assistant actions](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/assistant/handler.ts): `amplify/functions/assistant/handler.ts`
- [Scheduled reminders](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/reminders-worker/handler.ts): `amplify/functions/reminders-worker/handler.ts`
- [Group welcome notices](https://github.com/academic-and-personal-projects/tontine-pilot/blob/main/amplify/functions/notify/handler.ts): `amplify/functions/notify/handler.ts`

### Messaging and AI

- **Bedrock models**
- **SES and SNS**

### Media services

- **Textract OCR**
- **Polly speech**
- **EventBridge Scheduler**

### Other components

- **Group member**

## Connections

- Group member → Sign-in UI: signs in
- Sign-in UI → Cognito auth: authenticates
- Group member → Group workspace: manages group
- Group workspace → Remote data adapter: requests data
- Declare payment → Remote data adapter: submits payment
- Alerts and mediation → Remote data adapter: manages alerts
- Ledger export → Remote data adapter: requests ledger
- Tonti assistant → AppSync data API: asks assistant
- Remote data adapter → AppSync data API: queries and mutates
- AppSync data API → Group ledger: reads and writes
- AppSync data API → Declaration parsing: dispatches
- AppSync data API → Receipt OCR: dispatches
- AppSync data API → Empathic mediation: dispatches
- AppSync data API → Rotation recommendation: dispatches
- AppSync data API → Audio digest: dispatches
- AppSync data API → Assistant actions: dispatches
- AppSync data API → Scheduled reminders: dispatches
- AppSync data API → Group welcome notices: dispatches
- Declaration parsing → Group ledger: reads group context
- Declaration parsing → Bedrock models: extracts details
- Receipt OCR → Group ledger: reads group context
- Receipt OCR → Receipt and audio storage: reads receipt
- Receipt OCR → Textract OCR: extracts text
- Receipt OCR → Bedrock models: parses image
- Empathic mediation → Group ledger: reads alert context
- Empathic mediation → Bedrock models: drafts proposal
- Rotation recommendation → Group ledger: reads member history
- Rotation recommendation → Bedrock models: writes reasons
- Audio digest → Group ledger: reads cycle data
- Audio digest → Polly speech: synthesizes speech
- Audio digest → Receipt and audio storage: stores audio
- Assistant actions → Group ledger: reads and updates
- Assistant actions → Bedrock models: answers and routes tools
- Assistant actions → SES and SNS: sends email
- Scheduled reminders → Group ledger: reads and updates alerts
- Scheduled reminders → Bedrock models: drafts reminder
- Scheduled reminders → SES and SNS: sends reminders
- EventBridge Scheduler → Scheduled reminders: triggers worker
- Group welcome notices → Group ledger: reads group members
- Group welcome notices → SES and SNS: sends welcome
