# ankits1802/ragamala-painting-generator architecture

> Architecture diagram of the GitHub repository ankits1802/ragamala-painting-generator, 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/ankits1802/ragamala-painting-generator
- Repository: https://github.com/ankits1802/ragamala-painting-generator

## Overview

Ragamala Painting Generator fine-tunes SDXL with LoRA to create raga- and style-conditioned Indian miniature paintings. Its principal workflow prepares and annotates cultural artwork data, trains the model, then generates and evaluates images through an API or interactive interface. The graph also preserves documented data collection, human/cultural evaluation, cloud support, and training components. Evidence is limited to README statements and the supplied source index/excerpts; unsampled subsystem details and some runtime wiring are therefore not inferred.

Main entry points: [`api/routes/generate.py`](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/routes/generate.py) (Generation API), [`src/training/trainer.py`](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/trainer.py) (Training Orchestrator), [`src/inference/generator.py`](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/generator.py) (Ragamala Generator), [`api/app.py`](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/app.py) (API Application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Cultural Data"]
  node_collector["Artwork Collection<br/>[collector.py]"]
  node_preprocessor["Image Preprocessing<br/>[preprocessor.py]"]
  node_annotator["Cultural Annotation<br/>[annotator.py]"]
  node_dataset["Training Dataset<br/>[dataset.py]"]
end

subgraph group_training["Model Training"]
  node_trainer["Training Orchestrator<br/>[trainer.py]"]
  node_lora["SDXL LoRA<br/>[sdxl_lora.py]"]
  node_losses["Training Losses<br/>[losses.py]"]
  node_scheduler["Diffusion Scheduler<br/>[scheduler.py]"]
  node_callbacks["Training Callbacks<br/>[callbacks.py]"]
end

subgraph group_generation["Image Generation"]
  node_generator["Ragamala Generator<br/>[generator.py]"]
  node_promptencoder["Prompt Encoder<br/>[prompt_encoder.py]"]
  node_templates["Prompt Templates"]
  node_postprocessor["Image Postprocessing<br/>[post_processor.py]"]
end

subgraph group_evaluation["Quality Evaluation"]
  node_metrics["Image Metrics<br/>[metrics.py]"]
  node_cultural["Cultural Evaluator"]
  node_human["Human Evaluation<br/>[human_eval.py]"]
  node_visualization["Result Visualization<br/>[visualization.py]"]
end

subgraph group_product["User Access"]
  node_api["Generation API<br/>[generate.py]"]
  node_auth["API Authentication<br/>[auth.py]"]
  node_rate["Rate Limiting<br/>[rate_limiting.py]"]
  node_models["API Schemas<br/>[models.py]"]
  node_app["API Application<br/>[app.py]"]
  node_gradio["Gradio Interface<br/>[gradio_app.py]"]
  node_streamlit["Streamlit Interface<br/>[streamlit_app.py]"]
  node_aws["AWS Utilities<br/>[aws_utils.py]"]
end

node_user(("User"))

node_collector -->|"prepares images"| node_preprocessor
node_preprocessor -->|"enriches data"| node_annotator
node_annotator -.->|"labels examples"| node_dataset
node_trainer -->|"loads data"| node_dataset
node_trainer -->|"initializes model"| node_lora
node_trainer -->|"uses loss"| node_losses
node_trainer -->|"creates scheduler"| node_scheduler
node_trainer -->|"initializes callbacks"| node_callbacks
node_lora -->|"loads datasets"| node_dataset
node_generator -->|"encodes prompts"| node_promptencoder
node_generator -->|"uses scheduler"| node_scheduler
node_generator -.->|"uses templates"| node_templates
node_generator -.->|"postprocesses images"| node_postprocessor
node_api -->|"generates images"| node_generator
node_api -->|"calculates metrics"| node_metrics
node_api -->|"assesses culture"| node_cultural
node_api -->|"uses schemas"| node_models
node_api -->|"verifies credentials"| node_auth
node_app -->|"mounts routes"| node_api
node_app -->|"configures limits"| node_rate
node_streamlit -->|"calls API"| node_api
node_user -->|"uses interface"| node_streamlit
node_user -->|"uses interface"| node_gradio
node_user -->|"submits requests"| node_api
node_callbacks -->|"uses metrics"| node_metrics
node_callbacks -->|"uses visualizations"| node_visualization
node_app -->|"uses cloud utilities"| node_aws
node_human -.->|"complements scoring"| node_metrics

click node_collector "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/collector.py"
click node_preprocessor "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/preprocessor.py"
click node_annotator "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/annotator.py"
click node_dataset "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/dataset.py"
click node_trainer "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/trainer.py"
click node_lora "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/models/sdxl_lora.py"
click node_losses "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/losses.py"
click node_scheduler "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/models/scheduler.py"
click node_callbacks "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/callbacks.py"
click node_generator "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/generator.py"
click node_promptencoder "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/models/prompt_encoder.py"
click node_templates "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/prompt_templates.py"
click node_postprocessor "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/post_processor.py"
click node_metrics "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/evaluation/metrics.py"
click node_cultural "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/evaluation/cultural_evaluator.py"
click node_human "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/evaluation/human_eval.py"
click node_visualization "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/utils/visualization.py"
click node_api "https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/routes/generate.py"
click node_auth "https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/middleware/auth.py"
click node_rate "https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/middleware/rate_limiting.py"
click node_models "https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/models.py"
click node_app "https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/app.py"
click node_gradio "https://github.com/ankits1802/ragamala-painting-generator/blob/main/frontend/gradio_app.py"
click node_streamlit "https://github.com/ankits1802/ragamala-painting-generator/blob/main/frontend/streamlit_app.py"
click node_aws "https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/utils/aws_utils.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_collector,node_preprocessor,node_annotator,node_dataset,node_user toneBlue
class node_trainer,node_lora,node_losses,node_scheduler,node_callbacks toneAmber
class node_generator,node_promptencoder,node_templates,node_postprocessor toneMint
class node_metrics,node_cultural,node_human,node_visualization toneRose
class node_api,node_auth,node_rate,node_models,node_app,node_gradio,node_streamlit,node_aws toneIndigo
```

## Components

### Cultural Data

- [Artwork Collection](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/collector.py): `src/data/collector.py`
- [Image Preprocessing](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/preprocessor.py): `src/data/preprocessor.py`
- [Cultural Annotation](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/annotator.py): `src/data/annotator.py`
- [Training Dataset](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/data/dataset.py): `src/data/dataset.py`

### Model Training

- [Training Orchestrator](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/trainer.py): `src/training/trainer.py`
- [SDXL LoRA](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/models/sdxl_lora.py): `src/models/sdxl_lora.py`
- [Training Losses](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/losses.py): `src/training/losses.py`
- [Diffusion Scheduler](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/models/scheduler.py): `src/models/scheduler.py`
- [Training Callbacks](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/training/callbacks.py): `src/training/callbacks.py`

### Image Generation

- [Ragamala Generator](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/generator.py): `src/inference/generator.py`
- [Prompt Encoder](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/models/prompt_encoder.py): `src/models/prompt_encoder.py`
- [Prompt Templates](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/prompt_templates.py): `src/inference/prompt_templates.py`
- [Image Postprocessing](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/inference/post_processor.py): `src/inference/post_processor.py`

### Quality Evaluation

- [Image Metrics](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/evaluation/metrics.py): `src/evaluation/metrics.py`
- [Cultural Evaluator](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/evaluation/cultural_evaluator.py): `src/evaluation/cultural_evaluator.py`
- [Human Evaluation](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/evaluation/human_eval.py): `src/evaluation/human_eval.py`
- [Result Visualization](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/utils/visualization.py): `src/utils/visualization.py`

### User Access

- [Generation API](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/routes/generate.py): `api/routes/generate.py`
- [API Authentication](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/middleware/auth.py): `api/middleware/auth.py`
- [Rate Limiting](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/middleware/rate_limiting.py): `api/middleware/rate_limiting.py`
- [API Schemas](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/models.py): `api/models.py`
- [API Application](https://github.com/ankits1802/ragamala-painting-generator/blob/main/api/app.py): `api/app.py`
- [Gradio Interface](https://github.com/ankits1802/ragamala-painting-generator/blob/main/frontend/gradio_app.py): `frontend/gradio_app.py`
- [Streamlit Interface](https://github.com/ankits1802/ragamala-painting-generator/blob/main/frontend/streamlit_app.py): `frontend/streamlit_app.py`
- [AWS Utilities](https://github.com/ankits1802/ragamala-painting-generator/blob/main/src/utils/aws_utils.py): `src/utils/aws_utils.py`

### Other components

- **User**

## Connections

- Artwork Collection → Image Preprocessing: prepares images
- Image Preprocessing → Cultural Annotation: enriches data
- Cultural Annotation → Training Dataset: labels examples
- Training Orchestrator → Training Dataset: loads data (evidence: `src/training/trainer.py`)
- Training Orchestrator → SDXL LoRA: initializes model (evidence: `src/training/trainer.py`)
- Training Orchestrator → Training Losses: uses loss (evidence: `src/training/trainer.py`)
- Training Orchestrator → Diffusion Scheduler: creates scheduler (evidence: `src/training/trainer.py`)
- Training Orchestrator → Training Callbacks: initializes callbacks (evidence: `src/training/trainer.py`)
- SDXL LoRA → Training Dataset: loads datasets (evidence: `src/models/sdxl_lora.py`)
- Ragamala Generator → Prompt Encoder: encodes prompts (evidence: `src/inference/generator.py`)
- Ragamala Generator → Diffusion Scheduler: uses scheduler (evidence: `src/inference/generator.py`)
- Ragamala Generator → Prompt Templates: uses templates
- Ragamala Generator → Image Postprocessing: postprocesses images
- Generation API → Ragamala Generator: generates images (evidence: `api/routes/generate.py`)
- Generation API → Image Metrics: calculates metrics (evidence: `api/routes/generate.py`)
- Generation API → Cultural Evaluator: assesses culture (evidence: `api/routes/generate.py`)
- Generation API → API Schemas: uses schemas (evidence: `api/routes/generate.py`)
- Generation API → API Authentication: verifies credentials (evidence: `api/routes/generate.py`)
- API Application → Generation API: mounts routes (evidence: `api/app.py`)
- API Application → Rate Limiting: configures limits (evidence: `api/app.py`)
- Streamlit Interface → Generation API: calls API (evidence: `frontend/streamlit_app.py`)
- User → Streamlit Interface: uses interface
- User → Gradio Interface: uses interface
- User → Generation API: submits requests
- Training Callbacks → Image Metrics: uses metrics (evidence: `src/training/callbacks.py`)
- Training Callbacks → Result Visualization: uses visualizations (evidence: `src/training/callbacks.py`)
- API Application → AWS Utilities: uses cloud utilities (evidence: `api/app.py`)
- Human Evaluation → Image Metrics: complements scoring
