# atharvakatre/pharmsight-launchlens architecture

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

- Interactive diagram: https://gitdiagram.com/atharvakatre/pharmsight-launchlens
- Repository: https://github.com/atharvakatre/pharmsight-launchlens

## Overview

LaunchLens is a drug-launch revenue forecasting app. Forecasters authenticate, edit or import year-by-year scenario assumptions, then review patient and revenue forecasts, compare scenarios, export results, and save immutable workspace snapshots; Brand Leads can review and comment on saved versions. The graph follows the documented UI-to-API-to-engine workflow and includes authentication, persistence, and version review. Several UI and API relationships are documented but their implementation files were not sampled, so those links are marked unverified rather than inferred from names.

Main entry points: [`backend/app/services/scenarios.py`](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/scenarios.py) (Scenario service), [`frontend/src/routes.tsx`](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/routes.tsx) (App routes), [`backend/app/main.py`](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/main.py) (FastAPI app), [`frontend/src/features/login/LoginPage.tsx`](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/login/LoginPage.tsx) (Login page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Forecast workspace"]
  node_login_ui["Login page<br/>[LoginPage.tsx]"]
  node_auth_state["Session state<br/>[AuthContext.tsx]"]
  node_routes["App routes<br/>[routes.tsx]"]
  node_scenario_editor["Scenario editor<br/>[ScenarioEditor.tsx]"]
  node_workspace["Workspace state"]
  node_dashboard["Forecast dashboard<br/>[DashboardPage.tsx]"]
  node_versions_ui["Version history<br/>[VersionsPage.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_scenario_api["Scenario API<br/>[scenarios.ts]"]
  node_version_api["Version API<br/>[versions.ts]"]
end

subgraph group_backend["API and access"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_auth_api["Authentication routes<br/>[auth.py]"]
  node_scenario_routes["Scenario routes<br/>[scenarios.py]"]
  node_version_routes["Version routes<br/>[versions.py]"]
  node_access["Token and role checks<br/>[deps.py]"]
  node_auth_service["Credential service<br/>[auth.py]"]
  node_scenario_service["Scenario service<br/>[scenarios.py]"]
end

subgraph group_forecast["Forecast domain"]
  node_forecast_engine["Forecast engine<br/>[engine.py]"]
  node_forecast_models["Forecast models<br/>[models.py]"]
end

subgraph group_persistence["Workspace history"]
  node_version_service["Snapshot service<br/>[versions.py]"]
  node_orm["Workspace records<br/>[db_models.py]"]
  node_database[("PostgreSQL<br/>[database.py]")]
end

node_forecaster(("Forecaster"))
node_brand_lead(("Brand Lead"))

node_forecaster -->|"signs in"| node_login_ui
node_brand_lead -->|"signs in"| node_login_ui
node_login_ui -->|"submits credentials"| node_auth_state
node_auth_state -->|"sets token"| node_api_client
node_routes -->|"routes to"| node_login_ui
node_routes -->|"routes to"| node_scenario_editor
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_versions_ui
node_scenario_editor -->|"edits scenarios"| node_scenario_api
node_workspace -->|"loads scenarios"| node_scenario_api
node_dashboard -->|"requests forecasts"| node_scenario_api
node_versions_ui -.->|"manages history"| node_version_api
node_scenario_api -->|"sends requests"| node_api_client
node_version_api -.->|"sends requests"| node_api_client
node_api_client -->|"calls API"| node_fastapi
node_fastapi -->|"registers routes"| node_auth_api
node_fastapi -->|"registers routes"| node_scenario_routes
node_fastapi -->|"registers routes"| node_version_routes
node_auth_api -->|"authenticates"| node_auth_service
node_auth_api -->|"uses dependencies"| node_access
node_auth_service -->|"reads users"| node_orm
node_scenario_routes -->|"checks permissions"| node_access
node_scenario_routes -->|"dispatches operations"| node_scenario_service
node_scenario_service -->|"calculates forecast"| node_forecast_engine
node_scenario_service -->|"builds inputs"| node_forecast_models
node_forecast_engine -->|"uses models"| node_forecast_models
node_scenario_service -->|"persists scenarios"| node_orm
node_version_routes -.->|"dispatches operations"| node_version_service
node_version_service -->|"loads workspace scenarios"| node_scenario_service
node_version_service -.->|"stores snapshots and comments"| node_orm
node_orm -->|"maps records"| node_database
node_forecaster -->|"edits and imports"| node_scenario_editor
node_dashboard -.->|"saves snapshot"| node_version_api
node_brand_lead -->|"reviews and comments"| node_versions_ui

click node_login_ui "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/login/LoginPage.tsx"
click node_auth_state "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/auth/AuthContext.tsx"
click node_routes "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/routes.tsx"
click node_scenario_editor "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/scenarios/ScenarioEditor.tsx"
click node_workspace "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/workspace/WorkspaceContext.tsx"
click node_dashboard "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/dashboard/DashboardPage.tsx"
click node_versions_ui "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/versions/VersionsPage.tsx"
click node_api_client "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/api/client.ts"
click node_scenario_api "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/api/scenarios.ts"
click node_version_api "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/api/versions.ts"
click node_fastapi "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/auth.py"
click node_scenario_routes "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/scenarios.py"
click node_version_routes "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/versions.py"
click node_access "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/deps.py"
click node_auth_service "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/auth.py"
click node_scenario_service "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/scenarios.py"
click node_forecast_engine "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/forecast/engine.py"
click node_forecast_models "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/forecast/models.py"
click node_version_service "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/versions.py"
click node_orm "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/db_models.py"
click node_database "https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/database.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_login_ui,node_auth_state,node_routes,node_scenario_editor,node_workspace,node_dashboard,node_versions_ui,node_api_client,node_scenario_api,node_version_api toneBlue
class node_fastapi,node_auth_api,node_scenario_routes,node_version_routes,node_access,node_auth_service,node_scenario_service toneAmber
class node_forecast_engine,node_forecast_models toneMint
class node_version_service,node_orm,node_database toneRose
class node_forecaster,node_brand_lead toneIndigo
```

## Components

### Forecast workspace

- [Login page](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/login/LoginPage.tsx): `frontend/src/features/login/LoginPage.tsx`
- [Session state](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/auth/AuthContext.tsx): `frontend/src/auth/AuthContext.tsx`
- [App routes](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/routes.tsx): `frontend/src/routes.tsx`
- [Scenario editor](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/scenarios/ScenarioEditor.tsx): `frontend/src/features/scenarios/ScenarioEditor.tsx`
- [Workspace state](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/workspace/WorkspaceContext.tsx): `frontend/src/workspace/WorkspaceContext.tsx`
- [Forecast dashboard](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/dashboard/DashboardPage.tsx): `frontend/src/features/dashboard/DashboardPage.tsx`
- [Version history](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/features/versions/VersionsPage.tsx): `frontend/src/features/versions/VersionsPage.tsx`
- [API client](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Scenario API](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/api/scenarios.ts): `frontend/src/api/scenarios.ts`
- [Version API](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/frontend/src/api/versions.ts): `frontend/src/api/versions.ts`

### API and access

- [FastAPI app](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Scenario routes](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/scenarios.py): `backend/app/api/scenarios.py`
- [Version routes](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/versions.py): `backend/app/api/versions.py`
- [Token and role checks](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/api/deps.py): `backend/app/api/deps.py`
- [Credential service](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/auth.py): `backend/app/services/auth.py`
- [Scenario service](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/scenarios.py): `backend/app/services/scenarios.py`

### Forecast domain

- [Forecast engine](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/forecast/engine.py): `backend/app/forecast/engine.py`
- [Forecast models](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/forecast/models.py): `backend/app/forecast/models.py`

### Workspace history

- [Snapshot service](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/services/versions.py): `backend/app/services/versions.py`
- [Workspace records](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/db_models.py): `backend/app/db_models.py`
- [PostgreSQL](https://github.com/atharvakatre/pharmsight-launchlens/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Forecaster**
- **Brand Lead**

## Connections

- Forecaster → Login page: signs in
- Brand Lead → Login page: signs in
- Login page → Session state: submits credentials (evidence: `frontend/src/features/login/LoginPage.tsx`)
- Session state → API client: sets token (evidence: `frontend/src/auth/AuthContext.tsx`)
- App routes → Login page: routes to (evidence: `frontend/src/routes.tsx`)
- App routes → Scenario editor: routes to (evidence: `frontend/src/routes.tsx`)
- App routes → Forecast dashboard: routes to (evidence: `frontend/src/routes.tsx`)
- App routes → Version history: routes to (evidence: `frontend/src/routes.tsx`)
- Scenario editor → Scenario API: edits scenarios (evidence: `frontend/src/features/scenarios/ScenarioEditor.tsx`)
- Workspace state → Scenario API: loads scenarios (evidence: `frontend/src/workspace/WorkspaceContext.tsx`)
- Forecast dashboard → Scenario API: requests forecasts (evidence: `frontend/src/features/dashboard/DashboardPage.tsx`)
- Version history → Version API: manages history
- Scenario API → API client: sends requests (evidence: `frontend/src/api/scenarios.ts`)
- Version API → API client: sends requests
- API client → FastAPI app: calls API
- FastAPI app → Authentication routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Scenario routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Version routes: registers routes (evidence: `backend/app/main.py`)
- Authentication routes → Credential service: authenticates (evidence: `backend/app/api/auth.py`)
- Authentication routes → Token and role checks: uses dependencies (evidence: `backend/app/api/auth.py`)
- Credential service → Workspace records: reads users (evidence: `backend/app/services/auth.py`)
- Scenario routes → Token and role checks: checks permissions (evidence: `backend/app/api/scenarios.py`)
- Scenario routes → Scenario service: dispatches operations (evidence: `backend/app/api/scenarios.py`)
- Scenario service → Forecast engine: calculates forecast (evidence: `backend/app/services/scenarios.py`)
- Scenario service → Forecast models: builds inputs (evidence: `backend/app/services/scenarios.py`)
- Forecast engine → Forecast models: uses models (evidence: `backend/app/forecast/engine.py`)
- Scenario service → Workspace records: persists scenarios (evidence: `backend/app/services/scenarios.py`)
- Version routes → Snapshot service: dispatches operations
- Snapshot service → Scenario service: loads workspace scenarios (evidence: `backend/app/services/versions.py`)
- Snapshot service → Workspace records: stores snapshots and comments (evidence: `backend/app/services/versions.py`)
- Workspace records → PostgreSQL: maps records (evidence: `backend/app/db_models.py`)
- Forecaster → Scenario editor: edits and imports
- Forecast dashboard → Version API: saves snapshot
- Brand Lead → Version history: reviews and comments
