# neptune-glitch/air-quality-openenv architecture

> Architecture diagram of the GitHub repository neptune-glitch/air-quality-openenv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/neptune-glitch/air-quality-openenv
- Repository: https://github.com/neptune-glitch/air-quality-openenv

## Overview

Air Quality Env is an OpenEnv-compatible reinforcement-learning simulation for industrial emissions control. A user can run episodes through the CLI or web service: an action policy reads the current AQI state, chooses an intervention, and the environment applies it, returns an observation and reward, and checks whether the target was reached. Difficulty levels alter starting AQI and target thresholds. The web runner can use an OpenAI-compatible model, with a heuristic fallback. The graph reflects the sampled runtime files and README; no separate storage subsystem is evident.

Main entry points: [`env.py`](https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py) (AQI environment), [`inference.py`](https://github.com/neptune-glitch/air-quality-openenv/blob/main/inference.py) (CLI episode runner), [`server/app.py`](https://github.com/neptune-glitch/air-quality-openenv/blob/main/server/app.py) (Web API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Agent interaction"]
  node_policy["Action policy<br/>[inference.py]"]
  node_web_policy["Web action policy<br/>[app.py]"]
end

subgraph group_simulation["Environment simulation"]
  node_environment["AQI environment<br/>[env.py]"]
  node_difficulty["Difficulty tasks<br/>[env.py]"]
  node_state_reward["State and reward<br/>[env.py]"]
  node_observation["Observation and score<br/>[env.py]"]
end

subgraph group_interfaces["Runtime interfaces"]
  node_cli["CLI episode runner<br/>[inference.py]"]
  node_web["Web API<br/>[app.py]"]
end

node_user(("User"))
node_llm{{"OpenAI-compatible API"}}

node_user -->|"runs episodes"| node_cli
node_user -->|"requests endpoint"| node_web
node_cli -->|"requests action"| node_policy
node_policy -->|"requests completion"| node_llm
node_cli -->|"resets and steps"| node_environment
node_web -->|"requests action"| node_web_policy
node_web_policy -->|"requests completion"| node_llm
node_web -->|"resets and steps"| node_environment
node_environment -->|"selects task"| node_difficulty
node_environment -->|"applies action"| node_state_reward
node_state_reward -->|"builds observation"| node_observation

click node_cli "https://github.com/neptune-glitch/air-quality-openenv/blob/main/inference.py"
click node_web "https://github.com/neptune-glitch/air-quality-openenv/blob/main/server/app.py"
click node_policy "https://github.com/neptune-glitch/air-quality-openenv/blob/main/inference.py"
click node_web_policy "https://github.com/neptune-glitch/air-quality-openenv/blob/main/server/app.py"
click node_environment "https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py"
click node_difficulty "https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py"
click node_state_reward "https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py"
click node_observation "https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.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_policy,node_web_policy,node_user toneBlue
class node_environment,node_difficulty,node_state_reward,node_observation toneAmber
class node_cli,node_web,node_llm toneMint
```

## Components

### Agent interaction

- [Action policy](https://github.com/neptune-glitch/air-quality-openenv/blob/main/inference.py): `inference.py`
- [Web action policy](https://github.com/neptune-glitch/air-quality-openenv/blob/main/server/app.py): `server/app.py`

### Environment simulation

- [AQI environment](https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py): `env.py`
- [Difficulty tasks](https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py): `env.py`
- [State and reward](https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py): `env.py`
- [Observation and score](https://github.com/neptune-glitch/air-quality-openenv/blob/main/env.py): `env.py`

### Runtime interfaces

- [CLI episode runner](https://github.com/neptune-glitch/air-quality-openenv/blob/main/inference.py): `inference.py`
- [Web API](https://github.com/neptune-glitch/air-quality-openenv/blob/main/server/app.py): `server/app.py`

### Other components

- **User**
- **OpenAI-compatible API**

## Connections

- User → CLI episode runner: runs episodes (evidence: `README.md`)
- User → Web API: requests endpoint (evidence: `README.md`)
- CLI episode runner → Action policy: requests action (evidence: `inference.py`)
- Action policy → OpenAI-compatible API: requests completion (evidence: `inference.py`)
- CLI episode runner → AQI environment: resets and steps (evidence: `inference.py`)
- Web API → Web action policy: requests action (evidence: `server/app.py`)
- Web action policy → OpenAI-compatible API: requests completion (evidence: `server/app.py`)
- Web API → AQI environment: resets and steps (evidence: `server/app.py`)
- AQI environment → Difficulty tasks: selects task (evidence: `env.py`)
- AQI environment → State and reward: applies action (evidence: `env.py`)
- State and reward → Observation and score: builds observation (evidence: `env.py`)
