# danamushiva-cloud/prompt-generator-backend architecture

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

- Interactive diagram: https://gitdiagram.com/danamushiva-cloud/prompt-generator-backend
- Repository: https://github.com/danamushiva-cloud/prompt-generator-backend

## Overview

This is a FastAPI backend for generating optimized prompts from a user's idea and category, with JWT authentication and per-user history and favorites. The main workflow is signup or login, then an authenticated request to generate a prompt; the API calls a Modal-hosted inference service, saves the result, and returns it. Users can later retrieve history and toggle or list favorites. The README also documents six prompt categories and the fine-tuned Qwen model. Edges reflect the sampled route and helper code or explicit README statements; the inference implementation itself is external and not present in this repository.

Main entry points: [`main.py`](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/main.py) (FastAPI routes), [`database.py`](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/database.py) (Session and engine), [`auth.py`](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/auth.py) (JWT authentication), [`models.py`](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/models.py) (User and history models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflows"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_identity["Identity"]
  node_auth["JWT authentication<br/>[auth.py]"]
end

subgraph group_persistence["Persistence"]
  node_models["User and history models<br/>[models.py]"]
  node_database["Session and engine<br/>[database.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_inference["Prompt inference"]
  node_modal{{"Modal inference endpoint"}}
end

node_user(("Client user"))

node_user -->|"calls endpoints"| node_api
node_api -->|"validates and shapes"| node_schemas
node_api -->|"authenticates requests"| node_auth
node_api -->|"queries and saves"| node_models
node_api -->|"obtains sessions"| node_database
node_auth -->|"obtains sessions"| node_database
node_auth -->|"looks up users"| node_models
node_models -->|"uses ORM base"| node_database
node_database -->|"connects to"| node_sqlite
node_api -->|"sends idea and category"| node_modal

click node_api "https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/main.py"
click node_schemas "https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/schemas.py"
click node_auth "https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/auth.py"
click node_models "https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/models.py"
click node_database "https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/database.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_user toneBlue
class node_auth toneAmber
class node_models,node_database,node_sqlite toneMint
class node_modal toneRose
```

## Components

### API workflows

- [FastAPI routes](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/main.py): `main.py`
- [Request schemas](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/schemas.py): `schemas.py`

### Identity

- [JWT authentication](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/auth.py): `auth.py`

### Persistence

- [User and history models](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/models.py): `models.py`
- [Session and engine](https://github.com/danamushiva-cloud/prompt-generator-backend/blob/main/database.py): `database.py`
- **SQLite database**

### Prompt inference

- **Modal inference endpoint**

### Other components

- **Client user**

## Connections

- Client user → FastAPI routes: calls endpoints (evidence: `README.md`)
- FastAPI routes → Request schemas: validates and shapes (evidence: `main.py`)
- FastAPI routes → JWT authentication: authenticates requests (evidence: `main.py`)
- FastAPI routes → User and history models: queries and saves (evidence: `main.py`)
- FastAPI routes → Session and engine: obtains sessions (evidence: `main.py`)
- JWT authentication → Session and engine: obtains sessions (evidence: `auth.py`)
- JWT authentication → User and history models: looks up users (evidence: `auth.py`)
- User and history models → Session and engine: uses ORM base (evidence: `models.py`)
- Session and engine → SQLite database: connects to (evidence: `database.py`)
- FastAPI routes → Modal inference endpoint: sends idea and category (evidence: `main.py`)
