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

# System architecture

## Runtime components

| Layer                 | Responsibility                                                        | Current operating role                                  |
| --------------------- | --------------------------------------------------------------------- | ------------------------------------------------------- |
| Web application       | User experience, localization, research views and account workflows   | Next.js research console                                |
| API                   | Identity, APIs, entitlements, orchestration and durable state         | FastAPI application                                     |
| PostgreSQL and Redis  | Tenant data, queue coordination, cache and durable records            | Application persistence and task infrastructure         |
| Workers and scheduler | Ingestion, reports, sync, alerts, delivery and queued research work   | Retry-aware background execution                        |
| Provider adapters     | Market, news, portfolio, model, billing and notification integrations | Explicit provider contracts and health states           |
| Research runner       | Restricted Python research jobs and result artifacts                  | Containerized runtime being production-validated        |
| Strategy runtime      | Backtests and PAPER/SHADOW lifecycle                                  | Separate runtime boundary; live execution is not active |

## Product data flow

```mermaid
flowchart LR
  A["Markets, news, options and portfolio sources"] --> B["Research Snapshot"]
  B --> C["Market Event and Asset Impact"]
  C --> D["User Portfolio Impact"]
  D --> E["Today / Ask / Reports / Alerts"]
  E --> F["Backtests and Strategy Versions"]
  F --> G["PAPER and SHADOW Runtime"]
```

## Design principles

* Keep provider keys and durable credentials server-side.
* Make source freshness and availability visible to users.
* Generate shared market intelligence once, then personalize user impact.
* Use idempotency for billing, reports, delivery, strategy runs and runtime projections.
* Keep research, PAPER and SHADOW state durable across worker or service restarts.
* Do not represent fallback or mock data as live production data.
* Treat automatic execution and custody as separate future product domains, not as aliases for research or paper trading.


---

# 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://puregamma-ai.gitbook.io/puregamma-ai/puregamma-ai/platform-and-architecture/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.
