# ipunsoumya/photo-curator architecture

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

- Interactive diagram: https://gitdiagram.com/ipunsoumya/photo-curator
- Repository: https://github.com/ipunsoumya/photo-curator

## Overview

#### Purpose and entry points
This is a full-stack photo-curation application: a browser UI drives a Python backend that manages photo batches, review decisions, training/classification, and integration with an Immich photo service. The frontend boots at `frontend/src/main.jsx` and renders the application shell in `frontend/src/App.jsx`. The backend API starts from `backend/main.py`.

#### Frontend application and user state
The Vite-based React frontend provides distinct workflow screens for authentication, active photo review, historical batches, settings, and training metrics:
- `frontend/src/pages/Login.jsx`
- `frontend/src/pages/ReviewQueue.jsx`
- `frontend/src/pages/BatchHistory.jsx`
- `frontend/src/pages/Settings.jsx`
- `frontend/src/pages/TrainingStats.jsx`

`frontend/src/context/AuthContext.jsx` owns client-side authentication state, while `frontend/src/api.js` is the boundary for requests to the backend. UI components should not directly depend on backend services or persistence details.

#### API routing and workflow boundary
The backend separates HTTP concerns by domain routes:
- `backend/routes/auth.py`
- `backend/routes/photos.py`
- `backend/routes/batches.py`
- `backend/routes/decisions.py`
- `backend/routes/training.py`

`backend/main.py` composes the application and route layer. The primary control flow is: authenticated frontend request → domain route → service layer → database and/or external provider → API response. Batch and photo routes likely establish review work; decision routes record human curation outcomes; training routes expose or initiate learning/classification-related operations.

#### Persistence and application configuration
`backend/config.py` centralizes runtime configuration, including values needed by database and external integrations. `backend/database.py` is the persistence boundary, backed in the repository by `backend/photocurator.db`, indicating a local SQLite deployment model. Routes and services should access storage through this module rather than coupling directly to the database file.

The database is the durable source for application-owned state such as authentication-related records, batches, review decisions, sessions, and training data. Immich remains the likely system of record for upstream photo assets.

#### Curation, learning, and automation services
The core decisioning pipeline is implemented in the service layer:
- `backend/services/classifier.py`
- `backend/services/rule_extractor.py`
- `backend/services/prompt_builder.py`
- `backend/services/llm_client.py`
- `backend/services/scheduler.py`

Human decisions from the review workflow can feed rule extraction and classifier behavior. `prompt_builder.py` prepares structured context for `llm_client.py`, creating a clear boundary between local curation logic and an external LLM provider. `scheduler.py` is the likely orchestration point for deferred, periodic, or batch-oriented processing rather than request-time UI handling.

#### External systems and session boundaries
`backend/services/immich.py` encapsulates communication with Immich and should isolate remote photo retrieval or update semantics from routes and classifiers. `backend/services/session.py` supports server-side session/authentication lifecycle, with `backend/routes/auth.py` as its HTTP-facing counterpart.

Material runtime dependencies are Python backend packages declared in `backend/requirements.txt` and the Node/Vite frontend declared in `frontend/package.json`. The main infrastructure boundaries are: React browser client, Python API process, local SQLite database, Immich service, and an LLM service accessed through `backend/services/llm_client.py`.

