# adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine architecture

> Architecture diagram of the GitHub repository adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine
- Repository: https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine

## Overview

#### Purpose and Runtime

This is a full-stack MEC inference-offloading simulator. It models mobile thermal/battery telemetry, selects local SLM/NPU execution or cloud Gemini execution, and presents live status and responses in a React UI. The primary runtime is a unified Node/Express + Vite server on port 3000, with a separate Python backend present but not described as part of the primary launch path.

Key entry points: `server.ts`, `src/main.tsx`, `src/App.tsx`, `backend/main.py`.

#### Server and API Boundary

`server.ts` is the backend integration boundary: it hosts the frontend, exposes the WebSocket endpoint (`/ws`), runs telemetry simulation, evaluates offloading eligibility, and proxies cloud-model requests. It protects server-configured Gemini credentials from browser network access while allowing a user-provided key flow.

Relevant paths: `server.ts`, `.env.example`, `package.json`.

#### Real-Time Telemetry Stage

The server emits simulated device telemetry at approximately 1 Hz over a bidirectional WebSocket. Temperature and battery state are the control inputs for routing and are consumed by the browser to update the operational dashboard.

Relevant paths: `server.ts`, `src/App.tsx`.

#### Offloading Decision and Execution Paths

Routing is governed by hardware thresholds: local execution is selected at temperature ≤40°C and battery ≥15%; otherwise inference is offloaded to cloud/MEC. The local route represents zero-key, on-device SLM/NPU execution. The cloud route uses Gemini when an API key is available and falls back to a simulated cloud response when it is not.

The decision logic and cloud dispatch are server-side rather than browser-side.

Relevant paths: `server.ts`, `.env.example`.

#### Frontend Control Plane

The Vite/React client is the interactive monitoring and command surface. It opens the WebSocket connection, renders telemetry and route state, accepts inference prompts, and exposes user-facing settings/help surfaces. The application root is mounted through the standard Vite React bootstrap.

Relevant paths: `src/main.tsx`, `src/App.tsx`, `src/index.css`.

#### Credential and User Interaction Boundaries

The UI supports Gemini API-key entry via a modal; README states user-entered keys are retained in browser `localStorage`. Server-side environment configuration provides an alternate server key. The browser should not directly call Gemini; `server.ts` is the intended API proxy boundary.

Relevant paths: `src/components/ApiKeyModal.tsx`, `src/components/UserManualModal.tsx`, `.env.example`.

#### Build and Deployment Shape

Development runs the unified Node server plus Vite integration. Production builds frontend assets and bundles the server for Node execution. Dependencies are managed by npm/Bun lockfiles, TypeScript compiler settings, and Vite configuration.

Relevant paths: `package.json`, `vite.config.ts`, `tsconfig.json`, `bun.lock`.

#### Secondary Python Backend

A Python backend exists with its own dependency manifest, suggesting an alternate or experimental service path. Its relationship to the Node server is not established by the supplied README; treat it as a separate runtime until its code is inspected.

Relevant paths: `backend/main.py`, `backend/requirements.txt`.

