# chaithumoorpa/comiccraft architecture

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

- Interactive diagram: https://gitdiagram.com/chaithumoorpa/comiccraft
- Repository: https://github.com/chaithumoorpa/comiccraft

## Overview

ComicCraft is a FastAPI web app that turns a user's idea into a five-panel comic: Gemini creates an outline and story text, image generation renders panels, and the app assembles a layout and exports a PDF. The routes own this orchestration, including the separate JSON export and image-test endpoints. The README documents the major capabilities; wiring shown here is based on sampled routes and service source, while static-file serving is visible in the app entry point.

Main entry points: [`app/routes.py`](https://github.com/chaithumoorpa/comiccraft/blob/main/app/routes.py) (API routes), [`app/main.py`](https://github.com/chaithumoorpa/comiccraft/blob/main/app/main.py) (FastAPI app), [`app/services/image_generator.py`](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/image_generator.py) (Image generator), [`app/services/gemini_client.py`](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_client.py) (Gemini client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_routes["API routes<br/>[routes.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_templates["Page templates<br/>[index.html]"]
  node_main["FastAPI app<br/>[main.py]"]
  node_settings["App settings<br/>[config.py]"]
end

subgraph group_story["Story generation"]
  node_outline["Outline generator<br/>[gemini_flash.py]"]
  node_story_text["Story generator<br/>[gemini_pro.py]"]
  node_gemini_client["Gemini client<br/>[gemini_client.py]"]
end

subgraph group_art["Panel artwork"]
  node_image_generator["Image generator<br/>[image_generator.py]"]
  node_panel_store[("Panel images")]
end

subgraph group_output["Layout and export"]
  node_layout["Layout builder<br/>[layout_builder.py]"]
  node_exporter["PDF exporter<br/>[exporters.py]"]
  node_pdf_store[("Exported PDFs")]
end

node_user(("Comic creator"))
node_gemini{{"Gemini API"}}
node_diffusion{{"Stable Diffusion"}}

node_user -->|"submits prompt"| node_routes
node_routes -->|"validates input"| node_schemas
node_routes -->|"requests outline"| node_outline
node_outline -->|"requests JSON"| node_gemini_client
node_story_text -->|"requests JSON"| node_gemini_client
node_gemini_client -->|"calls model"| node_gemini
node_gemini_client -->|"reads credentials"| node_settings
node_routes -->|"expands outline"| node_story_text
node_story_text -->|"reads model"| node_settings
node_outline -->|"reads model"| node_settings
node_routes -->|"generates panels"| node_image_generator
node_image_generator -->|"reads image settings"| node_settings
node_image_generator -.->|"renders panels"| node_diffusion
node_image_generator -->|"writes images"| node_panel_store
node_routes -->|"assembles layout"| node_layout
node_routes -->|"exports PDF"| node_exporter
node_exporter -->|"reads images"| node_panel_store
node_exporter -->|"writes PDF"| node_pdf_store
node_routes -->|"renders pages"| node_templates
node_user -->|"requests pages or files"| node_main
node_main -->|"dispatches requests"| node_routes
node_main -->|"serves static files"| node_panel_store
node_main -->|"serves static files"| node_pdf_store
node_routes -->|"downloads PDF"| node_pdf_store

click node_routes "https://github.com/chaithumoorpa/comiccraft/blob/main/app/routes.py"
click node_schemas "https://github.com/chaithumoorpa/comiccraft/blob/main/app/schemas.py"
click node_templates "https://github.com/chaithumoorpa/comiccraft/blob/main/templates/index.html"
click node_main "https://github.com/chaithumoorpa/comiccraft/blob/main/app/main.py"
click node_settings "https://github.com/chaithumoorpa/comiccraft/blob/main/app/config.py"
click node_outline "https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_flash.py"
click node_story_text "https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_pro.py"
click node_gemini_client "https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_client.py"
click node_image_generator "https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/image_generator.py"
click node_panel_store "https://github.com/chaithumoorpa/comiccraft/tree/main/static/panels"
click node_layout "https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/layout_builder.py"
click node_exporter "https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/exporters.py"
click node_pdf_store "https://github.com/chaithumoorpa/comiccraft/tree/main/static/exports"

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_routes,node_schemas,node_templates,node_main,node_settings toneBlue
class node_outline,node_story_text,node_gemini_client toneAmber
class node_image_generator,node_panel_store,node_gemini toneMint
class node_layout,node_exporter,node_pdf_store toneRose
class node_user,node_diffusion toneIndigo
```

## Components

### Web interface

- [API routes](https://github.com/chaithumoorpa/comiccraft/blob/main/app/routes.py): `app/routes.py`
- [Request schemas](https://github.com/chaithumoorpa/comiccraft/blob/main/app/schemas.py): `app/schemas.py`
- [Page templates](https://github.com/chaithumoorpa/comiccraft/blob/main/templates/index.html): `templates/index.html`
- [FastAPI app](https://github.com/chaithumoorpa/comiccraft/blob/main/app/main.py): `app/main.py`
- [App settings](https://github.com/chaithumoorpa/comiccraft/blob/main/app/config.py): `app/config.py`

### Story generation

- [Outline generator](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_flash.py): `app/services/gemini_flash.py`
- [Story generator](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_pro.py): `app/services/gemini_pro.py`
- [Gemini client](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/gemini_client.py): `app/services/gemini_client.py`

### Panel artwork

- [Image generator](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/image_generator.py): `app/services/image_generator.py`
- [Panel images](https://github.com/chaithumoorpa/comiccraft/tree/main/static/panels): `static/panels`

### Layout and export

- [Layout builder](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/layout_builder.py): `app/services/layout_builder.py`
- [PDF exporter](https://github.com/chaithumoorpa/comiccraft/blob/main/app/services/exporters.py): `app/services/exporters.py`
- [Exported PDFs](https://github.com/chaithumoorpa/comiccraft/tree/main/static/exports): `static/exports`

### Other components

- **Comic creator**
- **Gemini API**
- **Stable Diffusion**

## Connections

- Comic creator → API routes: submits prompt
- API routes → Request schemas: validates input
- API routes → Outline generator: requests outline
- Outline generator → Gemini client: requests JSON
- Story generator → Gemini client: requests JSON
- Gemini client → Gemini API: calls model
- Gemini client → App settings: reads credentials
- API routes → Story generator: expands outline
- Story generator → App settings: reads model
- Outline generator → App settings: reads model
- API routes → Image generator: generates panels
- Image generator → App settings: reads image settings
- Image generator → Stable Diffusion: renders panels
- Image generator → Panel images: writes images
- API routes → Layout builder: assembles layout
- API routes → PDF exporter: exports PDF
- PDF exporter → Panel images: reads images
- PDF exporter → Exported PDFs: writes PDF
- API routes → Page templates: renders pages
- Comic creator → FastAPI app: requests pages or files
- FastAPI app → API routes: dispatches requests
- FastAPI app → Panel images: serves static files
- FastAPI app → Exported PDFs: serves static files
- API routes → Exported PDFs: downloads PDF
