# avi4748sinha/chitrai architecture

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

- Interactive diagram: https://gitdiagram.com/avi4748sinha/chitrai
- Repository: https://github.com/avi4748sinha/chitrai

## Overview

ChitrAI is a prompt-based image-generation web app. A user enters a description in the React interface; it posts the prompt to the FastAPI endpoint, which calls Cloudflare’s Flux image API and returns base64 image data for display. The backend also provides health and custom API-docs endpoints and serves static files. A Gemini client exists, but its source says it is currently unused; it is not part of the shown generation workflow. Relationships reflect the excerpts; no README was provided.

Main entry points: [`backend/image_routes.py`](https://github.com/avi4748sinha/chitrai/blob/main/backend/image_routes.py) (Image endpoint), [`frontend/src/App.jsx`](https://github.com/avi4748sinha/chitrai/blob/main/frontend/src/App.jsx) (Prompt and preview), [`frontend/src/main.jsx`](https://github.com/avi4748sinha/chitrai/blob/main/frontend/src/main.jsx) (React entry), [`backend/main.py`](https://github.com/avi4748sinha/chitrai/blob/main/backend/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["Prompt and preview<br/>[App.jsx]"]
  node_entry["React entry<br/>[main.jsx]"]
end

subgraph group_backend["API backend"]
  node_api["FastAPI app<br/>[main.py]"]
  node_generate["Image endpoint<br/>[image_routes.py]"]
end

subgraph group_services["External services"]
  node_cloudflare["Cloudflare Flux"]
end

node_user(("User"))

node_user -->|"enters prompt"| node_app
node_entry -->|"renders"| node_app
node_app -->|"posts prompt"| node_generate
node_api -->|"registers routes"| node_generate
node_generate -->|"sends prompt"| node_cloudflare
node_cloudflare -->|"returns image"| node_generate
node_generate -->|"returns image data"| node_app

click node_app "https://github.com/avi4748sinha/chitrai/blob/main/frontend/src/App.jsx"
click node_entry "https://github.com/avi4748sinha/chitrai/blob/main/frontend/src/main.jsx"
click node_api "https://github.com/avi4748sinha/chitrai/blob/main/backend/main.py"
click node_generate "https://github.com/avi4748sinha/chitrai/blob/main/backend/image_routes.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_app,node_entry,node_user toneBlue
class node_api,node_generate toneAmber
class node_cloudflare toneMint
```

## Components

### Web interface

- [Prompt and preview](https://github.com/avi4748sinha/chitrai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [React entry](https://github.com/avi4748sinha/chitrai/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### API backend

- [FastAPI app](https://github.com/avi4748sinha/chitrai/blob/main/backend/main.py): `backend/main.py`
- [Image endpoint](https://github.com/avi4748sinha/chitrai/blob/main/backend/image_routes.py): `backend/image_routes.py`

### External services

- **Cloudflare Flux**

### Other components

- **User**

## Connections

- User → Prompt and preview: enters prompt (evidence: `frontend/src/App.jsx`)
- React entry → Prompt and preview: renders (evidence: `frontend/src/main.jsx`)
- Prompt and preview → Image endpoint: posts prompt (evidence: `frontend/src/App.jsx`)
- FastAPI app → Image endpoint: registers routes (evidence: `backend/main.py`)
- Image endpoint → Cloudflare Flux: sends prompt (evidence: `backend/image_routes.py`)
- Cloudflare Flux → Image endpoint: returns image (evidence: `backend/image_routes.py`)
- Image endpoint → Prompt and preview: returns image data (evidence: `backend/image_routes.py`)