Main entry points: [`server.ts`](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts) (Express + Vite Server), [`src/App.tsx`](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/App.tsx) (Dashboard & Prompt UI), [`.env.example`](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/.env.example) (Server Gemini Key), [`src/main.tsx`](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/main.tsx) (Vite React Bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_node["Unified Node Runtime"]
  node_node_server["Express + Vite Server<br/>Node entry point<br/>[server.ts]"]
  node_telemetry["Telemetry Simulator<br/>real-time stage<br/>[server.ts]"]
  node_routing{{"Offloading Decision<br/>routing policy<br/>[server.ts]"}}
  node_local_inference["Local SLM/NPU<br/>on-device route<br/>[server.ts]"]
  node_cloud_dispatch["Cloud Dispatch<br/>inference proxy<br/>[server.ts]"]
  node_ws["WebSocket /ws<br/>bidirectional API<br/>[server.ts]"]
  node_server_env["Server Gemini Key<br/>environment config<br/>[.env.example]"]
end

subgraph group_client["React Control Plane"]
  node_client_bootstrap["Vite React Bootstrap<br/>browser entry point<br/>[main.tsx]"]
  node_app["Dashboard &amp; Prompt UI<br/>React application<br/>[App.tsx]"]
  node_api_key_modal["API Key Modal<br/>credential UI<br/>[ApiKeyModal.tsx]"]
  node_user_manual["Help Surface<br/>React modal"]
end

subgraph group_cloud["Cloud Inference"]
  node_gemini{{"Gemini API<br/>cloud model"}}
  node_simulated_cloud["Simulated Cloud Response<br/>fallback<br/>[server.ts]"]
end

subgraph group_python["Secondary Python Runtime"]
  node_python_backend["Python Backend<br/>alternate service<br/>[main.py]"]
  node_python_requirements["Python Dependencies<br/>dependency manifest<br/>[requirements.txt]"]
end

node_build["Node Build &amp; Launch<br/>package scripts<br/>[package.json]"]
node_vite_config["Vite Integration<br/>build config<br/>[vite.config.ts]"]

node_build -->|"launches"| node_node_server
node_vite_config -->|"integrates frontend"| node_node_server
node_node_server -->|"exposes"| node_ws
node_node_server -->|"runs"| node_telemetry
node_telemetry -->|"streams state"| node_ws
node_ws -->|"receives prompts/state"| node_routing
node_routing -->|"≤40°C and ≥15% battery"| node_local_inference
node_routing -->|"otherwise offloads"| node_cloud_dispatch
node_server_env -.->|"provides server key"| node_cloud_dispatch
node_cloud_dispatch -->|"proxies keyed requests"| node_gemini
node_cloud_dispatch -->|"falls back without key"| node_simulated_cloud
node_client_bootstrap -->|"mounts"| node_app
node_app -->|"connects bidirectionally"| node_ws
node_api_key_modal -->|"supplies user key"| node_app
node_app -->|"opens"| node_user_manual
node_python_requirements -->|"defines dependencies"| node_python_backend

click node_node_server "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_telemetry "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_routing "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_local_inference "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_cloud_dispatch "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_ws "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_server_env "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/.env.example"
click node_client_bootstrap "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/main.tsx"
click node_app "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/App.tsx"
click node_api_key_modal "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/components/ApiKeyModal.tsx"
click node_user_manual "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/components/UserManualModal.tsx"
click node_simulated_cloud "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts"
click node_python_backend "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/backend/main.py"
click node_python_requirements "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/backend/requirements.txt"
click node_build "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/package.json"
click node_vite_config "https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/vite.config.ts"

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_node_server,node_telemetry,node_routing,node_local_inference,node_cloud_dispatch,node_ws,node_server_env toneBlue
class node_client_bootstrap,node_app,node_api_key_modal,node_user_manual toneAmber
class node_gemini,node_simulated_cloud toneMint
class node_python_backend,node_python_requirements toneRose
class node_build,node_vite_config toneNeutral
```

## Components

### Unified Node Runtime

Primary server and integration boundary.

- [Express + Vite Server](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): Node entry point · Hosts the client, WebSocket, routing, and cloud proxy. · `server.ts`
- [Telemetry Simulator](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): real-time stage · Emits temperature and battery state at about 1 Hz. · `server.ts`
- [Offloading Decision](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): routing policy · Uses temperature and battery thresholds to select execution. · `server.ts`
- [Local SLM/NPU](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): on-device route · Zero-key local execution when temperature ≤40°C and battery ≥15%. · `server.ts`
- [Cloud Dispatch](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): inference proxy · Uses a configured or user-provided Gemini key, else simulated response. · `server.ts`
- [WebSocket /ws](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): bidirectional API · `server.ts`
- [Server Gemini Key](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/.env.example): environment config · Alternate server-side credential source. · `.env.example`

### React Control Plane

Browser monitoring and command interface.

- [Vite React Bootstrap](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/main.tsx): browser entry point · `src/main.tsx`
- [Dashboard & Prompt UI](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/App.tsx): React application · Renders live state and sends inference prompts. · `src/App.tsx`
- [API Key Modal](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/components/ApiKeyModal.tsx): credential UI · Collects a user Gemini key retained in browser localStorage. · `src/components/ApiKeyModal.tsx`
- [Help Surface](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/src/components/UserManualModal.tsx): React modal · `src/components/UserManualModal.tsx`

### Cloud Inference

Server-mediated Gemini or simulated fallback.

- **Gemini API**: cloud model · Reached only through the server proxy.
- [Simulated Cloud Response](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/server.ts): fallback · Used when no Gemini API key is available. · `server.ts`

### Secondary Python Runtime

Separate alternate or experimental backend.

- [Python Backend](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/backend/main.py): alternate service · Relationship to the primary Node runtime is not established. · `backend/main.py`
- [Python Dependencies](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/backend/requirements.txt): dependency manifest · `backend/requirements.txt`

### Other components

- [Node Build & Launch](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/package.json): package scripts · Builds client assets and runs the unified server. · `package.json`
- [Vite Integration](https://github.com/adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine/blob/main/vite.config.ts): build config · `vite.config.ts`

## Connections

- Node Build & Launch → Express + Vite Server: launches
- Vite Integration → Express + Vite Server: integrates frontend
- Express + Vite Server → WebSocket /ws: exposes
- Express + Vite Server → Telemetry Simulator: runs
- Telemetry Simulator → WebSocket /ws: streams state
- WebSocket /ws → Offloading Decision: receives prompts/state
- Offloading Decision → Local SLM/NPU: ≤40°C and ≥15% battery
- Offloading Decision → Cloud Dispatch: otherwise offloads
- Server Gemini Key → Cloud Dispatch: provides server key
- Cloud Dispatch → Gemini API: proxies keyed requests
- Cloud Dispatch → Simulated Cloud Response: falls back without key
- Vite React Bootstrap → Dashboard & Prompt UI: mounts
- Dashboard & Prompt UI → WebSocket /ws: connects bidirectionally
- API Key Modal → Dashboard & Prompt UI: supplies user key
- Dashboard & Prompt UI → Help Surface: opens
- Python Dependencies → Python Backend: defines dependencies
