# lalaprog/unofficial-asinta architecture

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

- Interactive diagram: https://gitdiagram.com/lalaprog/unofficial-asinta
- Repository: https://github.com/lalaprog/unofficial-asinta

## Overview

BALE is a role-aware project billing and workforce ledger for Asinta Architects. Users sign in, then founders manage projects, clients, invoices, expenses, tools, advances and payroll; supervisors use assigned-site attendance. The shared data store reads and mutates Supabase records under RLS. Separate branches provide AI-assisted expense suggestions, receipt handling, and email/SMS communications with scheduled reminders. The README documents the database, role enforcement and major capabilities; sampled source confirms selected store, auth, reminder, and preview behavior. Many feature pages and integrations were not sampled, so their internal call paths are not inferred.

Main entry points: [`lib/data/store.tsx`](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/data/store.tsx) (Ledger store), [`app/expenses/page.tsx`](https://github.com/lalaprog/unofficial-asinta/blob/main/app/expenses/page.tsx) (Expense tracking), [`components/layout/AppShell.tsx`](https://github.com/lalaprog/unofficial-asinta/blob/main/components/layout/AppShell.tsx) (Workspace shell), [`app/api/cron/reminders/route.ts`](https://github.com/lalaprog/unofficial-asinta/blob/main/app/api/cron/reminders/route.ts) (Reminder dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace operations"]
  node_shell["Workspace shell<br/>[AppShell.tsx]"]
  node_projects["Projects and clients<br/>[page.tsx]"]
  node_invoices["Billing<br/>[page.tsx]"]
  node_expenses["Expense tracking<br/>[page.tsx]"]
  node_attendance["Field attendance<br/>[page.tsx]"]
  node_payroll["Payroll<br/>[page.tsx]"]
  node_advances["Worker advances<br/>[page.tsx]"]
  node_tools["Tool tracking<br/>[page.tsx]"]
end

subgraph group_identity["Identity and data"]
  node_login["Role-aware login<br/>[page.tsx]"]
  node_auth["Session context<br/>[authContext.tsx]"]
  node_middleware["Route guard<br/>[middleware.ts]"]
  node_ledger["Ledger store<br/>[store.tsx]"]
  node_supabase[("Supabase data")]
end

subgraph group_communications["Communications"]
  node_reminders["Reminder scheduler<br/>[scheduler.ts]"]
  node_cron["Reminder dispatch<br/>[route.ts]"]
  node_email["Email service<br/>[service.ts]"]
  node_sms["SMS delivery<br/>[deliver.ts]"]
  node_providers["Mail and SMS providers"]
end

subgraph group_assistance["AI assistance"]
  node_ai_routes["AI endpoints"]
  node_ai_logic["AI expense support"]
  node_groq["Groq service"]
  node_receipt[("Receipt storage<br/>[receipts.ts]")]
end

node_user(("BALE users"))

node_user -->|"signs in"| node_login
node_login -->|"establishes session"| node_auth
node_middleware -->|"validates role"| node_supabase
node_user -.->|"opens workspace"| node_shell
node_shell -->|"checks session"| node_auth
node_shell -.->|"loads records"| node_ledger
node_projects -.->|"manages records"| node_ledger
node_invoices -.->|"manages billing"| node_ledger
node_expenses -->|"manages expenses"| node_ledger
node_attendance -->|"records attendance"| node_ledger
node_payroll -->|"prepares payroll"| node_ledger
node_advances -.->|"manages advances"| node_ledger
node_tools -.->|"manages tools"| node_ledger
node_ledger -->|"reads and writes"| node_supabase
node_ai_routes -.->|"uses assistance"| node_ai_logic
node_ai_logic -->|"optionally extracts"| node_groq
node_expenses -.->|"requests suggestions"| node_ai_routes
node_expenses -->|"stores receipts"| node_receipt
node_cron -->|"runs scheduling"| node_reminders
node_cron -->|"dispatches reminders"| node_sms
node_email -.->|"sends email"| node_providers
node_sms -.->|"sends SMS"| node_providers
node_user -.->|"configures messaging"| node_email

click node_login "https://github.com/lalaprog/unofficial-asinta/blob/main/app/page.tsx"
click node_auth "https://github.com/lalaprog/unofficial-asinta/blob/main/lib/auth/authContext.tsx"
click node_middleware "https://github.com/lalaprog/unofficial-asinta/blob/main/middleware.ts"
click node_shell "https://github.com/lalaprog/unofficial-asinta/blob/main/components/layout/AppShell.tsx"
click node_ledger "https://github.com/lalaprog/unofficial-asinta/blob/main/lib/data/store.tsx"
click node_projects "https://github.com/lalaprog/unofficial-asinta/blob/main/app/projects/page.tsx"
click node_invoices "https://github.com/lalaprog/unofficial-asinta/blob/main/app/invoices/page.tsx"
click node_expenses "https://github.com/lalaprog/unofficial-asinta/blob/main/app/expenses/page.tsx"
click node_attendance "https://github.com/lalaprog/unofficial-asinta/blob/main/app/attendance/page.tsx"
click node_payroll "https://github.com/lalaprog/unofficial-asinta/blob/main/app/payroll/page.tsx"
click node_advances "https://github.com/lalaprog/unofficial-asinta/blob/main/app/advances/page.tsx"
click node_tools "https://github.com/lalaprog/unofficial-asinta/blob/main/app/tools/page.tsx"
click node_ai_routes "https://github.com/lalaprog/unofficial-asinta/tree/main/app/api/ai"
click node_ai_logic "https://github.com/lalaprog/unofficial-asinta/tree/main/lib/ai"
click node_receipt "https://github.com/lalaprog/unofficial-asinta/blob/main/lib/supabase/receipts.ts"
click node_reminders "https://github.com/lalaprog/unofficial-asinta/blob/main/lib/reminders/scheduler.ts"
click node_cron "https://github.com/lalaprog/unofficial-asinta/blob/main/app/api/cron/reminders/route.ts"
click node_email "https://github.com/lalaprog/unofficial-asinta/blob/main/lib/email/service.ts"
click node_sms "https://github.com/lalaprog/unofficial-asinta/blob/main/lib/sms/deliver.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_shell,node_projects,node_invoices,node_expenses,node_attendance,node_payroll,node_advances,node_tools,node_user toneBlue
class node_login,node_auth,node_middleware,node_ledger,node_supabase toneAmber
class node_reminders,node_cron,node_email,node_sms,node_providers toneMint
class node_ai_routes,node_ai_logic,node_groq,node_receipt toneRose
```

## Components

### Workspace operations

- [Workspace shell](https://github.com/lalaprog/unofficial-asinta/blob/main/components/layout/AppShell.tsx): `components/layout/AppShell.tsx`
- [Projects and clients](https://github.com/lalaprog/unofficial-asinta/blob/main/app/projects/page.tsx): `app/projects/page.tsx`
- [Billing](https://github.com/lalaprog/unofficial-asinta/blob/main/app/invoices/page.tsx): `app/invoices/page.tsx`
- [Expense tracking](https://github.com/lalaprog/unofficial-asinta/blob/main/app/expenses/page.tsx): `app/expenses/page.tsx`
- [Field attendance](https://github.com/lalaprog/unofficial-asinta/blob/main/app/attendance/page.tsx): `app/attendance/page.tsx`
- [Payroll](https://github.com/lalaprog/unofficial-asinta/blob/main/app/payroll/page.tsx): `app/payroll/page.tsx`
- [Worker advances](https://github.com/lalaprog/unofficial-asinta/blob/main/app/advances/page.tsx): `app/advances/page.tsx`
- [Tool tracking](https://github.com/lalaprog/unofficial-asinta/blob/main/app/tools/page.tsx): `app/tools/page.tsx`

### Identity and data

- [Role-aware login](https://github.com/lalaprog/unofficial-asinta/blob/main/app/page.tsx): `app/page.tsx`
- [Session context](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/auth/authContext.tsx): `lib/auth/authContext.tsx`
- [Route guard](https://github.com/lalaprog/unofficial-asinta/blob/main/middleware.ts): `middleware.ts`
- [Ledger store](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/data/store.tsx): `lib/data/store.tsx`
- **Supabase data**

### Communications

- [Reminder scheduler](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/reminders/scheduler.ts): `lib/reminders/scheduler.ts`
- [Reminder dispatch](https://github.com/lalaprog/unofficial-asinta/blob/main/app/api/cron/reminders/route.ts): `app/api/cron/reminders/route.ts`
- [Email service](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/email/service.ts): `lib/email/service.ts`
- [SMS delivery](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/sms/deliver.ts): `lib/sms/deliver.ts`
- **Mail and SMS providers**

### AI assistance

- [AI endpoints](https://github.com/lalaprog/unofficial-asinta/tree/main/app/api/ai): `app/api/ai`
- [AI expense support](https://github.com/lalaprog/unofficial-asinta/tree/main/lib/ai): `lib/ai`
- **Groq service**
- [Receipt storage](https://github.com/lalaprog/unofficial-asinta/blob/main/lib/supabase/receipts.ts): `lib/supabase/receipts.ts`

### Other components

- **BALE users**

## Connections

- BALE users → Role-aware login: signs in (evidence: `README.md`)
- Role-aware login → Session context: establishes session (evidence: `lib/auth/authContext.tsx`)
- Route guard → Supabase data: validates role (evidence: `README.md`)
- BALE users → Workspace shell: opens workspace
- Workspace shell → Session context: checks session (evidence: `components/layout/AppShell.tsx`)
- Workspace shell → Ledger store: loads records (evidence: `components/layout/AppShell.tsx`)
- Projects and clients → Ledger store: manages records
- Billing → Ledger store: manages billing (evidence: `app/invoices/page.tsx`)
- Expense tracking → Ledger store: manages expenses (evidence: `app/expenses/page.tsx`)
- Field attendance → Ledger store: records attendance (evidence: `app/attendance/page.tsx`)
- Payroll → Ledger store: prepares payroll (evidence: `app/payroll/page.tsx`)
- Worker advances → Ledger store: manages advances
- Tool tracking → Ledger store: manages tools
- Ledger store → Supabase data: reads and writes (evidence: `README.md`)
- AI endpoints → AI expense support: uses assistance
- AI expense support → Groq service: optionally extracts (evidence: `README.md`)
- Expense tracking → AI endpoints: requests suggestions
- Expense tracking → Receipt storage: stores receipts (evidence: `README.md`)
- Reminder dispatch → Reminder scheduler: runs scheduling (evidence: `app/api/cron/reminders/route.ts`)
- Reminder dispatch → SMS delivery: dispatches reminders (evidence: `app/api/cron/reminders/route.ts`)
- Email service → Mail and SMS providers: sends email
- SMS delivery → Mail and SMS providers: sends SMS
- BALE users → Email service: configures messaging
