# havishalterx-eng/alter-x-4- architecture

> Architecture diagram of the GitHub repository havishalterx-eng/alter-x-4-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/havishalterx-eng/alter-x-4-
- Repository: https://github.com/havishalterx-eng/alter-x-4-

## Overview

#### 1. Purpose and system shape
ALTERX is a multi-tenant autonomous execution platform with Workflow Mode (business workflows) and Project Mode (software delivery). It is a monorepo containing TypeScript/NestJS services, Python/FastAPI-style engine services, a browser client, shared contracts, and AWS infrastructure. The central design is a Platform control plane calling a separately bounded Engine.

Key roots: `apps/`, `packages/contracts/`, `infrastructure/terraform/`.

#### 2. Entry points and external boundary
The main user-facing boundary is the Platform API, backed by the web SPA. The API handles identity, tenancy/RBAC, product CRUD, billing, integrations, and forwards engine requests through dedicated facades/clients. The web client provides workflow building, projects, runs, knowledge, operations, and admin surfaces.

Paths: `apps/platform-api/src/main.ts`, `apps/platform-api/src/app.module.ts`, `apps/platform-web/src/main.tsx`.

#### 3. Workflow and project control plane
The orchestration service is the Engine’s durable system of record for workflows, triggers, conversations, projects, runs, artifacts, approvals, execution checkpoints, recovery, and deployment state. It compiles workflow/architecture inputs into executable DAGs, launches and observes runs, and exposes gRPC seams to execution services.

Primary flow: Platform API → orchestration APIs/facades → graph compiler → durable run queue → node execution → persisted run events/outcomes.

Paths: `apps/orchestration-service/src/compiler/graph-compiler.service.ts`, `apps/orchestration-service/src/runs/run-launcher.service.ts`, `apps/orchestration-service/src/registry/nodeexec.service.ts`.

#### 4. Planning, capability binding, and execution graph
Intelligence Service turns problem understanding into plans and resolves available capabilities/agents. Its planner and architecture synthesizer feed binding decisions that the orchestration compiler converts to DAG nodes. This is the primary planning boundary for downstream graph work.

Paths: `apps/intelligence-service/src/planner/kernel.py`, `apps/intelligence-service/src/architecture_synthesizer/service.py`, `apps/intelligence-service/src/selection_binding/engine.py`.

#### 5. Controlled execution gateways and workers
Node execution is deliberately mediated: Model Gateway is the only intended LLM-provider route; Tool Gateway is the external-tool route; Sandbox Service handles code execution; Verification evaluates outputs. Background workers host Temporal consumers, schedulers, and executor-related processing, separating asynchronous work from request-serving services.

Paths: `apps/model-gateway/src/gateway/model-gateway.service.ts`, `apps/tool-gateway/src/gateway/tool-gateway.service.ts`, `apps/background-workers/src/platform-jobs/handlers.ts`.

#### 6. Knowledge, memory, evaluation, and governance loop
ADS Core ingests connector/upload content, normalizes/chunks/embeds it, applies source/document permissions, and serves retrieval. Memory Service stores policy and learned memory, delivers policy data, and detects drift using intelligence and cost signals. Eval Service orchestrates golden-set, red-team, chaos, and promotion-gate evidence. Audit and deletion services provide cross-system accountability and right-to-delete orchestration.

Paths: `apps/ads-core/src/ingestion/pipeline.py`, `apps/memory-service/src/drift/detector.py`, `apps/eval-service/src/execution/orchestrator.py`.

#### 7. Contracts, persistence, runtime, and infrastructure
`packages/contracts` is the shared API/proto/schema authority; service-to-service communication uses generated gRPC contracts alongside HTTP boundaries. PostgreSQL-backed service stores use Drizzle (TypeScript) or Alembic (Python); object storage, queues/events, secrets, configuration, cache, and observability are represented through adapters. Terraform defines an eight-account AWS deployment in `ap-south-1`; local development includes Docker Compose, LocalStack, Grafana, and Tempo. Supported vendor integrations include AWS Bedrock/Titan, OpenAI, Anthropic, E2B/AgentCore sandboxes, Auth0/Google, Stripe/Razorpay, WhatsApp, and Temporal.

Paths: `packages/contracts/proto/alter/compiler/v1/compiler.proto`, `packages/adapters/src/temporal/durable-execution-provider.ts`, `infrastructure/terraform/modules/environment/main.tf`.

