# sharanmankala/polyphony architecture

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

- Interactive diagram: https://gitdiagram.com/sharanmankala/polyphony
- Repository: https://github.com/sharanmankala/polyphony

## Overview

Polyphony’s implemented product is an authenticated creative workspace backed by a small FastAPI foundation: users create projects and sessions, upload image references, and request deterministic local image signals. The frontend calls the backend API; backend routes own validation, authorization, persistence and filesystem actions. The README also describes future intelligence and editing directions as design vision, not implemented runtime components. Relationships are limited to calls or data flows shown in excerpts or documented in the README; unsampled route details are not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py) (FastAPI routes), [`backend/app/db_models.py`](https://github.com/sharanmankala/polyphony/blob/main/backend/app/db_models.py) (Domain tables), [`frontend/src/app/page.tsx`](https://github.com/sharanmankala/polyphony/blob/main/frontend/src/app/page.tsx) (Creative workspace), [`backend/app/database.py`](https://github.com/sharanmankala/polyphony/blob/main/backend/app/database.py) (Database sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace"]
  node_web["Creative workspace<br/>[page.tsx]"]
end

subgraph group_api["API and domain"]
  node_api_routes["FastAPI routes<br/>[main.py]"]
  node_contracts["Request and response models<br/>[models.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_settings["App and upload settings<br/>[config.py]"]
  node_project_ops["Project operations<br/>[main.py]"]
  node_session_ops["Session operations<br/>[main.py]"]
  node_asset_ops["Image asset lifecycle<br/>[main.py]"]
end

subgraph group_persistence["Persistence"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_domain_tables["Domain tables<br/>[db_models.py]"]
  node_postgres[("PostgreSQL")]
  node_image_files[("Local image files")]
end

subgraph group_analysis["Image analysis"]
  node_analyzer["Pixel signal analyzer<br/>[image_analysis.py]"]
  node_analysis_records["Analysis records<br/>[db_models.py]"]
  node_future_vision["Vision-model gateway &#40;planned&#41;"]
end

node_user(("Creative user"))

node_user -->|"uses"| node_web
node_web -->|"requests API"| node_api_routes
node_api_routes -->|"validates and responds"| node_contracts
node_api_routes -->|"authenticates"| node_auth
node_api_routes -->|"routes project work"| node_project_ops
node_api_routes -->|"routes session work"| node_session_ops
node_api_routes -->|"routes asset work"| node_asset_ops
node_api_routes -->|"gets database session"| node_db_session
node_db_session -->|"opens sessions"| node_postgres
node_domain_tables -->|"uses base"| node_db_session
node_project_ops -->|"reads and writes"| node_domain_tables
node_session_ops -->|"reads and writes"| node_domain_tables
node_asset_ops -->|"reads and writes"| node_domain_tables
node_asset_ops -->|"checks upload limits"| node_settings
node_asset_ops -->|"stores and removes"| node_image_files
node_asset_ops -->|"analyzes image"| node_analyzer
node_asset_ops -->|"persists signals"| node_analysis_records
node_analyzer -->|"returns signals"| node_asset_ops
node_web -.->|"no current integration"| node_future_vision

click node_web "https://github.com/sharanmankala/polyphony/blob/main/frontend/src/app/page.tsx"
click node_api_routes "https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py"
click node_contracts "https://github.com/sharanmankala/polyphony/blob/main/backend/app/models.py"
click node_auth "https://github.com/sharanmankala/polyphony/blob/main/backend/app/auth.py"
click node_settings "https://github.com/sharanmankala/polyphony/blob/main/backend/app/config.py"
click node_project_ops "https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py"
click node_session_ops "https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py"
click node_asset_ops "https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py"
click node_db_session "https://github.com/sharanmankala/polyphony/blob/main/backend/app/database.py"
click node_domain_tables "https://github.com/sharanmankala/polyphony/blob/main/backend/app/db_models.py"
click node_image_files "https://github.com/sharanmankala/polyphony/tree/main/backend/assets/images"
click node_analyzer "https://github.com/sharanmankala/polyphony/blob/main/backend/app/image_analysis.py"
click node_analysis_records "https://github.com/sharanmankala/polyphony/blob/main/backend/app/db_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_web,node_user toneBlue
class node_api_routes,node_contracts,node_auth,node_settings,node_project_ops,node_session_ops,node_asset_ops toneAmber
class node_db_session,node_domain_tables,node_postgres,node_image_files toneMint
class node_analyzer,node_analysis_records,node_future_vision toneRose
```

## Components

### Workspace

- [Creative workspace](https://github.com/sharanmankala/polyphony/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`

### API and domain

- [FastAPI routes](https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py): `backend/app/main.py`
- [Request and response models](https://github.com/sharanmankala/polyphony/blob/main/backend/app/models.py): `backend/app/models.py`
- [Authentication](https://github.com/sharanmankala/polyphony/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [App and upload settings](https://github.com/sharanmankala/polyphony/blob/main/backend/app/config.py): `backend/app/config.py`
- [Project operations](https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py): `backend/app/main.py`
- [Session operations](https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py): `backend/app/main.py`
- [Image asset lifecycle](https://github.com/sharanmankala/polyphony/blob/main/backend/app/main.py): `backend/app/main.py`

### Persistence

- [Database sessions](https://github.com/sharanmankala/polyphony/blob/main/backend/app/database.py): `backend/app/database.py`
- [Domain tables](https://github.com/sharanmankala/polyphony/blob/main/backend/app/db_models.py): `backend/app/db_models.py`
- **PostgreSQL**
- [Local image files](https://github.com/sharanmankala/polyphony/tree/main/backend/assets/images): `backend/assets/images`

### Image analysis

- [Pixel signal analyzer](https://github.com/sharanmankala/polyphony/blob/main/backend/app/image_analysis.py): `backend/app/image_analysis.py`
- [Analysis records](https://github.com/sharanmankala/polyphony/blob/main/backend/app/db_models.py): `backend/app/db_models.py`
- **Vision-model gateway (planned)**

### Other components

- **Creative user**

## Connections

- Creative user → Creative workspace: uses (evidence: `README.md`)
- Creative workspace → FastAPI routes: requests API (evidence: `README.md`)
- FastAPI routes → Request and response models: validates and responds (evidence: `README.md`)
- FastAPI routes → Authentication: authenticates (evidence: `backend/app/main.py`)
- FastAPI routes → Project operations: routes project work (evidence: `README.md`)
- FastAPI routes → Session operations: routes session work (evidence: `README.md`)
- FastAPI routes → Image asset lifecycle: routes asset work (evidence: `README.md`)
- FastAPI routes → Database sessions: gets database session (evidence: `backend/app/main.py`)
- Database sessions → PostgreSQL: opens sessions (evidence: `backend/app/database.py`)
- Domain tables → Database sessions: uses base (evidence: `backend/app/db_models.py`)
- Project operations → Domain tables: reads and writes (evidence: `backend/app/main.py`)
- Session operations → Domain tables: reads and writes (evidence: `backend/app/main.py`)
- Image asset lifecycle → Domain tables: reads and writes (evidence: `backend/app/main.py`)
- Image asset lifecycle → App and upload settings: checks upload limits (evidence: `README.md`)
- Image asset lifecycle → Local image files: stores and removes (evidence: `README.md`)
- Image asset lifecycle → Pixel signal analyzer: analyzes image (evidence: `backend/app/main.py`)
- Image asset lifecycle → Analysis records: persists signals (evidence: `backend/app/main.py`)
- Pixel signal analyzer → Image asset lifecycle: returns signals (evidence: `README.md`)
- Creative workspace → Vision-model gateway (planned): no current integration (evidence: `README.md`)
