# jerryhieu2102/lattice-web architecture

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

- Interactive diagram: https://gitdiagram.com/jerryhieu2102/lattice-web
- Repository: https://github.com/jerryhieu2102/lattice-web

## Overview

LATTICE is a local, sandbox-only financial orchestration app for international students. Users capture life events and document evidence, review verified finances, generate and activate a deterministic funding plan, stress-test it, evaluate conditional rescue options, then prepare and approve sandbox actions. The API coordinates these stages; PostgreSQL-backed state, resource permissions and an append-only audit chain provide shared internal controls. The graph preserves README capabilities, but some branches use directory-level paths because their implementations were not sampled; edges are limited to documented or indexed relationships.

Main entry points: [`apps/api/main.py`](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/main.py) (FastAPI routes), [`apps/api/planning.py`](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/planning.py) (Plan orchestration), [`apps/web/app/api/v1/[...path]/route.ts`](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/app/api/v1/%5B...path%5D/route.ts) (API proxy), [`apps/api/routes_plans.py`](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_plans.py) (Plan endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Workspace UI<br/>[page.tsx]"]
  node_webapi["API proxy<br/>[route.ts]"]
  node_lifeui["Life capture<br/>[capture.tsx]"]
  node_docui["Document review<br/>[documents.tsx]"]
  node_planui["Plan and scenarios<br/>[planning.tsx]"]
  node_graphui["Funding graph<br/>[graph.tsx]"]
end

subgraph group_api["API workflows"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_life["Life-event workflow<br/>[routes_life.py]"]
  node_documents["Document workflow"]
  node_data["Finance and access<br/>[routes_data.py]"]
  node_plans["Plan endpoints<br/>[routes_plans.py]"]
  node_actions["Action approvals<br/>[routes_actions.py]"]
  node_auth["Session authentication<br/>[auth.py]"]
end

subgraph group_domain["Verification and domain"]
  node_extract["Evidence extraction<br/>[service.py]"]
  node_mockllm["Deterministic interpreter<br/>[mock.py]"]
  node_provenance["Provenance validation<br/>[validation.py]"]
  node_lifeengine["Life-event ledger<br/>[service.py]"]
end

subgraph group_planning["Planning and repair"]
  node_solver["Constraint optimizer<br/>[solver.py]"]
  node_planner["Plan orchestration<br/>[planning.py]"]
  node_simulation["Stress simulation<br/>[engine.py]"]
  node_rescue["Rescue evaluation<br/>[planner.py]"]
  node_graphsvc["Allocation graph<br/>[service.py]"]
end

subgraph group_controls["State and controls"]
  node_state["Financial state<br/>[state.py]"]
  node_permissions["Resource permissions<br/>[service.py]"]
  node_policy["Action policy<br/>[engine.py]"]
  node_bank["Sandbox bank<br/>[provider.py]"]
  node_audit["Hash-chain audit<br/>[service.py]"]
  node_db[("Application database<br/>[db.py]")]
  node_models["Domain records<br/>[models.py]"]
end

node_user(("Demo user"))

node_user -->|"uses"| node_webapp
node_webapp -.->|"requests"| node_webapi
node_lifeui -.->|"submits events"| node_webapi
node_docui -.->|"submits evidence"| node_webapi
node_planui -.->|"requests plans"| node_webapi
node_graphui -.->|"requests graph"| node_webapi
node_webapi -.->|"proxies API"| node_api
node_api -->|"authenticates"| node_auth
node_api -.->|"routes life events"| node_life
node_api -.->|"routes documents"| node_documents
node_api -.->|"routes finance"| node_data
node_api -.->|"routes planning"| node_plans
node_api -.->|"routes actions"| node_actions
node_documents -->|"extracts facts"| node_extract
node_extract -->|"parses text"| node_mockllm
node_extract -->|"validates evidence"| node_provenance
node_life -->|"manages events"| node_lifeengine
node_lifeengine -->|"interprets intent"| node_mockllm
node_lifeengine -->|"requests replanning"| node_planner
node_lifeengine -.->|"records changes"| node_audit
node_data -->|"checks visibility"| node_permissions
node_plans -->|"generates plans"| node_planner
node_planner -->|"loads finances"| node_state
node_planner -->|"optimizes allocations"| node_solver
node_planner -->|"runs scenarios"| node_simulation
node_plans -->|"evaluates rescue"| node_rescue
node_plans -->|"builds graph"| node_graphsvc
node_actions -->|"checks authorization"| node_policy
node_actions -->|"executes sandbox action"| node_bank
node_actions -->|"checks plan freshness"| node_planner
node_actions -->|"records actions"| node_audit
node_state -->|"filters resources"| node_permissions
node_state -->|"reads records"| node_models
node_permissions -->|"queries permissions"| node_models
node_audit -->|"stores events"| node_models
node_models -->|"maps tables"| node_db
node_life -.->|"records lifecycle"| node_audit
node_plans -->|"records plans"| node_audit

click node_webapp "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/app/%5B%5B...slug%5D%5D/page.tsx"
click node_webapi "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/app/api/v1/%5B...path%5D/route.ts"
click node_lifeui "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/life/capture.tsx"
click node_docui "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/documents.tsx"
click node_planui "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/planning.tsx"
click node_graphui "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/graph.tsx"
click node_api "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/main.py"
click node_life "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_life.py"
click node_documents "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_documents.py"
click node_data "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_data.py"
click node_plans "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_plans.py"
click node_actions "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_actions.py"
click node_auth "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/auth.py"
click node_extract "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_ai/extraction/service.py"
click node_mockllm "https://github.com/jerryhieu2102/lattice-web/blob/main/connectors/llm/mock.py"
click node_provenance "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/provenance/validation.py"
click node_lifeengine "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/life/service.py"
click node_solver "https://github.com/jerryhieu2102/lattice-web/blob/main/optimizer/model/solver.py"
click node_planner "https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/planning.py"
click node_simulation "https://github.com/jerryhieu2102/lattice-web/blob/main/simulation/scenarios/engine.py"
click node_rescue "https://github.com/jerryhieu2102/lattice-web/blob/main/optimizer/rescue/planner.py"
click node_graphsvc "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/graph/service.py"
click node_state "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/state.py"
click node_permissions "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/permissions/service.py"
click node_policy "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/policy/engine.py"
click node_bank "https://github.com/jerryhieu2102/lattice-web/blob/main/connectors/sandbox_bank/provider.py"
click node_audit "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/audit/service.py"
click node_db "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/db.py"
click node_models "https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/models.py"

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_webapp,node_webapi,node_lifeui,node_docui,node_planui,node_graphui,node_user toneBlue
class node_api,node_life,node_documents,node_data,node_plans,node_actions,node_auth toneAmber
class node_extract,node_mockllm,node_provenance,node_lifeengine toneMint
class node_solver,node_planner,node_simulation,node_rescue,node_graphsvc toneRose
class node_state,node_permissions,node_policy,node_bank,node_audit,node_db,node_models toneIndigo
```

## Components

### Web experience

- [Workspace UI](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/app/%5B%5B...slug%5D%5D/page.tsx): `apps/web/app/[[...slug]]/page.tsx`
- [API proxy](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/app/api/v1/%5B...path%5D/route.ts): `apps/web/app/api/v1/[...path]/route.ts`
- [Life capture](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/life/capture.tsx): `apps/web/components/life/capture.tsx`
- [Document review](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/documents.tsx): `apps/web/components/documents.tsx`
- [Plan and scenarios](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/planning.tsx): `apps/web/components/planning.tsx`
- [Funding graph](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/web/components/graph.tsx): `apps/web/components/graph.tsx`

### API workflows

- [FastAPI routes](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/main.py): `apps/api/main.py`
- [Life-event workflow](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_life.py): `apps/api/routes_life.py`
- [Document workflow](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_documents.py): `apps/api/routes_documents.py`
- [Finance and access](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_data.py): `apps/api/routes_data.py`
- [Plan endpoints](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_plans.py): `apps/api/routes_plans.py`
- [Action approvals](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/routes_actions.py): `apps/api/routes_actions.py`
- [Session authentication](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/auth.py): `apps/api/auth.py`

### Verification and domain

- [Evidence extraction](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_ai/extraction/service.py): `lattice_ai/extraction/service.py`
- [Deterministic interpreter](https://github.com/jerryhieu2102/lattice-web/blob/main/connectors/llm/mock.py): `connectors/llm/mock.py`
- [Provenance validation](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/provenance/validation.py): `lattice_core/provenance/validation.py`
- [Life-event ledger](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/life/service.py): `lattice_core/life/service.py`

### Planning and repair

- [Constraint optimizer](https://github.com/jerryhieu2102/lattice-web/blob/main/optimizer/model/solver.py): `optimizer/model/solver.py`
- [Plan orchestration](https://github.com/jerryhieu2102/lattice-web/blob/main/apps/api/planning.py): `apps/api/planning.py`
- [Stress simulation](https://github.com/jerryhieu2102/lattice-web/blob/main/simulation/scenarios/engine.py): `simulation/scenarios/engine.py`
- [Rescue evaluation](https://github.com/jerryhieu2102/lattice-web/blob/main/optimizer/rescue/planner.py): `optimizer/rescue/planner.py`
- [Allocation graph](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/graph/service.py): `lattice_core/graph/service.py`

### State and controls

- [Financial state](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/state.py): `lattice_core/state.py`
- [Resource permissions](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/permissions/service.py): `lattice_core/permissions/service.py`
- [Action policy](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/policy/engine.py): `lattice_core/policy/engine.py`
- [Sandbox bank](https://github.com/jerryhieu2102/lattice-web/blob/main/connectors/sandbox_bank/provider.py): `connectors/sandbox_bank/provider.py`
- [Hash-chain audit](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/audit/service.py): `lattice_core/audit/service.py`
- [Application database](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/db.py): `lattice_core/db.py`
- [Domain records](https://github.com/jerryhieu2102/lattice-web/blob/main/lattice_core/models.py): `lattice_core/models.py`

### Other components

- **Demo user**

## Connections

- Demo user → Workspace UI: uses (evidence: `README.md`)
- Workspace UI → API proxy: requests
- Life capture → API proxy: submits events
- Document review → API proxy: submits evidence
- Plan and scenarios → API proxy: requests plans
- Funding graph → API proxy: requests graph
- API proxy → FastAPI routes: proxies API
- FastAPI routes → Session authentication: authenticates
- FastAPI routes → Life-event workflow: routes life events
- FastAPI routes → Document workflow: routes documents
- FastAPI routes → Finance and access: routes finance
- FastAPI routes → Plan endpoints: routes planning
- FastAPI routes → Action approvals: routes actions
- Document workflow → Evidence extraction: extracts facts (evidence: `apps/api/routes_documents.py`)
- Evidence extraction → Deterministic interpreter: parses text (evidence: `lattice_ai/extraction/service.py`)
- Evidence extraction → Provenance validation: validates evidence (evidence: `lattice_ai/extraction/service.py`)
- Life-event workflow → Life-event ledger: manages events (evidence: `apps/api/routes_life.py`)
- Life-event ledger → Deterministic interpreter: interprets intent (evidence: `lattice_core/life/service.py`)
- Life-event ledger → Plan orchestration: requests replanning (evidence: `lattice_core/life/service.py`)
- Life-event ledger → Hash-chain audit: records changes (evidence: `lattice_core/life/service.py`)
- Finance and access → Resource permissions: checks visibility (evidence: `apps/api/routes_data.py`)
- Plan endpoints → Plan orchestration: generates plans (evidence: `apps/api/planning.py`)
- Plan orchestration → Financial state: loads finances (evidence: `apps/api/planning.py`)
- Plan orchestration → Constraint optimizer: optimizes allocations (evidence: `apps/api/planning.py`)
- Plan orchestration → Stress simulation: runs scenarios (evidence: `apps/api/planning.py`)
- Plan endpoints → Rescue evaluation: evaluates rescue (evidence: `apps/api/routes_plans.py`)
- Plan endpoints → Allocation graph: builds graph (evidence: `apps/api/routes_plans.py`)
- Action approvals → Action policy: checks authorization (evidence: `apps/api/routes_actions.py`)
- Action approvals → Sandbox bank: executes sandbox action (evidence: `apps/api/routes_actions.py`)
- Action approvals → Plan orchestration: checks plan freshness (evidence: `apps/api/routes_actions.py`)
- Action approvals → Hash-chain audit: records actions (evidence: `apps/api/routes_actions.py`)
- Financial state → Resource permissions: filters resources (evidence: `lattice_core/state.py`)
- Financial state → Domain records: reads records (evidence: `lattice_core/state.py`)
- Resource permissions → Domain records: queries permissions (evidence: `lattice_core/permissions/service.py`)
- Hash-chain audit → Domain records: stores events (evidence: `lattice_core/audit/service.py`)
- Domain records → Application database: maps tables (evidence: `lattice_core/models.py`)
- Life-event workflow → Hash-chain audit: records lifecycle (evidence: `apps/api/routes_life.py`)
- Plan endpoints → Hash-chain audit: records plans (evidence: `apps/api/routes_plans.py`)
