> For the complete documentation index, see [llms.txt](https://maha-strategies-llc.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maha-strategies-llc.gitbook.io/docs/core-concepts/system-architecture.md).

# System Architecture

The Maha OS infrastructure is built on a decoupled, edge-heavy paradigm. To preserve the Zero-Payload Policy while executing real-time kinetic interventions, the architecture distributes processing between a localized Android client (`com.maha.os`) and a secure, agentic backend.

***

### 1. The Agentic Core

The Agentic Core is the decision-making engine responsible for translating raw biological telemetry into structural UI interventions. It operates strictly as a transient evaluator, not a data repository.

* **Node.js & Render Proxy:** The backend utilizes a high-performance Node.js environment deployed via a Render proxy. This structure safely routes physiological state data without exposing client-side API keys or triggering rate limits associated with continuous polling.
* **Active Telemetry Evaluation:** Unlike standard habit trackers that simply log Resting Heart Rate (RHR) or Heart Rate Variability (HRV) into a database, the Agentic Core feeds these metrics into Gemini 2.5 Flash. The model evaluates the delta between the user's baseline and their current metabolic state.
* **Protocol Generation:** If an extractive algorithmic loop or physiological stress spike is detected, the AI generates a customized kinetic protocol (e.g., specific box breathing ratios) and fires a zero-latency WebSocket payload back to the client.

***

### 2. Edge Biometrics & Optical Intelligence

To ensure zero latency and absolute privacy for visual and localized biometric data, Maha OS pushes heavy compute to the edge.

* **On-Device Food Scanning:** The ecosystem features an optical intelligence pipeline for scanning food and analyzing ingredients. All image processing occurs strictly on-device.
* **Model Quantization:** To maintain the Zero-Payload Policy without inducing thermal throttling or severe battery drain on the Android device, the optical models are heavily quantized. This allows for rapid inference of complex visual data without a single byte leaving the localized node.

***

### 3. Package & Deployment

The Sovereign Client is deployed to the Google Play Console under the package name `com.maha.os`. To execute system-level cognitive defense, the application requires specific, high-level Android permissions that bridge health data with UI rendering.

#### Core Permission Matrix

* **`SYSTEM_ALERT_WINDOW`:** Critical for rendering the `z-[9999]` absolute overlay. This permission allows Maha OS to physically draw over other applications, enforcing the UI lockdown when a kinetic intervention is triggered.
* **`Health Connect API` / `Body Sensors`:** Required for the localized ingestion of RHR, continuous glucose monitoring (where applicable), and systemic readiness metrics.
* **`FOREGROUND_SERVICE`:** Enables adaptive background polling. The system relies on persistent WebSockets to receive instant commands from the Agentic Core without the OS terminating the connection to save memory.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://maha-strategies-llc.gitbook.io/docs/core-concepts/system-architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
