Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 371e7da

Browse files
author
DarkStarStrix
committed
Refactor NexaPod CLI structure and update Docker configurations
Signed-off-by: DarkStarStrix <allanw.mk@gmai.com>
1 parent 05ee36f commit 371e7da

17 files changed

Lines changed: 645 additions & 3757 deletions

File tree

.idea/copilotDiffState.xml

Lines changed: 30 additions & 172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 83 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Docs/ARCHITECTURE.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,46 @@ NEXAPod is a distributed compute fabric for scientific workloads. It coordinates
88

99
### High-Level Component Diagram
1010

11-
```
12-
┌─────────────────────────────────────────────────────────────────┐
13-
│ NEXAPod System │
14-
├─────────────────────────────────────────────────────────────────┤
15-
│ Frontend Layer │
16-
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
17-
│ │ Dashboard │ │ Contributor Wall│ │ API Client │ │
18-
│ │ (Streamlit) │ │ (HTML) │ │ (REST/CLI) │ │
19-
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
20-
├─────────────────────────────────────────────────────────────────┤
21-
│ API Layer │
22-
│ ┌─────────────────────────────────────────────────────────────┐ │
23-
│ │ REST API (Flask) │ │
24-
│ │ /register │ /submit-job │ /status │ /credits │ │
25-
│ └─────────────────────────────────────────────────────────────┘ │
26-
├─────────────────────────────────────────────────────────────────┤
27-
│ Core Engine │
28-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────┐ │
29-
│ │ Scheduler │ │ Validator │ │ Security │ │ Ledger │ │
30-
│ │ Queue │ │ Engine │ │ Manager │ │ System │ │
31-
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────┘ │
32-
├─────────────────────────────────────────────────────────────────┤
33-
│ Data Layer │
34-
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
35-
│ │ Node DB │ │ Job DB │ │ Credit DB │ │
36-
│ │ (SQLite) │ │ (SQLite) │ │ (SQLite) │ │
37-
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
38-
├─────────────────────────────────────────────────────────────────┤
39-
│ Execution Layer │
40-
│ ┌─────────────────────────────────────────────────────────────┐ │
41-
│ │ Container Runtime (Docker) │ │
42-
│ │ Input Fetcher │ Job Executor │ Output Archiver │ Logger │ │
43-
│ └─────────────────────────────────────────────────────────────┘ │
44-
└─────────────────────────────────────────────────────────────────┘
11+
```mermaid
12+
flowchart TD
13+
%% External Entry Point
14+
Users[Users & External Nodes]
15+
16+
%% Frontend Layer - Stacked horizontally
17+
subgraph Frontend ["Frontend Layer"]
18+
direction LR
19+
Dashboard[Dashboard<br/>Streamlit] --> Wall[Contributor Wall<br/>HTML/CSS/JS] --> Client[API Client<br/>REST/CLI]
20+
end
21+
22+
%% API Layer - Single component
23+
subgraph API ["API Layer"]
24+
Flask[REST API - Flask<br/>register • submit-job • status • credits]
25+
end
26+
27+
%% Core Engine - Flow between components
28+
subgraph Core ["Core Engine"]
29+
direction LR
30+
Scheduler[Job<br/>Scheduler] --> Validator[Result<br/>Validator] --> Security[Security<br/>Manager] --> Ledger[Credit<br/>Ledger]
31+
end
32+
33+
%% Data Layer - Connected databases
34+
subgraph Data ["Data Layer"]
35+
direction LR
36+
NodeDB[Node DB<br/>SQLite] --> JobDB[Job DB<br/>SQLite] --> CreditDB[Credit DB<br/>SQLite]
37+
end
38+
39+
%% Execution Layer - Process flow
40+
subgraph Execution ["Execution Layer"]
41+
direction LR
42+
Docker[Container Runtime<br/>Docker] --> Fetcher[Input<br/>Fetcher] --> Executor[Job<br/>Executor] --> Archiver[Output<br/>Archiver]
43+
end
44+
45+
%% Vertical connections between layers
46+
Users --> Frontend
47+
Frontend --> API
48+
API --> Core
49+
Core --> Data
50+
Core --> Execution
4551
```
4652

4753
### Detailed Dataflow

Infrastructure/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ def register():
1919
data = request.get_json()
2020
if not data or 'node_id' not in data or 'profile' not in data:
2121
return jsonify({"error": "Invalid registration data"}), 400
22-
22+
2323
node_id = data['node_id']
2424
profile = data['profile']
25-
25+
2626
db.store_node(node_id, json.dumps(profile))
2727
return jsonify({"status": "registered", "node_id": node_id})
2828

@@ -38,7 +38,7 @@ def get_job():
3838
if job:
3939
db.store_job(job)
4040
return jsonify(job)
41-
41+
4242
return jsonify({"status": "no_job_available"})
4343

4444

@@ -48,7 +48,7 @@ def submit_result():
4848
data = request.get_json()
4949
if not data or 'job_id' not in data or 'result' not in data:
5050
return jsonify({"error": "Invalid result submission"}), 400
51-
51+
5252
db.update_job_result(data['job_id'], json.dumps(data['result']))
5353
return jsonify({"status": "result_received", "job_id": data['job_id']})
5454

Infrastructure/perf_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Performance estimation utilities.
33
"""
4-
from nexapod.descriptor import JobDescriptor
4+
from NexaPod_CLI.descriptor import JobDescriptor
55

66

77
def estimate_flops(desc: JobDescriptor) -> float:

Infrastructure/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Container runner using Docker to execute jobs in isolation.
33
"""
44
import docker
5-
from nexapod.descriptor import JobDescriptor
5+
from NexaPod_CLI.descriptor import JobDescriptor
66

77

88
class ContainerRunner:

Infrastruture/Dockerfile.client

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ COPY ./safe_tensors /app/safe_tensors
1616
USER $APP_USER
1717
# The client is run via the nexapod CLI, which specifies the command.
1818
# We can have a default command for dashboard or runner.
19-
EXPOSE 8501
20-
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
21-
CMD curl -f http://localhost:8501/ || exit 1
22-
CMD ["streamlit", "run", "Client/dashboard.py"]
19+
CMD ["python", "-m", "Client.dashboard"]
20+

Infrastruture/Dockerfile.server

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ COPY ./Server /app/Server
1515

1616
USER $APP_USER
1717
EXPOSE 8000
18-
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
19-
CMD curl -f http://localhost:8000/ || exit 1
2018
CMD ["python", "-m", "Server.app"]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ def descriptor():
88
return JobDescriptor
99

1010

11-
def descriptor():
12-
return None
11+
def cli():
12+
"""
13+
Runs the CLI application.
14+
"""
15+
from .main import main
16+
main()

0 commit comments

Comments
 (0)