# code360-py/draft architecture

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

- Interactive diagram: https://gitdiagram.com/code360-py/draft
- Repository: https://github.com/code360-py/draft

## Overview

The repository appears to combine language-model inference and fine-tuning experiments with an image-generation workflow; the available excerpts do not establish a single user-facing product workflow. The tree also contains a web page and chat, room, device, and invoice data, but no README or sampled source shows how they are used, so they are shown without inferred connections. The training script train.py and index.html were not sampled; their roles are therefore left unspecified.

Main entry points: [`uctrain.py`](https://github.com/code360-py/draft/blob/main/uctrain.py) (Language training), [`main.py`](https://github.com/code360-py/draft/blob/main/main.py) (Model inference), [`imagellm.py`](https://github.com/code360-py/draft/blob/main/imagellm.py) (Image pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_language["Language models"]
  node_language_training["Language training<br/>[uctrain.py]"]
  node_training_data[("Training dataset<br/>[uctrain.py]")]
  node_prompt_formatting["Prompt formatting<br/>[uctrain.py]"]
  node_sft_training["SFT training<br/>[uctrain.py]"]
  node_adapter_save["Adapter saving<br/>[uctrain.py]"]
  node_model_inference["Model inference<br/>[main.py]"]
  node_prompt_tokenization["Prompt tokenization<br/>[main.py]"]
  node_text_streaming["Text streaming<br/>[main.py]"]
  node_alternate_inference["Alternate inference<br/>[ucllm.py]"]
  node_other_training["Other training script<br/>[train.py]"]
end

subgraph group_image["Image generation"]
  node_image_training["Image LoRA training<br/>[imagellm.py]"]
  node_image_pipeline["Image pipeline<br/>[imagellm.py]"]
  node_generated_image["Generated image<br/>[imagellm.py]"]
end

subgraph group_records["Web and records"]
  node_web_page["Web page<br/>[index.html]"]
  node_chat_records[("Chat records<br/>[general.json]")]
  node_device_records[("Device records<br/>[devices.json]")]
  node_invoice_records[("Invoice records<br/>[INV-1001.json]")]
  node_room_records[("Room records<br/>[general.ndjson]")]
end

node_user(("User"))

node_language_training -->|"loads"| node_training_data
node_language_training -->|"maps examples"| node_prompt_formatting
node_language_training -->|"trains"| node_sft_training
node_language_training -->|"saves model"| node_adapter_save
node_model_inference -->|"formats and tokenizes"| node_prompt_tokenization
node_model_inference -->|"streams output"| node_text_streaming
node_image_training -->|"loads LoRA"| node_image_pipeline
node_image_pipeline -->|"generates"| node_generated_image

click node_language_training "https://github.com/code360-py/draft/blob/main/uctrain.py"
click node_training_data "https://github.com/code360-py/draft/blob/main/uctrain.py"
click node_prompt_formatting "https://github.com/code360-py/draft/blob/main/uctrain.py"
click node_sft_training "https://github.com/code360-py/draft/blob/main/uctrain.py"
click node_adapter_save "https://github.com/code360-py/draft/blob/main/uctrain.py"
click node_model_inference "https://github.com/code360-py/draft/blob/main/main.py"
click node_prompt_tokenization "https://github.com/code360-py/draft/blob/main/main.py"
click node_text_streaming "https://github.com/code360-py/draft/blob/main/main.py"
click node_alternate_inference "https://github.com/code360-py/draft/blob/main/ucllm.py"
click node_other_training "https://github.com/code360-py/draft/blob/main/train.py"
click node_image_training "https://github.com/code360-py/draft/blob/main/imagellm.py"
click node_image_pipeline "https://github.com/code360-py/draft/blob/main/imagellm.py"
click node_generated_image "https://github.com/code360-py/draft/blob/main/imagellm.py"
click node_web_page "https://github.com/code360-py/draft/blob/main/index.html"
click node_chat_records "https://github.com/code360-py/draft/blob/main/chats/general.json"
click node_device_records "https://github.com/code360-py/draft/blob/main/data/devices.json"
click node_invoice_records "https://github.com/code360-py/draft/blob/main/invoices/INV-1001.json"
click node_room_records "https://github.com/code360-py/draft/blob/main/rooms/general.ndjson"

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_language_training,node_training_data,node_prompt_formatting,node_sft_training,node_adapter_save,node_model_inference,node_prompt_tokenization,node_text_streaming,node_alternate_inference,node_other_training,node_user toneBlue
class node_image_training,node_image_pipeline,node_generated_image toneAmber
class node_web_page,node_chat_records,node_device_records,node_invoice_records,node_room_records toneMint
```

## Components

### Language models

- [Language training](https://github.com/code360-py/draft/blob/main/uctrain.py): `uctrain.py`
- [Training dataset](https://github.com/code360-py/draft/blob/main/uctrain.py): `uctrain.py`
- [Prompt formatting](https://github.com/code360-py/draft/blob/main/uctrain.py): `uctrain.py`
- [SFT training](https://github.com/code360-py/draft/blob/main/uctrain.py): `uctrain.py`
- [Adapter saving](https://github.com/code360-py/draft/blob/main/uctrain.py): `uctrain.py`
- [Model inference](https://github.com/code360-py/draft/blob/main/main.py): `main.py`
- [Prompt tokenization](https://github.com/code360-py/draft/blob/main/main.py): `main.py`
- [Text streaming](https://github.com/code360-py/draft/blob/main/main.py): `main.py`
- [Alternate inference](https://github.com/code360-py/draft/blob/main/ucllm.py): `ucllm.py`
- [Other training script](https://github.com/code360-py/draft/blob/main/train.py): `train.py`

### Image generation

- [Image LoRA training](https://github.com/code360-py/draft/blob/main/imagellm.py): `imagellm.py`
- [Image pipeline](https://github.com/code360-py/draft/blob/main/imagellm.py): `imagellm.py`
- [Generated image](https://github.com/code360-py/draft/blob/main/imagellm.py): `imagellm.py`

### Web and records

- [Web page](https://github.com/code360-py/draft/blob/main/index.html): `index.html`
- [Chat records](https://github.com/code360-py/draft/blob/main/chats/general.json): `chats/general.json`
- [Device records](https://github.com/code360-py/draft/blob/main/data/devices.json): `data/devices.json`
- [Invoice records](https://github.com/code360-py/draft/blob/main/invoices/INV-1001.json): `invoices/INV-1001.json`
- [Room records](https://github.com/code360-py/draft/blob/main/rooms/general.ndjson): `rooms/general.ndjson`

### Other components

- **User**

## Connections

- Language training → Training dataset: loads (evidence: `uctrain.py`)
- Language training → Prompt formatting: maps examples (evidence: `uctrain.py`)
- Language training → SFT training: trains (evidence: `uctrain.py`)
- Language training → Adapter saving: saves model (evidence: `uctrain.py`)
- Model inference → Prompt tokenization: formats and tokenizes (evidence: `main.py`)
- Model inference → Text streaming: streams output (evidence: `main.py`)
- Image LoRA training → Image pipeline: loads LoRA (evidence: `imagellm.py`)
- Image pipeline → Generated image: generates (evidence: `imagellm.py`)
