# afngh/dynamo architecture

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

- Interactive diagram: https://gitdiagram.com/afngh/dynamo
- Repository: https://github.com/afngh/dynamo

## Overview

Dynamo is a custom PyTorch language model with a Django SSE backend and React chat interface. The principal workflow is user sign-in, prompt submission, model generation, and streamed token display; a separate documented workflow trains and checkpoints the model. The graph also preserves tokenizer, transformer, sampling, and UI subsystems. Several runtime files were not excerpted, so links based on README documentation are identified as such; uncertain internal routing is omitted.

Main entry points: [`main/config/_model_config.py`](https://github.com/afngh/dynamo/blob/dynamo/main/config/_model_config.py) (Model configuration), [`frontend/src/App.jsx`](https://github.com/afngh/dynamo/blob/dynamo/frontend/src/App.jsx) (Chat app), [`main/fine_tune/_fine_tune_model.py`](https://github.com/afngh/dynamo/blob/dynamo/main/fine_tune/_fine_tune_model.py) (Incremental training), [`main/model.py`](https://github.com/afngh/dynamo/blob/dynamo/main/model.py) (Model example)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Chat frontend"]
  node_app["Chat app<br/>[App.jsx]"]
  node_auth["Sign-in screen<br/>[AuthLanding.jsx]"]
  node_chatparts["Chat components<br/>[Message.jsx]"]
  node_settings["Model settings<br/>[SettingsPanel.jsx]"]
end

subgraph group_serve["Streaming service"]
  node_django["Django service<br/>[settings.py]"]
  node_stream["SSE handler<br/>[views.py]"]
end

subgraph group_inference["Model inference"]
  node_loader["Inference loader<br/>[load.py]"]
  node_handler["Model handler"]
  node_sampling["Text generation<br/>[_generator_api.py]"]
  node_tokenizer["GPT-2 tokenizer<br/>[_gpt2_tokenizer.py]"]
  node_bytecodec["Byte codec<br/>[_byte_codec.py]"]
end

subgraph group_training["Model training"]
  node_trainentry["Training entry<br/>[train.py]"]
  node_finetune["Incremental training"]
  node_checkpoint["Checkpoint storage<br/>[_model_save.py]"]
end

subgraph group_architecture["Transformer engine"]
  node_config["Model configuration<br/>[_model_config.py]"]
  node_model["Transformer model<br/>[_model_orc.py]"]
  node_embedding["Token embedding<br/>[_embedding.py]"]
  node_position["Position encoding"]
  node_attention["Causal attention<br/>[_attention.py]"]
  node_block["Transformer block"]
  node_feedforward["SwiGLU and norm<br/>[_post_attention.py]"]
  node_output["Transformer output<br/>[_transformer.py]"]
  node_legacy["Model example<br/>[model.py]"]
end

node_user(("Chat user"))
node_supabase["Supabase auth<br/>[supabaseClient.js]"]
node_hub[("Hugging Face Hub")]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_auth
node_app -->|"renders"| node_chatparts
node_app -->|"renders"| node_settings
node_app -->|"authenticates"| node_supabase
node_app -->|"requests SSE"| node_stream
node_stream -->|"loads model"| node_loader
node_loader -.->|"loads checkpoint"| node_handler
node_handler -.->|"configures generator"| node_sampling
node_sampling -->|"encodes prompt"| node_tokenizer
node_sampling -.->|"runs inference"| node_model
node_trainentry -->|"starts training"| node_finetune
node_finetune -->|"encodes text"| node_tokenizer
node_finetune -->|"configures training"| node_config
node_finetune -->|"builds model"| node_model
node_finetune -->|"syncs checkpoint"| node_hub
node_finetune -.->|"saves checkpoint"| node_checkpoint
node_config -->|"creates"| node_embedding
node_config -->|"creates"| node_position
node_config -->|"creates"| node_attention
node_config -->|"creates"| node_block
node_config -->|"creates"| node_feedforward
node_config -->|"creates"| node_output
node_legacy -->|"imports"| node_bytecodec
node_legacy -->|"imports"| node_tokenizer
node_legacy -->|"imports"| node_sampling
node_legacy -->|"imports"| node_checkpoint

click node_app "https://github.com/afngh/dynamo/blob/dynamo/frontend/src/App.jsx"
click node_auth "https://github.com/afngh/dynamo/blob/dynamo/frontend/src/components/AuthLanding.jsx"
click node_chatparts "https://github.com/afngh/dynamo/blob/dynamo/frontend/src/components/Message.jsx"
click node_settings "https://github.com/afngh/dynamo/blob/dynamo/frontend/src/components/SettingsPanel.jsx"
click node_supabase "https://github.com/afngh/dynamo/blob/dynamo/frontend/src/supabaseClient.js"
click node_django "https://github.com/afngh/dynamo/blob/dynamo/api/settings.py"
click node_stream "https://github.com/afngh/dynamo/blob/dynamo/stream/views.py"
click node_loader "https://github.com/afngh/dynamo/blob/dynamo/main/load.py"
click node_handler "https://github.com/afngh/dynamo/blob/dynamo/main/generator_config/_load_config_and_model.py"
click node_sampling "https://github.com/afngh/dynamo/blob/dynamo/main/generator_config/_generator_api.py"
click node_tokenizer "https://github.com/afngh/dynamo/blob/dynamo/main/seq2seq/_gpt2_tokenizer.py"
click node_trainentry "https://github.com/afngh/dynamo/blob/dynamo/main/train.py"
click node_finetune "https://github.com/afngh/dynamo/blob/dynamo/main/fine_tune/_fine_tune_model.py"
click node_checkpoint "https://github.com/afngh/dynamo/blob/dynamo/main/save_trained/_model_save.py"
click node_config "https://github.com/afngh/dynamo/blob/dynamo/main/config/_model_config.py"
click node_model "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_model_orc.py"
click node_embedding "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_embedding.py"
click node_position "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_positional_embedding.py"
click node_attention "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_attention.py"
click node_block "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_transformer_block.py"
click node_feedforward "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_post_attention.py"
click node_output "https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_transformer.py"
click node_bytecodec "https://github.com/afngh/dynamo/blob/dynamo/main/seq2seq/_byte_codec.py"
click node_legacy "https://github.com/afngh/dynamo/blob/dynamo/main/model.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_auth,node_chatparts,node_settings,node_user toneBlue
class node_django,node_stream,node_hub toneAmber
class node_loader,node_handler,node_sampling,node_tokenizer,node_bytecodec toneMint
class node_trainentry,node_finetune,node_checkpoint toneRose
class node_config,node_model,node_embedding,node_position,node_attention,node_block,node_feedforward,node_output,node_legacy toneIndigo
class node_supabase toneTeal
```

## Components

### Chat frontend

- [Chat app](https://github.com/afngh/dynamo/blob/dynamo/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in screen](https://github.com/afngh/dynamo/blob/dynamo/frontend/src/components/AuthLanding.jsx): `frontend/src/components/AuthLanding.jsx`
- [Chat components](https://github.com/afngh/dynamo/blob/dynamo/frontend/src/components/Message.jsx): `frontend/src/components/Message.jsx`
- [Model settings](https://github.com/afngh/dynamo/blob/dynamo/frontend/src/components/SettingsPanel.jsx): `frontend/src/components/SettingsPanel.jsx`

### Streaming service

- [Django service](https://github.com/afngh/dynamo/blob/dynamo/api/settings.py): `api/settings.py`
- [SSE handler](https://github.com/afngh/dynamo/blob/dynamo/stream/views.py): `stream/views.py`

### Model inference

- [Inference loader](https://github.com/afngh/dynamo/blob/dynamo/main/load.py): `main/load.py`
- [Model handler](https://github.com/afngh/dynamo/blob/dynamo/main/generator_config/_load_config_and_model.py): `main/generator_config/_load_config_and_model.py`
- [Text generation](https://github.com/afngh/dynamo/blob/dynamo/main/generator_config/_generator_api.py): `main/generator_config/_generator_api.py`
- [GPT-2 tokenizer](https://github.com/afngh/dynamo/blob/dynamo/main/seq2seq/_gpt2_tokenizer.py): `main/seq2seq/_gpt2_tokenizer.py`
- [Byte codec](https://github.com/afngh/dynamo/blob/dynamo/main/seq2seq/_byte_codec.py): `main/seq2seq/_byte_codec.py`

### Model training

- [Training entry](https://github.com/afngh/dynamo/blob/dynamo/main/train.py): `main/train.py`
- [Incremental training](https://github.com/afngh/dynamo/blob/dynamo/main/fine_tune/_fine_tune_model.py): `main/fine_tune/_fine_tune_model.py`
- [Checkpoint storage](https://github.com/afngh/dynamo/blob/dynamo/main/save_trained/_model_save.py): `main/save_trained/_model_save.py`

### Transformer engine

- [Model configuration](https://github.com/afngh/dynamo/blob/dynamo/main/config/_model_config.py): `main/config/_model_config.py`
- [Transformer model](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_model_orc.py): `main/transformer_orch/_model_orc.py`
- [Token embedding](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_embedding.py): `main/transformer_orch/_embedding.py`
- [Position encoding](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_positional_embedding.py): `main/transformer_orch/_positional_embedding.py`
- [Causal attention](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_attention.py): `main/transformer_orch/_attention.py`
- [Transformer block](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_transformer_block.py): `main/transformer_orch/_transformer_block.py`
- [SwiGLU and norm](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_post_attention.py): `main/transformer_orch/_post_attention.py`
- [Transformer output](https://github.com/afngh/dynamo/blob/dynamo/main/transformer_orch/_transformer.py): `main/transformer_orch/_transformer.py`
- [Model example](https://github.com/afngh/dynamo/blob/dynamo/main/model.py): `main/model.py`

### Other components

- **Chat user**
- [Supabase auth](https://github.com/afngh/dynamo/blob/dynamo/frontend/src/supabaseClient.js): `frontend/src/supabaseClient.js`
- **Hugging Face Hub**

## Connections

- Chat user → Chat app: uses (evidence: `README.md`)
- Chat app → Sign-in screen: renders (evidence: `frontend/src/App.jsx`)
- Chat app → Chat components: renders (evidence: `frontend/src/App.jsx`)
- Chat app → Model settings: renders (evidence: `frontend/src/App.jsx`)
- Chat app → Supabase auth: authenticates (evidence: `frontend/src/App.jsx`)
- Chat app → SSE handler: requests SSE (evidence: `README.md`)
- SSE handler → Inference loader: loads model (evidence: `stream/views.py`)
- Inference loader → Model handler: loads checkpoint
- Model handler → Text generation: configures generator
- Text generation → GPT-2 tokenizer: encodes prompt (evidence: `main/generator_config/_generator_api.py`)
- Text generation → Transformer model: runs inference
- Training entry → Incremental training: starts training (evidence: `README.md`)
- Incremental training → GPT-2 tokenizer: encodes text (evidence: `main/fine_tune/_fine_tune_model.py`)
- Incremental training → Model configuration: configures training (evidence: `main/fine_tune/_fine_tune_model.py`)
- Incremental training → Transformer model: builds model (evidence: `main/fine_tune/_fine_tune_model.py`)
- Incremental training → Hugging Face Hub: syncs checkpoint (evidence: `main/fine_tune/_fine_tune_model.py`)
- Incremental training → Checkpoint storage: saves checkpoint
- Model configuration → Token embedding: creates (evidence: `main/config/_model_config.py`)
- Model configuration → Position encoding: creates (evidence: `main/config/_model_config.py`)
- Model configuration → Causal attention: creates (evidence: `main/config/_model_config.py`)
- Model configuration → Transformer block: creates (evidence: `main/config/_model_config.py`)
- Model configuration → SwiGLU and norm: creates (evidence: `main/config/_model_config.py`)
- Model configuration → Transformer output: creates (evidence: `main/config/_model_config.py`)
- Model example → Byte codec: imports (evidence: `main/model.py`)
- Model example → GPT-2 tokenizer: imports (evidence: `main/model.py`)
- Model example → Text generation: imports (evidence: `main/model.py`)
- Model example → Checkpoint storage: imports (evidence: `main/model.py`)
