# deepak00singh/gen-model-alignment-synthetic-worlds architecture

> Architecture diagram of the GitHub repository deepak00singh/gen-model-alignment-synthetic-worlds, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deepak00singh/gen-model-alignment-synthetic-worlds
- Repository: https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds

## Overview

Synthetic-Eval is a framework for measuring LLM generalization and alignment inside invented-rule worlds. A user selects a model, environment, and evaluation focus in the dashboard; the API initializes a model and environment, runs a sandbox step, and returns state and log data. The documented programmatic path also loads a scenario and scores generalization and adversarial alignment. The API excerpt currently returns mocked metrics, so its response should not be read as the full evaluator pipeline. Connections for unsampled evaluator and provider modules rely on README or SOURCE INDEX references.

Main entry points: [`src/api/routes.py`](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/routes.py) (Evaluation API), [`src/models/model_wrapper.py`](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/model_wrapper.py) (Model router), [`src/world_engine/sandbox.py`](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/sandbox.py) (Simulation sandbox), [`src/api/app.py`](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/app.py) (Flask application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_dashboard["Browser dashboard<br/>[index.html]"]
  node_app["Flask application<br/>[app.py]"]
  node_routes["Evaluation API<br/>[routes.py]"]
  node_auth["JWT authentication<br/>[auth.py]"]
  node_middleware["Request security<br/>[middlewares.py]"]
  node_extensions["Web extensions<br/>[extensions.py]"]
end

subgraph group_world["Synthetic worlds"]
  node_environment["Environment loader<br/>[environment.py]"]
  node_envdata["World definitions"]
  node_sandbox["Simulation sandbox<br/>[sandbox.py]"]
  node_rules["Rule engine<br/>[rule_engine.py]"]
  node_worldstate["Mutable world state<br/>[world_state.py]"]
end

subgraph group_eval["Evaluation"]
  node_scenarios["Evaluation scenarios"]
  node_alignment["Alignment scoring"]
  node_generalization["Generalization scoring"]
end

subgraph group_models["Model access"]
  node_modelwrap["Model router<br/>[model_wrapper.py]"]
  node_openai["OpenAI backend<br/>[openai_model.py]"]
  node_hf["HuggingFace backend<br/>[hf_model.py]"]
  node_anthropic["Anthropic backend<br/>[anthropic_model.py]"]
end

subgraph group_state["Persistence and utilities"]
  node_userdb[("User records<br/>[models.py]")]
  node_logger["Logging utilities<br/>[logging_utils.py]"]
end

node_user(("Dashboard user"))
node_provider(("LLM provider"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests evaluation"| node_routes
node_app -->|"registers"| node_routes
node_app -->|"registers"| node_auth
node_app -->|"applies headers"| node_middleware
node_app -->|"initializes"| node_extensions
node_routes -->|"validates input"| node_middleware
node_auth -->|"reads and writes"| node_userdb
node_auth -->|"uses services"| node_extensions
node_routes -->|"lists definitions"| node_envdata
node_routes -->|"loads environment"| node_environment
node_routes -.->|"selects model"| node_modelwrap
node_routes -->|"creates and steps"| node_sandbox
node_sandbox -->|"initializes"| node_rules
node_sandbox -->|"initializes"| node_worldstate
node_sandbox -->|"loads scenario"| node_scenarios
node_sandbox -->|"runs evaluator"| node_alignment
node_sandbox -->|"runs evaluator"| node_generalization
node_alignment -.->|"requests responses"| node_modelwrap
node_generalization -.->|"requests responses"| node_modelwrap
node_modelwrap -->|"routes calls"| node_openai
node_modelwrap -->|"routes calls"| node_hf
node_modelwrap -->|"routes calls"| node_anthropic
node_openai -->|"calls API"| node_provider
node_hf -.->|"calls provider"| node_provider
node_anthropic -.->|"calls provider"| node_provider
node_modelwrap -->|"logs through"| node_logger

click node_dashboard "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/templates/index.html"
click node_app "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/app.py"
click node_routes "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/routes.py"
click node_auth "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/auth.py"
click node_middleware "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/middlewares.py"
click node_extensions "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/extensions.py"
click node_environment "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/environment.py"
click node_envdata "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/tree/main/data/environments"
click node_scenarios "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/tree/main/data/scenarios"
click node_sandbox "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/sandbox.py"
click node_rules "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/rule_engine.py"
click node_worldstate "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/world_state.py"
click node_alignment "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/evaluators/alignment_evaluator.py"
click node_generalization "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/evaluators/generalization_evaluator.py"
click node_modelwrap "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/model_wrapper.py"
click node_openai "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/openai_model.py"
click node_hf "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/hf_model.py"
click node_anthropic "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/anthropic_model.py"
click node_userdb "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/models.py"
click node_logger "https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/utils/logging_utils.py"

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_dashboard,node_app,node_routes,node_auth,node_middleware,node_extensions,node_user toneBlue
class node_environment,node_envdata,node_sandbox,node_rules,node_worldstate toneAmber
class node_scenarios,node_alignment,node_generalization toneMint
class node_modelwrap,node_openai,node_hf,node_anthropic toneRose
class node_userdb,node_logger,node_provider toneIndigo
```

## Components

### Web application

- [Browser dashboard](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/templates/index.html): `src/api/templates/index.html`
- [Flask application](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/app.py): `src/api/app.py`
- [Evaluation API](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/routes.py): `src/api/routes.py`
- [JWT authentication](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/auth.py): `src/api/auth.py`
- [Request security](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/middlewares.py): `src/api/middlewares.py`
- [Web extensions](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/extensions.py): `src/api/extensions.py`

### Synthetic worlds

- [Environment loader](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/environment.py): `src/world_engine/environment.py`
- [World definitions](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/tree/main/data/environments): `data/environments`
- [Simulation sandbox](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/sandbox.py): `src/world_engine/sandbox.py`
- [Rule engine](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/rule_engine.py): `src/world_engine/rule_engine.py`
- [Mutable world state](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/world_engine/world_state.py): `src/world_engine/world_state.py`

### Evaluation

- [Evaluation scenarios](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/tree/main/data/scenarios): `data/scenarios`
- [Alignment scoring](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/evaluators/alignment_evaluator.py): `src/evaluators/alignment_evaluator.py`
- [Generalization scoring](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/evaluators/generalization_evaluator.py): `src/evaluators/generalization_evaluator.py`

### Model access

- [Model router](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/model_wrapper.py): `src/models/model_wrapper.py`
- [OpenAI backend](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/openai_model.py): `src/models/openai_model.py`
- [HuggingFace backend](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/hf_model.py): `src/models/hf_model.py`
- [Anthropic backend](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/models/anthropic_model.py): `src/models/anthropic_model.py`

### Persistence and utilities

- [User records](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/api/models.py): `src/api/models.py`
- [Logging utilities](https://github.com/deepak00singh/gen-model-alignment-synthetic-worlds/blob/main/src/utils/logging_utils.py): `src/utils/logging_utils.py`

### Other components

- **Dashboard user**
- **LLM provider**

## Connections

- Dashboard user → Browser dashboard: uses (evidence: `README.md`)
- Browser dashboard → Evaluation API: requests evaluation (evidence: `README.md`)
- Flask application → Evaluation API: registers (evidence: `src/api/app.py`)
- Flask application → JWT authentication: registers (evidence: `src/api/app.py`)
- Flask application → Request security: applies headers (evidence: `src/api/app.py`)
- Flask application → Web extensions: initializes (evidence: `src/api/app.py`)
- Evaluation API → Request security: validates input (evidence: `src/api/routes.py`)
- JWT authentication → User records: reads and writes (evidence: `src/api/auth.py`)
- JWT authentication → Web extensions: uses services (evidence: `src/api/auth.py`)
- Evaluation API → World definitions: lists definitions (evidence: `src/api/routes.py`)
- Evaluation API → Environment loader: loads environment (evidence: `src/api/routes.py`)
- Evaluation API → Model router: selects model
- Evaluation API → Simulation sandbox: creates and steps (evidence: `src/api/routes.py`)
- Simulation sandbox → Rule engine: initializes (evidence: `src/world_engine/sandbox.py`)
- Simulation sandbox → Mutable world state: initializes (evidence: `src/world_engine/sandbox.py`)
- Simulation sandbox → Evaluation scenarios: loads scenario (evidence: `README.md`)
- Simulation sandbox → Alignment scoring: runs evaluator (evidence: `src/world_engine/sandbox.py`)
- Simulation sandbox → Generalization scoring: runs evaluator (evidence: `src/world_engine/sandbox.py`)
- Alignment scoring → Model router: requests responses
- Generalization scoring → Model router: requests responses
- Model router → OpenAI backend: routes calls (evidence: `src/models/model_wrapper.py`)
- Model router → HuggingFace backend: routes calls (evidence: `src/models/model_wrapper.py`)
- Model router → Anthropic backend: routes calls (evidence: `src/models/model_wrapper.py`)
- OpenAI backend → LLM provider: calls API (evidence: `src/models/openai_model.py`)
- HuggingFace backend → LLM provider: calls provider
- Anthropic backend → LLM provider: calls provider
- Model router → Logging utilities: logs through (evidence: `src/models/model_wrapper.py`)
