How adithyanm-2724/adaptive-edge-cloud-computation-offloading-engine works
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 Express + Vite Server · App.tsx Dashboard & Prompt UI · .env.example Server Gemini Key · main.tsx Vite React Bootstrap
Components 17
Unified Node Runtime
Primary server and integration boundary.
- Express + Vite Server · Hosts the client, WebSocket, routing, and cloud proxy.
server.ts - Telemetry Simulator · Emits temperature and battery state at about 1 Hz.
server.ts - Offloading Decision · Uses temperature and battery thresholds to select execution.
server.ts - Local SLM/NPU · Zero-key local execution when temperature ≤40°C and battery ≥15%.
server.ts - Cloud Dispatch · Uses a configured or user-provided Gemini key, else simulated response.
server.ts - WebSocket /ws
server.ts - Server Gemini Key · Alternate server-side credential source.
.env.example
React Control Plane
Browser monitoring and command interface.
- Vite React Bootstrap
src/main.tsx - Dashboard & Prompt UI · Renders live state and sends inference prompts.
src/App.tsx - API Key Modal · Collects a user Gemini key retained in browser localStorage.
src/components/ApiKeyModal.tsx - Help Surface
src/components/UserManualModal.tsx
Cloud Inference
Server-mediated Gemini or simulated fallback.
- Gemini API · Reached only through the server proxy.
- Simulated Cloud Response · Used when no Gemini API key is available.
server.ts
Secondary Python Runtime
Separate alternate or experimental backend.
- Python Backend · Relationship to the primary Node runtime is not established.
backend/main.py - Python Dependencies
backend/requirements.txt
Other components
- Node Build & Launch · Builds client assets and runs the unified server.
package.json - Vite Integration
vite.config.ts
Connections 16
- 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