# priyanshu4solanki/optimizing-resource-allocation-problem architecture

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

- Interactive diagram: https://gitdiagram.com/priyanshu4solanki/optimizing-resource-allocation-problem
- Repository: https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem

## Overview

This repository is an offline cloud-task allocation demo plus a live, folder-driven allocation service. The live workflow accepts a Python script, detects limited import-based dependencies, predicts resource needs, scores eligible workers, writes an assignment ticket, and collects execution results and feedback. The offline demo exercises the predictor–graph encoder–MARL placement pipeline; separate scripts prepare and train cloud-dataset models and export synthetic GNN data. Edges reflect README-documented behavior or shown source references; unsampled live internals are not expanded beyond those limits.

Main entry points: [`hub.py`](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/hub.py) (Hub API and watcher), [`main_engine.py`](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/main_engine.py) (Synthetic allocation demo), [`task_runner.py`](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/task_runner.py) (Ticket executor), [`task_predictors.py`](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/task_predictors.py) (Resource prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_live["Live allocation"]
  node_dashboard["Dashboard<br/>[dashboard.html]"]
  node_hub["Hub API and watcher<br/>[hub.py]"]
  node_dependency["Import dependency analysis"]
  node_agent["Worker telemetry agent<br/>[agent.py]"]
  node_runner["Ticket executor<br/>[task_runner.py]"]
  node_taskshare[("Task tickets and scripts")]
  node_resultshare[("Execution results")]
end

subgraph group_models["Allocation models"]
  node_predictor["Resource prediction<br/>[task_predictors.py]"]
  node_encoder["Task graph encoder<br/>[gnn_encoder.py]"]
  node_bridge["Candidate state builder"]
  node_scheduler["MARL placement policy<br/>[marl_scheduler.py]"]
  node_persistence["Model persistence"]
end

subgraph group_offline["Offline data and demo"]
  node_engine["Synthetic allocation demo<br/>[main_engine.py]"]
  node_dataset_prepare["Cloud dataset preparation"]
  node_dataset_train["Cloud model training"]
  node_synthetic_export["Synthetic GNN export"]
end

node_user(("Uploader"))
node_worker(("Worker machine"))

node_user -->|"uploads script"| node_dashboard
node_user -->|"drops script"| node_taskshare
node_dashboard -->|"submits upload"| node_hub
node_hub -->|"writes tickets"| node_taskshare
node_hub -->|"detects imports"| node_dependency
node_hub -->|"predicts resources"| node_predictor
node_hub -->|"encodes tasks"| node_encoder
node_hub -->|"builds candidate states"| node_bridge
node_hub -->|"selects assignments"| node_scheduler
node_hub -->|"loads models"| node_persistence
node_agent -->|"sends telemetry"| node_hub
node_worker -->|"runs agent"| node_agent
node_runner -->|"polls tickets"| node_taskshare
node_runner -->|"writes results"| node_resultshare
node_worker -->|"runs executor"| node_runner
node_runner -->|"reports completion"| node_hub
node_hub -->|"tracks output location"| node_resultshare
node_engine -->|"predicts resources"| node_predictor
node_engine -->|"encodes task graph"| node_encoder
node_engine -->|"builds joint state"| node_bridge
node_engine -->|"allocates tasks"| node_scheduler
node_engine -->|"saves checkpoints"| node_persistence
node_dataset_prepare -.->|"prepares training data"| node_dataset_train
node_synthetic_export -->|"generates estimates"| node_predictor
node_synthetic_export -->|"builds GNN inputs"| node_encoder

click node_dashboard "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/dashboard.html"
click node_hub "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/hub.py"
click node_dependency "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/ast_dependency_detector.py"
click node_agent "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/agent.py"
click node_runner "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/task_runner.py"
click node_predictor "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/task_predictors.py"
click node_encoder "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/gnn_encoder.py"
click node_bridge "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/marl_scheduler_bridge.py"
click node_scheduler "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/marl_scheduler.py"
click node_persistence "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/model_persistence.py"
click node_engine "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/main_engine.py"
click node_dataset_prepare "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/prepare_cloud_model_dataset.py"
click node_dataset_train "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/train_cloud_dataset.py"
click node_synthetic_export "https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/export_gnn_synthetic_dataset.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_dashboard,node_hub,node_dependency,node_agent,node_runner,node_taskshare,node_resultshare toneBlue
class node_predictor,node_encoder,node_bridge,node_scheduler,node_persistence toneAmber
class node_engine,node_dataset_prepare,node_dataset_train,node_synthetic_export toneMint
class node_user toneIndigo
class node_worker toneRose
```

## Components

### Live allocation

- [Dashboard](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/dashboard.html): `dashboard.html`
- [Hub API and watcher](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/hub.py): `hub.py`
- [Import dependency analysis](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/ast_dependency_detector.py): `ast_dependency_detector.py`
- [Worker telemetry agent](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/agent.py): `agent.py`
- [Ticket executor](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/task_runner.py): `task_runner.py`
- **Task tickets and scripts**
- **Execution results**

### Allocation models

- [Resource prediction](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/task_predictors.py): `task_predictors.py`
- [Task graph encoder](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/gnn_encoder.py): `gnn_encoder.py`
- [Candidate state builder](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/marl_scheduler_bridge.py): `marl_scheduler_bridge.py`
- [MARL placement policy](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/marl_scheduler.py): `marl_scheduler.py`
- [Model persistence](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/model_persistence.py): `model_persistence.py`

### Offline data and demo

- [Synthetic allocation demo](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/main_engine.py): `main_engine.py`
- [Cloud dataset preparation](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/prepare_cloud_model_dataset.py): `prepare_cloud_model_dataset.py`
- [Cloud model training](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/train_cloud_dataset.py): `train_cloud_dataset.py`
- [Synthetic GNN export](https://github.com/priyanshu4solanki/optimizing-resource-allocation-problem/blob/main/export_gnn_synthetic_dataset.py): `export_gnn_synthetic_dataset.py`

### Other components

- **Uploader**
- **Worker machine**

## Connections

- Uploader → Dashboard: uploads script (evidence: `README.md`)
- Uploader → Task tickets and scripts: drops script (evidence: `README.md`)
- Dashboard → Hub API and watcher: submits upload (evidence: `README.md`)
- Hub API and watcher → Task tickets and scripts: writes tickets (evidence: `README.md`)
- Hub API and watcher → Import dependency analysis: detects imports (evidence: `hub.py`)
- Hub API and watcher → Resource prediction: predicts resources (evidence: `hub.py`)
- Hub API and watcher → Task graph encoder: encodes tasks (evidence: `hub.py`)
- Hub API and watcher → Candidate state builder: builds candidate states (evidence: `hub.py`)
- Hub API and watcher → MARL placement policy: selects assignments (evidence: `hub.py`)
- Hub API and watcher → Model persistence: loads models (evidence: `hub.py`)
- Worker telemetry agent → Hub API and watcher: sends telemetry (evidence: `README.md`)
- Worker machine → Worker telemetry agent: runs agent (evidence: `README.md`)
- Ticket executor → Task tickets and scripts: polls tickets (evidence: `README.md`)
- Ticket executor → Execution results: writes results (evidence: `README.md`)
- Worker machine → Ticket executor: runs executor (evidence: `README.md`)
- Ticket executor → Hub API and watcher: reports completion (evidence: `README.md`)
- Hub API and watcher → Execution results: tracks output location (evidence: `README.md`)
- Synthetic allocation demo → Resource prediction: predicts resources (evidence: `main_engine.py`)
- Synthetic allocation demo → Task graph encoder: encodes task graph (evidence: `main_engine.py`)
- Synthetic allocation demo → Candidate state builder: builds joint state (evidence: `main_engine.py`)
- Synthetic allocation demo → MARL placement policy: allocates tasks (evidence: `main_engine.py`)
- Synthetic allocation demo → Model persistence: saves checkpoints (evidence: `main_engine.py`)
- Cloud dataset preparation → Cloud model training: prepares training data
- Synthetic GNN export → Resource prediction: generates estimates (evidence: `export_gnn_synthetic_dataset.py`)
- Synthetic GNN export → Task graph encoder: builds GNN inputs (evidence: `export_gnn_synthetic_dataset.py`)