Main entry points: [`backend/database.py`](https://github.com/ipunsoumya/photo-curator/blob/main/backend/database.py) (Persistence boundary), [`backend/config.py`](https://github.com/ipunsoumya/photo-curator/blob/main/backend/config.py) (Runtime configuration), [`frontend/src/App.jsx`](https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/App.jsx) (Application shell), [`frontend/src/api.js`](https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/api.js) (Backend API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_fe_main["Frontend bootstrap<br/>Vite entry<br/>[main.jsx]"]
  node_fe_app["Application shell<br/>React app<br/>[App.jsx]"]
  node_fe_auth["Auth state<br/>React context<br/>[AuthContext.jsx]"]
  node_fe_api["Backend API client<br/>request boundary<br/>[api.js]"]
  node_fe_workflows["Curation workflows<br/>React pages"]
end

subgraph group_backend["Python backend"]
  node_be_main["API application<br/>Python entry point<br/>[main.py]"]
  node_routes["Domain routes<br/>HTTP routing"]
  node_session["Session lifecycle<br/>auth service<br/>[session.py]"]
  node_services["Curation services<br/>service layer"]
  node_classifier["Classifier<br/>decisioning service<br/>[classifier.py]"]
  node_rule_extractor["Rule extraction<br/>learning service<br/>[rule_extractor.py]"]
  node_prompt_builder["Prompt builder<br/>LLM context<br/>[prompt_builder.py]"]
  node_scheduler["Batch scheduler<br/>orchestration service<br/>[scheduler.py]"]
  node_database[("Persistence boundary<br/>database access<br/>[database.py]")]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_external["Infrastructure &amp; providers"]
  node_sqlite[("Local SQLite state<br/>SQLite database<br/>[photocurator.db]")]
  node_immich{{"Immich integration<br/>photo provider adapter<br/>[immich.py]"}}
  node_llm_client{{"LLM provider client<br/>external AI adapter<br/>[llm_client.py]"}}
end

node_fe_main -->|"renders"| node_fe_app
node_fe_app -->|"uses"| node_fe_auth
node_fe_app -->|"hosts"| node_fe_workflows
node_fe_workflows -->|"requests"| node_fe_api
node_fe_auth -->|"authenticates requests"| node_fe_api
node_fe_api -->|"HTTP"| node_be_main
node_be_main -->|"composes"| node_routes
node_routes -->|"auth endpoints"| node_session
node_routes -->|"review and training operations"| node_services
node_session -->|"stores sessions"| node_database
node_services -->|"reads and writes state"| node_database
node_services -->|"retrieves and updates photos"| node_immich
node_services -->|"classifies review work"| node_classifier
node_services -->|"feeds human decisions"| node_rule_extractor
node_rule_extractor -->|"updates rules"| node_classifier
node_classifier -->|"builds AI context"| node_prompt_builder
node_prompt_builder -->|"sends prompt"| node_llm_client
node_scheduler -->|"runs batch processing"| node_services
node_database -->|"persists through"| node_sqlite
node_config -.->|"configures"| node_database
node_config -.->|"configures"| node_immich
node_config -.->|"configures"| node_llm_client

click node_fe_main "https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/main.jsx"
click node_fe_app "https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/App.jsx"
click node_fe_auth "https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/context/AuthContext.jsx"
click node_fe_api "https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/api.js"
click node_be_main "https://github.com/ipunsoumya/photo-curator/blob/main/backend/main.py"
click node_session "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/session.py"
click node_classifier "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/classifier.py"
click node_rule_extractor "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/rule_extractor.py"
click node_prompt_builder "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/prompt_builder.py"
click node_scheduler "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/scheduler.py"
click node_database "https://github.com/ipunsoumya/photo-curator/blob/main/backend/database.py"
click node_config "https://github.com/ipunsoumya/photo-curator/blob/main/backend/config.py"
click node_sqlite "https://github.com/ipunsoumya/photo-curator/blob/main/backend/photocurator.db"
click node_immich "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/immich.py"
click node_llm_client "https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/llm_client.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_fe_main,node_fe_app,node_fe_auth,node_fe_api,node_fe_workflows toneBlue
class node_be_main,node_routes,node_session,node_services,node_classifier,node_rule_extractor,node_prompt_builder,node_scheduler,node_database,node_config toneAmber
class node_sqlite,node_immich,node_llm_client toneMint
```

## Components

### React frontend

- [Frontend bootstrap](https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/main.jsx): Vite entry · `frontend/src/main.jsx`
- [Application shell](https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/App.jsx): React app · `frontend/src/App.jsx`
- [Auth state](https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/context/AuthContext.jsx): React context · `frontend/src/context/AuthContext.jsx`
- [Backend API client](https://github.com/ipunsoumya/photo-curator/blob/main/frontend/src/api.js): request boundary · `frontend/src/api.js`
- **Curation workflows**: React pages · Login, review queue, batch history, settings, and training metrics screens.

### Python backend

- [API application](https://github.com/ipunsoumya/photo-curator/blob/main/backend/main.py): Python entry point · `backend/main.py`
- **Domain routes**: HTTP routing · Authentication, photos, batches, decisions, and training endpoints.
- [Session lifecycle](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/session.py): auth service · `backend/services/session.py`
- **Curation services**: service layer · Establishes review work and records curation outcomes.
- [Classifier](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/classifier.py): decisioning service · `backend/services/classifier.py`
- [Rule extraction](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/rule_extractor.py): learning service · Derives curation rules from human decisions. · `backend/services/rule_extractor.py`
- [Prompt builder](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/prompt_builder.py): LLM context · `backend/services/prompt_builder.py`
- [Batch scheduler](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/scheduler.py): orchestration service · Runs deferred or periodic processing. · `backend/services/scheduler.py`
- [Persistence boundary](https://github.com/ipunsoumya/photo-curator/blob/main/backend/database.py): database access · Routes and services access application-owned state through this module. · `backend/database.py`
- [Runtime configuration](https://github.com/ipunsoumya/photo-curator/blob/main/backend/config.py): configuration · Supplies database and provider integration settings. · `backend/config.py`

### Infrastructure & providers

- [Local SQLite state](https://github.com/ipunsoumya/photo-curator/blob/main/backend/photocurator.db): SQLite database · Durable application state for accounts, batches, decisions, sessions, and training data. · `backend/photocurator.db`
- [Immich integration](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/immich.py): photo provider adapter · Isolates remote photo retrieval and update semantics. · `backend/services/immich.py`
- [LLM provider client](https://github.com/ipunsoumya/photo-curator/blob/main/backend/services/llm_client.py): external AI adapter · `backend/services/llm_client.py`

## Connections

- Frontend bootstrap → Application shell: renders
- Application shell → Auth state: uses
- Application shell → Curation workflows: hosts
- Curation workflows → Backend API client: requests
- Auth state → Backend API client: authenticates requests
- Backend API client → API application: HTTP
- API application → Domain routes: composes
- Domain routes → Session lifecycle: auth endpoints
- Domain routes → Curation services: review and training operations
- Session lifecycle → Persistence boundary: stores sessions
- Curation services → Persistence boundary: reads and writes state
- Curation services → Immich integration: retrieves and updates photos
- Curation services → Classifier: classifies review work
- Curation services → Rule extraction: feeds human decisions
- Rule extraction → Classifier: updates rules
- Classifier → Prompt builder: builds AI context
- Prompt builder → LLM provider client: sends prompt
- Batch scheduler → Curation services: runs batch processing
- Persistence boundary → Local SQLite state: persists through
- Runtime configuration → Persistence boundary: configures
- Runtime configuration → Immich integration: configures
- Runtime configuration → LLM provider client: configures
