# numerotec/delegate_photo_auto_crop architecture

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

- Interactive diagram: https://gitdiagram.com/numerotec/delegate_photo_auto_crop
- Repository: https://github.com/numerotec/delegate_photo_auto_crop

## Overview

This Flask application manages conference delegate photos: an operator selects a conference, processes its delegate images into passport-style crops, reviews or edits results, and uploads approved images to S3 while updating delegate records. Separate routes provide dashboards, logs, previews, and record updates; per-conference state keeps processing and upload jobs isolated. The sampled files and source index support the main processing and upload links; several route implementations were not sampled, so their internal behavior is represented only where indexed references support it.

Main entry points: [`app.py`](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/app.py) (Flask app), [`db/database.py`](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/db/database.py) (Database access), [`routes/dashboard.py`](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/dashboard.py) (Conference dashboard), [`routes/state.py`](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/state.py) (Conference state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask app<br/>[app.py]"]
  node_dashboard["Conference dashboard<br/>[dashboard.py]"]
  node_photo_routes["Photo review<br/>[photos.py]"]
  node_preview["Preview route<br/>[preview.py]"]
  node_logs["Processing logs<br/>[logs.py]"]
  node_updates["Delegate updates<br/>[update.py]"]
  node_processing["Processing routes<br/>[processing.py]"]
  node_templates["Dashboard and photo views<br/>[dashboard.html]"]
end

subgraph group_workflow["Photo workflow"]
  node_conferences["Conference lookup"]
  node_photos["Photo service<br/>[photo_service.py]"]
  node_face["Face detection<br/>[face_detector.py]"]
  node_crop["Passport cropping<br/>[crop_service.py]"]
end

subgraph group_state["State and persistence"]
  node_state[("Conference state<br/>[state.py]")]
  node_config["Configuration<br/>[config.py]"]
  node_db_access["Database access<br/>[database.py]"]
end

subgraph group_delivery["Photo delivery"]
  node_s3_upload["S3 upload routes<br/>[s3_upload.py]"]
  node_s3_service["S3 service<br/>[s3_service.py]"]
end

node_operator(("Operator"))
node_mysql[("MySQL")]
node_s3[("Amazon S3")]
node_photo_source(("Photo source"))

node_operator -->|"uses"| node_app
node_app -->|"registers"| node_dashboard
node_app -->|"registers"| node_processing
node_app -->|"registers"| node_preview
node_app -->|"registers"| node_updates
node_app -->|"registers"| node_photo_routes
node_app -->|"registers"| node_logs
node_app -->|"registers"| node_s3_upload
node_dashboard -->|"renders"| node_templates
node_dashboard -->|"loads conferences"| node_conferences
node_dashboard -->|"fetches delegates"| node_photos
node_dashboard -->|"detects faces"| node_face
node_dashboard -->|"generates crops"| node_crop
node_dashboard -->|"tracks jobs"| node_state
node_photo_source -->|"downloads originals"| node_photos
node_photos -->|"queries delegates"| node_db_access
node_conferences -->|"queries conferences"| node_db_access
node_db_access -->|"reads settings"| node_config
node_db_access -->|"opens connection"| node_mysql
node_processing -->|"uses photo service"| node_photos
node_processing -->|"detects faces"| node_face
node_processing -->|"generates crops"| node_crop
node_processing -->|"tracks jobs"| node_state
node_crop -->|"reads crop settings"| node_config
node_crop -->|"uses detection"| node_face
node_photo_routes -->|"reads photo state"| node_state
node_photo_routes -->|"accesses records"| node_db_access
node_photo_routes -->|"builds photo URLs"| node_photos
node_preview -->|"loads preview data"| node_state
node_logs -->|"reads job state"| node_state
node_logs -->|"accesses records"| node_db_access
node_updates -->|"updates job state"| node_state
node_updates -->|"updates records"| node_db_access
node_s3_upload -->|"tracks uploads"| node_state
node_s3_upload -->|"uploads photos"| node_s3_service
node_s3_upload -->|"updates delegate records"| node_db_access
node_s3_service -->|"transfers objects"| node_s3

click node_app "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/app.py"
click node_dashboard "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/dashboard.py"
click node_photo_routes "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/photos.py"
click node_preview "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/preview.py"
click node_logs "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/logs.py"
click node_updates "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/update.py"
click node_processing "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/processing.py"
click node_conferences "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/conference_service.py"
click node_photos "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/photo_service.py"
click node_face "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/face_detector.py"
click node_crop "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/crop_service.py"
click node_state "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/state.py"
click node_config "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/config.py"
click node_db_access "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/db/database.py"
click node_s3_upload "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/s3_upload.py"
click node_s3_service "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/s3_service.py"
click node_templates "https://github.com/numerotec/delegate_photo_auto_crop/blob/main/templates/dashboard.html"

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_dashboard,node_photo_routes,node_preview,node_logs,node_updates,node_processing,node_templates toneBlue
class node_conferences,node_photos,node_face,node_crop,node_mysql,node_s3 toneAmber
class node_state,node_config,node_db_access toneMint
class node_s3_upload,node_s3_service toneRose
class node_operator,node_photo_source toneIndigo
```

## Components

### Web application

- [Flask app](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/app.py): `app.py`
- [Conference dashboard](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/dashboard.py): `routes/dashboard.py`
- [Photo review](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/photos.py): `routes/photos.py`
- [Preview route](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/preview.py): `routes/preview.py`
- [Processing logs](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/logs.py): `routes/logs.py`
- [Delegate updates](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/update.py): `routes/update.py`
- [Processing routes](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/processing.py): `routes/processing.py`
- [Dashboard and photo views](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/templates/dashboard.html): `templates/dashboard.html`

### Photo workflow

- [Conference lookup](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/conference_service.py): `services/conference_service.py`
- [Photo service](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/photo_service.py): `services/photo_service.py`
- [Face detection](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/face_detector.py): `services/face_detector.py`
- [Passport cropping](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/crop_service.py): `services/crop_service.py`

### State and persistence

- [Conference state](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/state.py): `routes/state.py`
- [Configuration](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/config.py): `config.py`
- [Database access](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/db/database.py): `db/database.py`

### Photo delivery

- [S3 upload routes](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/routes/s3_upload.py): `routes/s3_upload.py`
- [S3 service](https://github.com/numerotec/delegate_photo_auto_crop/blob/main/services/s3_service.py): `services/s3_service.py`

### Other components

- **Operator**
- **MySQL**
- **Amazon S3**
- **Photo source**

## Connections

- Operator → Flask app: uses (evidence: `app.py`)
- Flask app → Conference dashboard: registers (evidence: `app.py`)
- Flask app → Processing routes: registers (evidence: `app.py`)
- Flask app → Preview route: registers (evidence: `app.py`)
- Flask app → Delegate updates: registers (evidence: `app.py`)
- Flask app → Photo review: registers (evidence: `app.py`)
- Flask app → Processing logs: registers (evidence: `app.py`)
- Flask app → S3 upload routes: registers (evidence: `app.py`)
- Conference dashboard → Dashboard and photo views: renders (evidence: `routes/dashboard.py`)
- Conference dashboard → Conference lookup: loads conferences (evidence: `routes/dashboard.py`)
- Conference dashboard → Photo service: fetches delegates (evidence: `routes/dashboard.py`)
- Conference dashboard → Face detection: detects faces (evidence: `routes/dashboard.py`)
- Conference dashboard → Passport cropping: generates crops (evidence: `routes/dashboard.py`)
- Conference dashboard → Conference state: tracks jobs (evidence: `routes/dashboard.py`)
- Photo source → Photo service: downloads originals (evidence: `services/photo_service.py`)
- Photo service → Database access: queries delegates (evidence: `services/photo_service.py`)
- Conference lookup → Database access: queries conferences (evidence: `services/conference_service.py`)
- Database access → Configuration: reads settings (evidence: `db/database.py`)
- Database access → MySQL: opens connection (evidence: `db/database.py`)
- Processing routes → Photo service: uses photo service (evidence: `routes/processing.py`)
- Processing routes → Face detection: detects faces (evidence: `routes/processing.py`)
- Processing routes → Passport cropping: generates crops (evidence: `routes/processing.py`)
- Processing routes → Conference state: tracks jobs (evidence: `routes/processing.py`)
- Passport cropping → Configuration: reads crop settings (evidence: `services/crop_service.py`)
- Passport cropping → Face detection: uses detection (evidence: `services/crop_service.py`)
- Photo review → Conference state: reads photo state (evidence: `routes/photos.py`)
- Photo review → Database access: accesses records (evidence: `routes/photos.py`)
- Photo review → Photo service: builds photo URLs (evidence: `routes/photos.py`)
- Preview route → Conference state: loads preview data (evidence: `routes/preview.py`)
- Processing logs → Conference state: reads job state (evidence: `routes/logs.py`)
- Processing logs → Database access: accesses records (evidence: `routes/logs.py`)
- Delegate updates → Conference state: updates job state (evidence: `routes/update.py`)
- Delegate updates → Database access: updates records (evidence: `routes/update.py`)
- S3 upload routes → Conference state: tracks uploads (evidence: `routes/s3_upload.py`)
- S3 upload routes → S3 service: uploads photos (evidence: `routes/s3_upload.py`)
- S3 upload routes → Database access: updates delegate records (evidence: `routes/s3_upload.py`)
- S3 service → Amazon S3: transfers objects (evidence: `services/s3_service.py`)
