# mda-ops/gaze architecture

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

- Interactive diagram: https://gitdiagram.com/mda-ops/gaze
- Repository: https://github.com/mda-ops/gaze

## Overview

GAZE is a revenue and performance analytics dashboard, represented here by its local Python application and the newer v2 web application. The user-facing workflow is to bring in revenue data, review data quality, choose reporting periods and filters, then inspect analytics and export reports. The product also covers commissions, creator and chatter performance, inactivity, targets, insights, and Looker-backed views. The graph combines documented capabilities with source-index and excerpt evidence; some v2 frontend-to-API links are shown as unverified because the relevant request code was not sampled.

Main entry points: [`app/web.py`](https://github.com/mda-ops/gaze/blob/main/app/web.py) (Python dashboard), [`v2/backend/src/routes/pages.routes.ts`](https://github.com/mda-ops/gaze/blob/main/v2/backend/src/routes/pages.routes.ts) (Page API routes), [`app/connectors.py`](https://github.com/mda-ops/gaze/blob/main/app/connectors.py) (Data connectors), [`v2/frontend/src/App.tsx`](https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and UI"]
  node_v1web["Python dashboard<br/>[web.py]"]
  node_v1js["Dashboard interactions<br/>[app.js]"]
  node_v2app["Web application<br/>[App.tsx]"]
  node_v2pages["Analytics page views"]
  node_query["Period and filters<br/>[pageQuery.ts]"]
  node_api["Frontend API client<br/>[client.ts]"]
end

subgraph group_ingestion["Data and Imports"]
  node_connectors["Data connectors<br/>[connectors.py]"]
  node_validation["Data quality checks<br/>[validation.py]"]
  node_schema["Import schema<br/>[schema.py]"]
end

subgraph group_analysis["Analytics"]
  node_analytics["Revenue analytics<br/>[analytics.py]"]
  node_financials["Commissions<br/>[financials.py]"]
  node_performance["Performance hub<br/>[performance_hub.py]"]
  node_tiers["Revenue tiers<br/>[revenue_tiers.py]"]
  node_insights["Insights and targets<br/>[insights.py]"]
  node_reports["Reports and exports<br/>[reports.py]"]
end

subgraph group_backend["Backend Services"]
  node_v2routes["Page API routes<br/>[pages.routes.ts]"]
  node_v2auth["Session and page access<br/>[auth.ts]"]
  node_settings["Settings routes<br/>[settings.routes.ts]"]
end

subgraph group_persistence["Storage and Sources"]
  node_sqlite[("Local analytics database<br/>[database.py]")]
  node_postgres[("Postgres data access<br/>[postgres_source.py]")]
  node_external["Revenue data sources"]
end

node_user(("Dashboard user"))

node_user -->|"uses"| node_v1web
node_v1web -.->|"serves interface"| node_v1js
node_user -.->|"uses"| node_v2app
node_v2app -->|"renders pages"| node_v2pages
node_v2pages -->|"uses filters"| node_query
node_v2pages -.->|"requests data"| node_api
node_v2app -.->|"checks session"| node_v2auth
node_user -->|"uploads data"| node_connectors
node_external -->|"imports sheet"| node_connectors
node_connectors -->|"validates rows"| node_validation
node_connectors -->|"uses schema"| node_schema
node_user -->|"reviews results"| node_analytics
node_v1web -->|"uses analytics"| node_analytics
node_v1web -->|"handles imports"| node_connectors
node_v1web -->|"uses finance logic"| node_financials
node_v1web -->|"uses performance hub"| node_performance
node_v1web -->|"uses tier logic"| node_tiers
node_v1web -->|"uses insights"| node_insights
node_v1web -->|"uses reports"| node_reports
node_v1web -->|"reads and writes"| node_sqlite
node_sqlite -->|"delegates queries"| node_postgres
node_external -.->|"provides revenue data"| node_postgres
node_v2app -.->|"fetches page data"| node_v2routes
node_v2routes -->|"dispatches hub"| node_performance
node_v2routes -->|"dispatches tiers"| node_tiers
node_v2routes -.->|"loads settings"| node_settings
node_v2routes -->|"requires page access"| node_v2auth

click node_v1web "https://github.com/mda-ops/gaze/blob/main/app/web.py"
click node_v1js "https://github.com/mda-ops/gaze/blob/main/app/static/app.js"
click node_v2app "https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/App.tsx"
click node_v2pages "https://github.com/mda-ops/gaze/tree/main/v2/frontend/src/pages"
click node_query "https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/lib/pageQuery.ts"
click node_api "https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/api/client.ts"
click node_connectors "https://github.com/mda-ops/gaze/blob/main/app/connectors.py"
click node_validation "https://github.com/mda-ops/gaze/blob/main/app/validation.py"
click node_schema "https://github.com/mda-ops/gaze/blob/main/app/schema.py"
click node_analytics "https://github.com/mda-ops/gaze/blob/main/app/analytics.py"
click node_financials "https://github.com/mda-ops/gaze/blob/main/app/financials.py"
click node_performance "https://github.com/mda-ops/gaze/blob/main/app/performance_hub.py"
click node_tiers "https://github.com/mda-ops/gaze/blob/main/app/revenue_tiers.py"
click node_insights "https://github.com/mda-ops/gaze/blob/main/app/insights.py"
click node_reports "https://github.com/mda-ops/gaze/blob/main/app/reports.py"
click node_v2routes "https://github.com/mda-ops/gaze/blob/main/v2/backend/src/routes/pages.routes.ts"
click node_v2auth "https://github.com/mda-ops/gaze/blob/main/v2/backend/src/plugins/auth.ts"
click node_settings "https://github.com/mda-ops/gaze/blob/main/v2/backend/src/routes/settings.routes.ts"
click node_sqlite "https://github.com/mda-ops/gaze/blob/main/app/database.py"
click node_postgres "https://github.com/mda-ops/gaze/blob/main/app/postgres_source.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_v1web,node_v1js,node_v2app,node_v2pages,node_query,node_api,node_user toneBlue
class node_connectors,node_validation,node_schema toneAmber
class node_analytics,node_financials,node_performance,node_tiers,node_insights,node_reports toneMint
class node_v2routes,node_v2auth,node_settings toneRose
class node_sqlite,node_postgres,node_external toneIndigo
```

## Components

### Access and UI

- [Python dashboard](https://github.com/mda-ops/gaze/blob/main/app/web.py): `app/web.py`
- [Dashboard interactions](https://github.com/mda-ops/gaze/blob/main/app/static/app.js): `app/static/app.js`
- [Web application](https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/App.tsx): `v2/frontend/src/App.tsx`
- [Analytics page views](https://github.com/mda-ops/gaze/tree/main/v2/frontend/src/pages): `v2/frontend/src/pages`
- [Period and filters](https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/lib/pageQuery.ts): `v2/frontend/src/lib/pageQuery.ts`
- [Frontend API client](https://github.com/mda-ops/gaze/blob/main/v2/frontend/src/api/client.ts): `v2/frontend/src/api/client.ts`

### Data and Imports

- [Data connectors](https://github.com/mda-ops/gaze/blob/main/app/connectors.py): `app/connectors.py`
- [Data quality checks](https://github.com/mda-ops/gaze/blob/main/app/validation.py): `app/validation.py`
- [Import schema](https://github.com/mda-ops/gaze/blob/main/app/schema.py): `app/schema.py`

### Analytics

- [Revenue analytics](https://github.com/mda-ops/gaze/blob/main/app/analytics.py): `app/analytics.py`
- [Commissions](https://github.com/mda-ops/gaze/blob/main/app/financials.py): `app/financials.py`
- [Performance hub](https://github.com/mda-ops/gaze/blob/main/app/performance_hub.py): `app/performance_hub.py`
- [Revenue tiers](https://github.com/mda-ops/gaze/blob/main/app/revenue_tiers.py): `app/revenue_tiers.py`
- [Insights and targets](https://github.com/mda-ops/gaze/blob/main/app/insights.py): `app/insights.py`
- [Reports and exports](https://github.com/mda-ops/gaze/blob/main/app/reports.py): `app/reports.py`

### Backend Services

- [Page API routes](https://github.com/mda-ops/gaze/blob/main/v2/backend/src/routes/pages.routes.ts): `v2/backend/src/routes/pages.routes.ts`
- [Session and page access](https://github.com/mda-ops/gaze/blob/main/v2/backend/src/plugins/auth.ts): `v2/backend/src/plugins/auth.ts`
- [Settings routes](https://github.com/mda-ops/gaze/blob/main/v2/backend/src/routes/settings.routes.ts): `v2/backend/src/routes/settings.routes.ts`

### Storage and Sources

- [Local analytics database](https://github.com/mda-ops/gaze/blob/main/app/database.py): `app/database.py`
- [Postgres data access](https://github.com/mda-ops/gaze/blob/main/app/postgres_source.py): `app/postgres_source.py`
- **Revenue data sources**

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Python dashboard: uses (evidence: `README.md`)
- Python dashboard → Dashboard interactions: serves interface
- Dashboard user → Web application: uses
- Web application → Analytics page views: renders pages (evidence: `v2/frontend/src/App.tsx`)
- Analytics page views → Period and filters: uses filters (evidence: `v2/frontend/src/pages/PerformanceHub2Page.tsx`)
- Analytics page views → Frontend API client: requests data (evidence: `v2/frontend/src/pages/LookerPages.tsx`)
- Web application → Session and page access: checks session
- Dashboard user → Data connectors: uploads data (evidence: `README.md`)
- Revenue data sources → Data connectors: imports sheet (evidence: `README.md`)
- Data connectors → Data quality checks: validates rows (evidence: `import_history_sample.py`)
- Data connectors → Import schema: uses schema (evidence: `app/connectors.py`)
- Dashboard user → Revenue analytics: reviews results (evidence: `README.md`)
- Python dashboard → Revenue analytics: uses analytics (evidence: `app/web.py`)
- Python dashboard → Data connectors: handles imports (evidence: `app/web.py`)
- Python dashboard → Commissions: uses finance logic (evidence: `app/web.py`)
- Python dashboard → Performance hub: uses performance hub (evidence: `app/web.py`)
- Python dashboard → Revenue tiers: uses tier logic (evidence: `app/web.py`)
- Python dashboard → Insights and targets: uses insights (evidence: `app/web.py`)
- Python dashboard → Reports and exports: uses reports (evidence: `app/web.py`)
- Python dashboard → Local analytics database: reads and writes (evidence: `app/web.py`)
- Local analytics database → Postgres data access: delegates queries (evidence: `app/database.py`)
- Revenue data sources → Postgres data access: provides revenue data
- Web application → Page API routes: fetches page data
- Page API routes → Performance hub: dispatches hub (evidence: `v2/backend/src/routes/pages.routes.ts`)
- Page API routes → Revenue tiers: dispatches tiers (evidence: `v2/backend/src/routes/pages.routes.ts`)
- Page API routes → Settings routes: loads settings
- Page API routes → Session and page access: requires page access (evidence: `v2/backend/src/routes/pages.routes.ts`)
