# keenztechnique/backend-sandbox architecture

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

- Interactive diagram: https://gitdiagram.com/keenztechnique/backend-sandbox
- Repository: https://github.com/keenztechnique/backend-sandbox

## Overview

This is a FastAPI task-submission and status service backed by PostgreSQL, with RabbitMQ-based asynchronous processing. A client submits a task; the API stores it and publishes a notification, while a worker consumes messages, processes them, and uses broker dead-letter routing for retries. Clients can separately query stored task status. The README is empty, so capabilities and relationships here are grounded in the sampled source; the publisher’s message format and the worker’s JSON parsing appear inconsistent.

Main entry points: [`main.py`](https://github.com/keenztechnique/backend-sandbox/blob/main/main.py) (FastAPI Endpoints), [`worker.py`](https://github.com/keenztechnique/backend-sandbox/blob/main/worker.py) (Task Worker), [`database.py`](https://github.com/keenztechnique/backend-sandbox/blob/main/database.py) (Async DB Sessions), [`models.py`](https://github.com/keenztechnique/backend-sandbox/blob/main/models.py) (Task Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api["FastAPI Endpoints<br/>[main.py]"]
  node_schemas["Task Schemas<br/>[main.py]"]
end

subgraph group_storage["Task Storage"]
  node_db_session["Async DB Sessions<br/>[database.py]"]
  node_task_model["Task Model<br/>[models.py]"]
end

subgraph group_messaging["Message Processing"]
  node_worker["Task Worker<br/>[worker.py]"]
end

subgraph group_observability["Logging"]
  node_logging["Structured Logging<br/>[logger.py]"]
end

node_client(("API Client"))
node_postgres[("PostgreSQL")]
node_rabbit["RabbitMQ"]

node_client -->|"submits or queries"| node_api
node_api -->|"validates and returns"| node_schemas
node_api -->|"uses sessions"| node_db_session
node_api -->|"creates and queries"| node_task_model
node_task_model -->|"uses Base"| node_db_session
node_db_session -->|"connects to"| node_postgres
node_api -->|"publishes task"| node_rabbit
node_rabbit -->|"delivers messages"| node_worker
node_worker -->|"acks or rejects"| node_rabbit
node_worker -->|"configures retry routing"| node_rabbit
node_api -->|"configures and logs"| node_logging
node_worker -->|"configures and logs"| node_logging

click node_api "https://github.com/keenztechnique/backend-sandbox/blob/main/main.py"
click node_schemas "https://github.com/keenztechnique/backend-sandbox/blob/main/main.py"
click node_db_session "https://github.com/keenztechnique/backend-sandbox/blob/main/database.py"
click node_task_model "https://github.com/keenztechnique/backend-sandbox/blob/main/models.py"
click node_worker "https://github.com/keenztechnique/backend-sandbox/blob/main/worker.py"
click node_logging "https://github.com/keenztechnique/backend-sandbox/blob/main/logger.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_api,node_schemas,node_client toneBlue
class node_db_session,node_task_model,node_postgres toneAmber
class node_worker toneMint
class node_logging toneRose
class node_rabbit toneIndigo
```

## Components

### HTTP API

- [FastAPI Endpoints](https://github.com/keenztechnique/backend-sandbox/blob/main/main.py): `main.py`
- [Task Schemas](https://github.com/keenztechnique/backend-sandbox/blob/main/main.py): `main.py`

### Task Storage

- [Async DB Sessions](https://github.com/keenztechnique/backend-sandbox/blob/main/database.py): `database.py`
- [Task Model](https://github.com/keenztechnique/backend-sandbox/blob/main/models.py): `models.py`

### Message Processing

- [Task Worker](https://github.com/keenztechnique/backend-sandbox/blob/main/worker.py): `worker.py`

### Logging

- [Structured Logging](https://github.com/keenztechnique/backend-sandbox/blob/main/logger.py): `logger.py`

### Other components

- **API Client**
- **PostgreSQL**
- **RabbitMQ**

## Connections

- API Client → FastAPI Endpoints: submits or queries (evidence: `main.py`)
- FastAPI Endpoints → Task Schemas: validates and returns (evidence: `main.py`)
- FastAPI Endpoints → Async DB Sessions: uses sessions (evidence: `main.py`)
- FastAPI Endpoints → Task Model: creates and queries (evidence: `main.py`)
- Task Model → Async DB Sessions: uses Base (evidence: `models.py`)
- Async DB Sessions → PostgreSQL: connects to (evidence: `database.py`)
- FastAPI Endpoints → RabbitMQ: publishes task (evidence: `main.py`)
- RabbitMQ → Task Worker: delivers messages (evidence: `worker.py`)
- Task Worker → RabbitMQ: acks or rejects (evidence: `worker.py`)
- Task Worker → RabbitMQ: configures retry routing (evidence: `worker.py`)
- FastAPI Endpoints → Structured Logging: configures and logs (evidence: `main.py`)
- Task Worker → Structured Logging: configures and logs (evidence: `worker.py`)