Main entry points: [`apps/platform-api/src/main.ts`](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-api/src/main.ts) (Platform API), [`apps/orchestration-service/src/registry/nodeexec.service.ts`](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/registry/nodeexec.service.ts) (Node Execution), [`apps/orchestration-service/src/runs/run-launcher.service.ts`](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/runs/run-launcher.service.ts) (Run Launcher), [`apps/intelligence-service/src/planner/kernel.py`](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/planner/kernel.py) (Intelligence Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform Control Plane"]
  node_web["Platform Web<br/>SPA<br/>[main.tsx]"]
  node_platform_api["Platform API<br/>NestJS API<br/>[main.ts]"]
  node_platform_module["Platform Modules<br/>NestJS composition<br/>[app.module.ts]"]
end

subgraph group_engine["Engine"]
  node_intelligence["Intelligence Service<br/>planning service<br/>[kernel.py]"]
  node_architecture_synthesizer["Architecture Synthesizer<br/>planning layer<br/>[service.py]"]
  node_capability_binding["Capability Binding<br/>selection engine<br/>[engine.py]"]
  node_graph_compiler["Graph Compiler<br/>DAG compiler"]
  node_run_launcher["Run Launcher<br/>orchestration service"]
  node_node_execution["Node Execution<br/>execution registry"]
  node_model_gateway["Model Gateway<br/>LLM gateway"]
  node_tool_gateway["Tool Gateway"]
  node_workers["Background Workers<br/>async workers<br/>[handlers.ts]"]
end

subgraph group_governance["Knowledge &amp; Governance"]
  node_ads["ADS Core<br/>knowledge ingestion<br/>[pipeline.py]"]
  node_memory["Memory Service<br/>policy memory<br/>[detector.py]"]
  node_evaluation["Eval Service<br/>evaluation orchestration<br/>[orchestrator.py]"]
end

subgraph group_runtime["Shared Runtime"]
  node_contracts["Shared Contracts<br/>proto/schema authority<br/>[compiler.proto]"]
  node_durable_execution["Durable Execution Adapter<br/>Temporal adapter"]
  node_aws{{"AWS Environment<br/>Terraform infrastructure<br/>[main.tf]"}}
end

node_web -->|"HTTPS"| node_platform_api
node_platform_api -->|"composes"| node_platform_module
node_platform_api -->|"planning requests"| node_intelligence
node_platform_api -->|"Engine facade"| node_run_launcher
node_intelligence -->|"architecture synthesis"| node_architecture_synthesizer
node_intelligence -->|"capability resolution"| node_capability_binding
node_architecture_synthesizer -->|"architecture input"| node_graph_compiler
node_capability_binding -->|"bound capabilities"| node_graph_compiler
node_graph_compiler -->|"executable DAG"| node_run_launcher
node_run_launcher -->|"durable runs"| node_durable_execution
node_durable_execution -->|"dispatches async work"| node_workers
node_run_launcher -->|"launch nodes"| node_node_execution
node_node_execution -->|"model invocation"| node_model_gateway
node_node_execution -->|"tool invocation"| node_tool_gateway
node_node_execution -->|"retrieval"| node_ads
node_node_execution -->|"policy and memory"| node_memory
node_evaluation -->|"evaluation runs"| node_run_launcher
node_memory -.->|"drift signals"| node_intelligence
node_contracts -.->|"API schemas"| node_platform_api
node_contracts -.->|"compiler gRPC schema"| node_graph_compiler
node_aws -.->|"hosts"| node_platform_api
node_aws -.->|"runtime resources"| node_durable_execution

click node_web "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-web/src/main.tsx"
click node_platform_api "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-api/src/main.ts"
click node_platform_module "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-api/src/app.module.ts"
click node_intelligence "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/planner/kernel.py"
click node_architecture_synthesizer "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/architecture_synthesizer/service.py"
click node_capability_binding "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/selection_binding/engine.py"
click node_graph_compiler "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/compiler/graph-compiler.service.ts"
click node_run_launcher "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/runs/run-launcher.service.ts"
click node_node_execution "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/registry/nodeexec.service.ts"
click node_model_gateway "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/model-gateway/src/gateway/model-gateway.service.ts"
click node_tool_gateway "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/tool-gateway/src/gateway/tool-gateway.service.ts"
click node_workers "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/background-workers/src/platform-jobs/handlers.ts"
click node_ads "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/ads-core/src/ingestion/pipeline.py"
click node_memory "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/memory-service/src/drift/detector.py"
click node_evaluation "https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/eval-service/src/execution/orchestrator.py"
click node_contracts "https://github.com/havishalterx-eng/alter-x-4-/blob/main/packages/contracts/proto/alter/compiler/v1/compiler.proto"
click node_durable_execution "https://github.com/havishalterx-eng/alter-x-4-/blob/main/packages/adapters/src/temporal/durable-execution-provider.ts"
click node_aws "https://github.com/havishalterx-eng/alter-x-4-/blob/main/infrastructure/terraform/modules/environment/main.tf"

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_web,node_platform_api,node_platform_module toneBlue
class node_intelligence,node_architecture_synthesizer,node_capability_binding,node_graph_compiler,node_run_launcher,node_node_execution,node_model_gateway,node_tool_gateway,node_workers toneAmber
class node_ads,node_memory,node_evaluation toneMint
class node_contracts,node_durable_execution,node_aws toneRose
```

## Components

### Platform Control Plane

- [Platform Web](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-web/src/main.tsx): SPA · User surfaces for workflows, projects, runs, knowledge, operations, and admin. · `apps/platform-web/src/main.tsx`
- [Platform API](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-api/src/main.ts): NestJS API · Identity, tenancy, product, billing, integration, and Engine facades. · `apps/platform-api/src/main.ts`
- [Platform Modules](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/platform-api/src/app.module.ts): NestJS composition · Control-plane application wiring. · `apps/platform-api/src/app.module.ts`

### Engine

Durable planning and execution boundary.

- [Intelligence Service](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/planner/kernel.py): planning service · Synthesizes plans, architectures, and capability bindings. · `apps/intelligence-service/src/planner/kernel.py`
- [Architecture Synthesizer](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/architecture_synthesizer/service.py): planning layer · Produces architecture inputs for execution graphs. · `apps/intelligence-service/src/architecture_synthesizer/service.py`
- [Capability Binding](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/intelligence-service/src/selection_binding/engine.py): selection engine · Resolves available agents and capabilities. · `apps/intelligence-service/src/selection_binding/engine.py`
- [Graph Compiler](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/compiler/graph-compiler.service.ts): DAG compiler · Converts plans and bindings into executable DAG nodes. · `apps/orchestration-service/src/compiler/graph-compiler.service.ts`
- [Run Launcher](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/runs/run-launcher.service.ts): orchestration service · Launches and observes durable workflow and project runs. · `apps/orchestration-service/src/runs/run-launcher.service.ts`
- [Node Execution](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/orchestration-service/src/registry/nodeexec.service.ts): execution registry · gRPC seam between orchestration and execution services. · `apps/orchestration-service/src/registry/nodeexec.service.ts`
- [Model Gateway](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/model-gateway/src/gateway/model-gateway.service.ts): LLM gateway · Exclusive intended route to LLM providers. · `apps/model-gateway/src/gateway/model-gateway.service.ts`
- [Tool Gateway](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/tool-gateway/src/gateway/tool-gateway.service.ts): tool gateway · Controlled route to external tools and integrations. · `apps/tool-gateway/src/gateway/tool-gateway.service.ts`
- [Background Workers](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/background-workers/src/platform-jobs/handlers.ts): async workers · Temporal consumers, schedulers, and executor processing. · `apps/background-workers/src/platform-jobs/handlers.ts`

### Knowledge & Governance

- [ADS Core](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/ads-core/src/ingestion/pipeline.py): knowledge ingestion · Ingests, permission-filters, embeds, and retrieves source content. · `apps/ads-core/src/ingestion/pipeline.py`
- [Memory Service](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/memory-service/src/drift/detector.py): policy memory · Stores learned policy memory and detects drift. · `apps/memory-service/src/drift/detector.py`
- [Eval Service](https://github.com/havishalterx-eng/alter-x-4-/blob/main/apps/eval-service/src/execution/orchestrator.py): evaluation orchestration · Runs golden-set, red-team, chaos, and promotion evidence. · `apps/eval-service/src/execution/orchestrator.py`

### Shared Runtime

- [Shared Contracts](https://github.com/havishalterx-eng/alter-x-4-/blob/main/packages/contracts/proto/alter/compiler/v1/compiler.proto): proto/schema authority · Generated API and gRPC contract source. · `packages/contracts/proto/alter/compiler/v1/compiler.proto`
- [Durable Execution Adapter](https://github.com/havishalterx-eng/alter-x-4-/blob/main/packages/adapters/src/temporal/durable-execution-provider.ts): Temporal adapter · Provider boundary for durable execution. · `packages/adapters/src/temporal/durable-execution-provider.ts`
- [AWS Environment](https://github.com/havishalterx-eng/alter-x-4-/blob/main/infrastructure/terraform/modules/environment/main.tf): Terraform infrastructure · Eight-account ap-south-1 deployment runtime. · `infrastructure/terraform/modules/environment/main.tf`

## Connections

- Platform Web → Platform API: HTTPS
- Platform API → Platform Modules: composes
- Platform API → Intelligence Service: planning requests
- Platform API → Run Launcher: Engine facade
- Intelligence Service → Architecture Synthesizer: architecture synthesis
- Intelligence Service → Capability Binding: capability resolution
- Architecture Synthesizer → Graph Compiler: architecture input
- Capability Binding → Graph Compiler: bound capabilities
- Graph Compiler → Run Launcher: executable DAG
- Run Launcher → Durable Execution Adapter: durable runs
- Durable Execution Adapter → Background Workers: dispatches async work
- Run Launcher → Node Execution: launch nodes
- Node Execution → Model Gateway: model invocation
- Node Execution → Tool Gateway: tool invocation
- Node Execution → ADS Core: retrieval
- Node Execution → Memory Service: policy and memory
- Eval Service → Run Launcher: evaluation runs
- Memory Service → Intelligence Service: drift signals
- Shared Contracts → Platform API: API schemas
- Shared Contracts → Graph Compiler: compiler gRPC schema
- AWS Environment → Platform API: hosts
- AWS Environment → Durable Execution Adapter: runtime resources
