# itsluuis/life01 architecture

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

- Interactive diagram: https://gitdiagram.com/itsluuis/life01
- Repository: https://github.com/itsluuis/life01

## Overview

Life01 is an interactive artificial-life simulator. Its main workflow is launching the desktop app, advancing an evolutionary ecosystem cycle by cycle, and viewing the grid and population metrics; the engine also persists champion brains and telemetry. The README documents distinct ecology, combat, reproduction, settlement-building, and learning capabilities. The graph follows explicit source-index references and shown calls; some UI-to-engine data wiring is not visible in the excerpts, so it is not asserted.

Main entry points: [`simulation/simulation_engine.py`](https://github.com/itsluuis/life01/blob/main/simulation/simulation_engine.py) (Simulation engine), [`main.py`](https://github.com/itsluuis/life01/blob/main/main.py) (Application entry), [`simulation/combat.py`](https://github.com/itsluuis/life01/blob/main/simulation/combat.py) (Combat and predation), [`gui/app.py`](https://github.com/itsluuis/life01/blob/main/gui/app.py) (Main window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_entry["Application entry<br/>[main.py]"]
  node_engine["Simulation engine"]
end

subgraph group_ecology["Ecosystem simulation"]
  node_environment["World and resources<br/>[environment.py]"]
  node_cell["Cell castes<br/>[cell.py]"]
  node_monster["Predator behavior<br/>[monster.py]"]
  node_combat["Combat and predation<br/>[combat.py]"]
end

subgraph group_learning["Learning and persistence"]
  node_agent["Cell Q-learning<br/>[q_agent.py]"]
  node_brain_db[("Champion archive<br/>[brain_db.py]")]
  node_telemetry_db[("Telemetry store<br/>[telemetry_db.py]")]
end

subgraph group_interface["Desktop interface"]
  node_app["Main window<br/>[app.py]"]
  node_grid["World grid display<br/>[grid_canvas.py]"]
  node_stats["Stats and event feed<br/>[stats_panel.py]"]
end

node_user(("User"))

node_user -->|"launches"| node_entry
node_entry -->|"initializes"| node_brain_db
node_entry -->|"initializes"| node_telemetry_db
node_entry -->|"constructs"| node_engine
node_entry -->|"launches"| node_app
node_app -->|"uses"| node_engine
node_app -->|"builds"| node_grid
node_app -->|"builds"| node_stats
node_engine -->|"advances"| node_environment
node_engine -->|"updates"| node_cell
node_engine -->|"steps"| node_monster
node_engine -->|"resolves combat"| node_combat
node_engine -->|"saves champions"| node_brain_db
node_engine -->|"records metrics"| node_telemetry_db
node_cell -->|"owns brain"| node_agent
node_agent -->|"reads world state"| node_environment
node_combat -->|"resolves encounters"| node_cell
node_combat -->|"resolves encounters"| node_monster
node_combat -->|"attacks homes"| node_environment

click node_entry "https://github.com/itsluuis/life01/blob/main/main.py"
click node_engine "https://github.com/itsluuis/life01/blob/main/simulation/simulation_engine.py"
click node_environment "https://github.com/itsluuis/life01/blob/main/simulation/environment.py"
click node_cell "https://github.com/itsluuis/life01/blob/main/simulation/cell.py"
click node_monster "https://github.com/itsluuis/life01/blob/main/simulation/monster.py"
click node_combat "https://github.com/itsluuis/life01/blob/main/simulation/combat.py"
click node_agent "https://github.com/itsluuis/life01/blob/main/ai/q_agent.py"
click node_brain_db "https://github.com/itsluuis/life01/blob/main/database/brain_db.py"
click node_telemetry_db "https://github.com/itsluuis/life01/blob/main/database/telemetry_db.py"
click node_app "https://github.com/itsluuis/life01/blob/main/gui/app.py"
click node_grid "https://github.com/itsluuis/life01/blob/main/gui/grid_canvas.py"
click node_stats "https://github.com/itsluuis/life01/blob/main/gui/stats_panel.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_entry,node_engine,node_user toneBlue
class node_environment,node_cell,node_monster,node_combat toneAmber
class node_agent,node_brain_db,node_telemetry_db toneMint
class node_app,node_grid,node_stats toneRose
```

## Components

### Runtime orchestration

- [Application entry](https://github.com/itsluuis/life01/blob/main/main.py): `main.py`
- [Simulation engine](https://github.com/itsluuis/life01/blob/main/simulation/simulation_engine.py): `simulation/simulation_engine.py`

### Ecosystem simulation

- [World and resources](https://github.com/itsluuis/life01/blob/main/simulation/environment.py): `simulation/environment.py`
- [Cell castes](https://github.com/itsluuis/life01/blob/main/simulation/cell.py): `simulation/cell.py`
- [Predator behavior](https://github.com/itsluuis/life01/blob/main/simulation/monster.py): `simulation/monster.py`
- [Combat and predation](https://github.com/itsluuis/life01/blob/main/simulation/combat.py): `simulation/combat.py`

### Learning and persistence

- [Cell Q-learning](https://github.com/itsluuis/life01/blob/main/ai/q_agent.py): `ai/q_agent.py`
- [Champion archive](https://github.com/itsluuis/life01/blob/main/database/brain_db.py): `database/brain_db.py`
- [Telemetry store](https://github.com/itsluuis/life01/blob/main/database/telemetry_db.py): `database/telemetry_db.py`

### Desktop interface

- [Main window](https://github.com/itsluuis/life01/blob/main/gui/app.py): `gui/app.py`
- [World grid display](https://github.com/itsluuis/life01/blob/main/gui/grid_canvas.py): `gui/grid_canvas.py`
- [Stats and event feed](https://github.com/itsluuis/life01/blob/main/gui/stats_panel.py): `gui/stats_panel.py`

### Other components

- **User**

## Connections

- User → Application entry: launches (evidence: `README.md`)
- Application entry → Champion archive: initializes (evidence: `main.py`)
- Application entry → Telemetry store: initializes (evidence: `main.py`)
- Application entry → Simulation engine: constructs (evidence: `main.py`)
- Application entry → Main window: launches (evidence: `main.py`)
- Main window → Simulation engine: uses (evidence: `gui/app.py`)
- Main window → World grid display: builds (evidence: `gui/app.py`)
- Main window → Stats and event feed: builds (evidence: `gui/app.py`)
- Simulation engine → World and resources: advances (evidence: `simulation/simulation_engine.py`)
- Simulation engine → Cell castes: updates (evidence: `simulation/simulation_engine.py`)
- Simulation engine → Predator behavior: steps (evidence: `simulation/simulation_engine.py`)
- Simulation engine → Combat and predation: resolves combat (evidence: `simulation/simulation_engine.py`)
- Simulation engine → Champion archive: saves champions (evidence: `simulation/simulation_engine.py`)
- Simulation engine → Telemetry store: records metrics (evidence: `simulation/simulation_engine.py`)
- Cell castes → Cell Q-learning: owns brain (evidence: `simulation/cell.py`)
- Cell Q-learning → World and resources: reads world state (evidence: `ai/q_agent.py`)
- Combat and predation → Cell castes: resolves encounters (evidence: `simulation/combat.py`)
- Combat and predation → Predator behavior: resolves encounters (evidence: `simulation/combat.py`)
- Combat and predation → World and resources: attacks homes (evidence: `simulation/combat.py`)
