# alejandro-jj/fastapi_bb architecture

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

- Interactive diagram: https://gitdiagram.com/alejandro-jj/fastapi_bb
- Repository: https://github.com/alejandro-jj/fastapi_bb

## Overview

BeadBuddy combines an authenticated image-upload/job API with asynchronous image processing, and also contains a separate bead-analysis library. The documented working path uploads an image, dispatches a Celery task through Redis, converts the image to grayscale, saves a result, and exposes task status. The sampled worker is still a placeholder for full segmentation; the richer segmentation and bead-analysis modules are not wired into it in the inspected code. The referenced optimization module is absent from the tree, so its behavior and connections are omitted.

Main entry points: [`backend/main.py`](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/main.py) (FastAPI routes), [`backend/tasks.py`](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/tasks.py) (Celery worker task), [`bb_funcs/completeAnalysis.py`](https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/completeAnalysis.py) (Complete analysis), [`bb_funcs/BeadClass.py`](https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/BeadClass.py) (Bead result model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_main["FastAPI routes<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
end

subgraph group_jobs["Job processing"]
  node_tasks["Celery worker task<br/>[tasks.py]"]
  node_redis[("Redis broker and results")]
end

subgraph group_analysis["Bead analysis"]
  node_complete["Complete analysis"]
  node_segmenter["Master segmenter<br/>[MasterSegmenter.py]"]
  node_bead["Bead result model<br/>[BeadClass.py]"]
  node_tools["Coordinate utilities<br/>[tools.py]"]
end

subgraph group_state["Data and files"]
  node_models["User and job models<br/>[models.py]"]
  node_database[("SQLite sessions<br/>[database.py]")]
  node_uploads[("Uploaded images")]
  node_results[("Processed images")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_main
node_main -->|"uses auth"| node_auth
node_main -->|"opens sessions"| node_database
node_main -->|"queries and writes"| node_models
node_main -->|"saves uploads"| node_uploads
node_main -->|"dispatches task"| node_tasks
node_main -->|"checks task result"| node_redis
node_main -->|"records result path"| node_results
node_tasks -->|"uses broker"| node_redis
node_redis -->|"delivers task"| node_tasks
node_tasks -->|"reads image"| node_uploads
node_tasks -->|"saves grayscale image"| node_results
node_complete -->|"runs segmentation"| node_segmenter
node_complete -->|"creates bead records"| node_bead
node_bead -->|"uses plotting utility"| node_tools

click node_main "https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/main.py"
click node_auth "https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/auth.py"
click node_models "https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/models.py"
click node_database "https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/database.py"
click node_uploads "https://github.com/alejandro-jj/fastapi_bb/tree/main/backend/uploads"
click node_results "https://github.com/alejandro-jj/fastapi_bb/tree/main/backend/results"
click node_tasks "https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/tasks.py"
click node_complete "https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/completeAnalysis.py"
click node_segmenter "https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/MasterSegmenter.py"
click node_bead "https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/BeadClass.py"
click node_tools "https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/tools.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_main,node_auth,node_client toneBlue
class node_tasks,node_redis toneAmber
class node_complete,node_segmenter,node_bead,node_tools toneMint
class node_models,node_database,node_uploads,node_results toneRose
```

## Components

### API and access

- [FastAPI routes](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/main.py): `backend/main.py`
- [Authentication](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/auth.py): `backend/auth.py`

### Job processing

- [Celery worker task](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/tasks.py): `backend/tasks.py`
- **Redis broker and results**

### Bead analysis

- [Complete analysis](https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/completeAnalysis.py): `bb_funcs/completeAnalysis.py`
- [Master segmenter](https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/MasterSegmenter.py): `bb_funcs/MasterSegmenter.py`
- [Bead result model](https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/BeadClass.py): `bb_funcs/BeadClass.py`
- [Coordinate utilities](https://github.com/alejandro-jj/fastapi_bb/blob/main/bb_funcs/tools.py): `bb_funcs/tools.py`

### Data and files

- [User and job models](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/models.py): `backend/models.py`
- [SQLite sessions](https://github.com/alejandro-jj/fastapi_bb/blob/main/backend/database.py): `backend/database.py`
- [Uploaded images](https://github.com/alejandro-jj/fastapi_bb/tree/main/backend/uploads): `backend/uploads`
- [Processed images](https://github.com/alejandro-jj/fastapi_bb/tree/main/backend/results): `backend/results`

### Other components

- **API client**

## Connections

- API client → FastAPI routes: sends requests
- FastAPI routes → Authentication: uses auth
- FastAPI routes → SQLite sessions: opens sessions
- FastAPI routes → User and job models: queries and writes
- FastAPI routes → Uploaded images: saves uploads
- FastAPI routes → Celery worker task: dispatches task
- FastAPI routes → Redis broker and results: checks task result
- FastAPI routes → Processed images: records result path
- Celery worker task → Redis broker and results: uses broker
- Redis broker and results → Celery worker task: delivers task
- Celery worker task → Uploaded images: reads image
- Celery worker task → Processed images: saves grayscale image
- Complete analysis → Master segmenter: runs segmentation
- Complete analysis → Bead result model: creates bead records
- Bead result model → Coordinate utilities: uses plotting utility
