# amruthreddyyamasani/prediction-lab architecture

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

- Interactive diagram: https://gitdiagram.com/amruthreddyyamasani/prediction-lab
- Repository: https://github.com/amruthreddyyamasani/prediction-lab

## Overview

Prediction Lab is an AI forecasting workspace: users create measurable questions, generate structured forecasts, track and revise them, resolve outcomes, and review calibration analytics. The React pages call a tRPC API; its procedures coordinate forecast generation and user-scoped persistence. The README documents Gemini, Supabase-backed records, and an interactive observatory. Detailed page and database implementations were not sampled, so the graph follows documented capabilities and supported module paths without inferring finer internal wiring.

Main entry points: [`client/src/lib/trpc.ts`](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/lib/trpc.ts) (tRPC client), [`client/src/App.tsx`](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/App.tsx) (React app), [`server/routers.ts`](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/routers.ts) (Procedures), [`client/src/pages/Home.tsx`](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Home.tsx) (Ask forecast)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Forecasting workspace"]
  node_app["React app<br/>[App.tsx]"]
  node_home["Ask forecast<br/>[Home.tsx]"]
  node_library["Forecast library<br/>[Library.tsx]"]
  node_detail["Prediction detail"]
  node_analytics["Calibration analytics<br/>[Analytics.tsx]"]
  node_categories["Categories<br/>[Categories.tsx]"]
  node_settings["Settings<br/>[Settings.tsx]"]
  node_observatory["Observatory"]
  node_transport["tRPC client<br/>[trpc.ts]"]
end

subgraph group_api["Application API"]
  node_endpoint["tRPC endpoint<br/>[&#91;...path&#93;.ts]"]
  node_router["Procedures<br/>[routers.ts]"]
end

subgraph group_domain["Forecast domain"]
  node_forecast["Forecast generation<br/>[forecast.ts]"]
  node_ledger["Prediction operations<br/>[db.ts]"]
  node_records[("Forecast records<br/>[db.ts]")]
end

subgraph group_integrations["External services"]
  node_gemini{{"Gemini API"}}
  node_supabase[("Supabase")]
  node_auth{{"Supabase Auth"}}
end

node_user(("Forecaster"))

node_user -->|"uses"| node_app
node_app -->|"routes"| node_home
node_app -->|"routes"| node_library
node_app -->|"routes"| node_detail
node_app -->|"routes"| node_analytics
node_app -->|"routes"| node_categories
node_app -->|"routes"| node_settings
node_home -->|"requests"| node_transport
node_library -->|"requests"| node_transport
node_detail -->|"requests"| node_transport
node_analytics -->|"requests"| node_transport
node_categories -->|"requests"| node_transport
node_settings -->|"requests"| node_transport
node_transport -->|"sends"| node_endpoint
node_endpoint -->|"dispatches"| node_router
node_router -->|"generates"| node_forecast
node_router -->|"operates"| node_ledger
node_forecast -->|"prompts"| node_gemini
node_ledger -->|"reads/writes"| node_records
node_router -->|"uses"| node_supabase
node_user -->|"explores"| node_observatory
node_transport -.->|"authenticates"| node_auth

click node_app "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/App.tsx"
click node_home "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Home.tsx"
click node_library "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Library.tsx"
click node_detail "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/PredictionDetail.tsx"
click node_analytics "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Analytics.tsx"
click node_categories "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Categories.tsx"
click node_settings "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Settings.tsx"
click node_observatory "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/components/ObservatoryField.tsx"
click node_transport "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/lib/trpc.ts"
click node_endpoint "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/api/trpc/%5B...path%5D.ts"
click node_router "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/routers.ts"
click node_forecast "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/forecast.ts"
click node_ledger "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/db.ts"
click node_records "https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/db.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_app,node_home,node_library,node_detail,node_analytics,node_categories,node_settings,node_observatory,node_transport toneBlue
class node_endpoint,node_router toneAmber
class node_forecast,node_ledger,node_records toneMint
class node_gemini,node_supabase,node_auth toneRose
class node_user toneIndigo
```

## Components

### Forecasting workspace

- [React app](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Ask forecast](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [Forecast library](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Library.tsx): `client/src/pages/Library.tsx`
- [Prediction detail](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/PredictionDetail.tsx): `client/src/pages/PredictionDetail.tsx`
- [Calibration analytics](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Analytics.tsx): `client/src/pages/Analytics.tsx`
- [Categories](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Categories.tsx): `client/src/pages/Categories.tsx`
- [Settings](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/pages/Settings.tsx): `client/src/pages/Settings.tsx`
- [Observatory](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/components/ObservatoryField.tsx): `client/src/components/ObservatoryField.tsx`
- [tRPC client](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/client/src/lib/trpc.ts): `client/src/lib/trpc.ts`

### Application API

- [tRPC endpoint](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/api/trpc/%5B...path%5D.ts): `api/trpc/[...path].ts`
- [Procedures](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/routers.ts): `server/routers.ts`

### Forecast domain

- [Forecast generation](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/forecast.ts): `server/forecast.ts`
- [Prediction operations](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/db.ts): `server/db.ts`
- [Forecast records](https://github.com/amruthreddyyamasani/prediction-lab/blob/main/server/db.ts): `server/db.ts`

### External services

- **Gemini API**
- **Supabase**
- **Supabase Auth**

### Other components

- **Forecaster**

## Connections

- Forecaster → React app: uses
- React app → Ask forecast: routes
- React app → Forecast library: routes
- React app → Prediction detail: routes
- React app → Calibration analytics: routes
- React app → Categories: routes
- React app → Settings: routes
- Ask forecast → tRPC client: requests
- Forecast library → tRPC client: requests
- Prediction detail → tRPC client: requests
- Calibration analytics → tRPC client: requests
- Categories → tRPC client: requests
- Settings → tRPC client: requests
- tRPC client → tRPC endpoint: sends
- tRPC endpoint → Procedures: dispatches
- Procedures → Forecast generation: generates
- Procedures → Prediction operations: operates
- Forecast generation → Gemini API: prompts
- Prediction operations → Forecast records: reads/writes
- Procedures → Supabase: uses
- Forecaster → Observatory: explores
- tRPC client → Supabase Auth: authenticates
