# baanista/superparticlesimulator architecture

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

- Interactive diagram: https://gitdiagram.com/baanista/superparticlesimulator
- Repository: https://github.com/baanista/superparticlesimulator

## Overview

This is a 2D SFML particle-and-cell simulation, despite the README describing a generic CMake template. Its runtime starts in the interactive application, seeds a primordial-soup scenario and cells, then updates and renders the particle system. Domain behavior spans physical matter, molecules, and cell metabolism/genetics, with spatial indexing and gravity as simulation infrastructure. Relationships are limited to those visible in excerpts or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`src/particles/cells/cell.cpp`](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/cell.cpp) (Cell Behavior), [`src/ParticleSystem.cpp`](https://github.com/baanista/superparticlesimulator/blob/master/src/ParticleSystem.cpp) (Particle System), [`src/main.cpp`](https://github.com/baanista/superparticlesimulator/blob/master/src/main.cpp) (Interactive Loop), [`src/Particle.cpp`](https://github.com/baanista/superparticlesimulator/blob/master/src/Particle.cpp) (Particle Base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Interactive Loop<br/>[main.cpp]"]
  node_soup["Primordial Soup<br/>[primodial_soup.cpp]"]
end

subgraph group_sim["Simulation Core"]
  node_system["Particle System<br/>[ParticleSystem.cpp]"]
  node_grid["Spatial Grid<br/>[SpatialGrid.cpp]"]
  node_gravity["Gravity Field<br/>[GravityField.cpp]"]
  node_serialization["Serialization<br/>[serializetion.hpp]"]
  node_random["Random Generators"]
end

subgraph group_matter["Particle Domain"]
  node_particle["Particle Base<br/>[Particle.cpp]"]
  node_matterbody["Physical Matter<br/>[ParticleMatter.cpp]"]
  node_atom["Atoms<br/>[atom.cpp]"]
  node_molecule["Molecules<br/>[molecule.cpp]"]
  node_factory["Particle Factory"]
end

subgraph group_biology["Cell Biology"]
  node_cell["Cell Behavior<br/>[cell.cpp]"]
  node_dna["Genetic Rules<br/>[DNA.hpp]"]
  node_cytoplasm["Cytoplasm<br/>[cytoplasm.hpp]"]
  node_metabolism["Metabolism<br/>[metabolize.cpp]"]
end

node_user(("Operator"))

node_user -->|"controls"| node_main
node_main -->|"updates and draws"| node_system
node_main -->|"seeds scenario"| node_soup
node_main -->|"creates cells"| node_cell
node_soup -->|"adds particles"| node_system
node_soup -->|"creates molecules"| node_molecule
node_system -->|"uses spatial index"| node_grid
node_system -->|"uses gravity field"| node_gravity
node_matterbody -->|"extends"| node_particle
node_atom -->|"extends"| node_matterbody
node_molecule -->|"extends"| node_matterbody
node_cell -->|"extends"| node_matterbody
node_cell -->|"absorbs and manages"| node_molecule
node_cell -->|"uses genetic rules"| node_dna
node_cell -->|"manages contents"| node_cytoplasm
node_metabolism -->|"implements conversions"| node_cell
node_metabolism -->|"uses simulation"| node_system
node_molecule -->|"uses simulation"| node_system
node_particle -->|"uses factory"| node_factory
node_particle -->|"uses generators"| node_random
node_particle -->|"uses serialization"| node_serialization

click node_main "https://github.com/baanista/superparticlesimulator/blob/master/src/main.cpp"
click node_soup "https://github.com/baanista/superparticlesimulator/blob/master/src/senarios/primodial_soup.cpp"
click node_system "https://github.com/baanista/superparticlesimulator/blob/master/src/ParticleSystem.cpp"
click node_grid "https://github.com/baanista/superparticlesimulator/blob/master/src/SpatialGrid.cpp"
click node_gravity "https://github.com/baanista/superparticlesimulator/blob/master/src/GravityField.cpp"
click node_particle "https://github.com/baanista/superparticlesimulator/blob/master/src/Particle.cpp"
click node_matterbody "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/ParticleMatter.cpp"
click node_atom "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/atom/atom.cpp"
click node_molecule "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/molecule/molecule.cpp"
click node_factory "https://github.com/baanista/superparticlesimulator/blob/master/src/particleFactory.hpp"
click node_cell "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/cell.cpp"
click node_dna "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/DNA.hpp"
click node_cytoplasm "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/cytoplasm.hpp"
click node_metabolism "https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/conversions/metabolize.cpp"
click node_serialization "https://github.com/baanista/superparticlesimulator/blob/master/src/serializetion.hpp"
click node_random "https://github.com/baanista/superparticlesimulator/blob/master/src/randomgenerators.hpp"

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_main,node_soup toneBlue
class node_system,node_grid,node_gravity,node_serialization,node_random toneAmber
class node_particle,node_matterbody,node_atom,node_molecule,node_factory toneMint
class node_cell,node_dna,node_cytoplasm,node_metabolism toneRose
class node_user toneIndigo
```

## Components

### Application

- [Interactive Loop](https://github.com/baanista/superparticlesimulator/blob/master/src/main.cpp): `src/main.cpp`
- [Primordial Soup](https://github.com/baanista/superparticlesimulator/blob/master/src/senarios/primodial_soup.cpp): `src/senarios/primodial_soup.cpp`

### Simulation Core

- [Particle System](https://github.com/baanista/superparticlesimulator/blob/master/src/ParticleSystem.cpp): `src/ParticleSystem.cpp`
- [Spatial Grid](https://github.com/baanista/superparticlesimulator/blob/master/src/SpatialGrid.cpp): `src/SpatialGrid.cpp`
- [Gravity Field](https://github.com/baanista/superparticlesimulator/blob/master/src/GravityField.cpp): `src/GravityField.cpp`
- [Serialization](https://github.com/baanista/superparticlesimulator/blob/master/src/serializetion.hpp): `src/serializetion.hpp`
- [Random Generators](https://github.com/baanista/superparticlesimulator/blob/master/src/randomgenerators.hpp): `src/randomgenerators.hpp`

### Particle Domain

- [Particle Base](https://github.com/baanista/superparticlesimulator/blob/master/src/Particle.cpp): `src/Particle.cpp`
- [Physical Matter](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/ParticleMatter.cpp): `src/particles/ParticleMatter.cpp`
- [Atoms](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/atom/atom.cpp): `src/particles/atom/atom.cpp`
- [Molecules](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/molecule/molecule.cpp): `src/particles/molecule/molecule.cpp`
- [Particle Factory](https://github.com/baanista/superparticlesimulator/blob/master/src/particleFactory.hpp): `src/particleFactory.hpp`

### Cell Biology

- [Cell Behavior](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/cell.cpp): `src/particles/cells/cell.cpp`
- [Genetic Rules](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/DNA.hpp): `src/particles/cells/DNA.hpp`
- [Cytoplasm](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/cytoplasm.hpp): `src/particles/cells/cytoplasm.hpp`
- [Metabolism](https://github.com/baanista/superparticlesimulator/blob/master/src/particles/cells/conversions/metabolize.cpp): `src/particles/cells/conversions/metabolize.cpp`

### Other components

- **Operator**

## Connections

- Operator → Interactive Loop: controls (evidence: `src/main.cpp`)
- Interactive Loop → Particle System: updates and draws (evidence: `src/main.cpp`)
- Interactive Loop → Primordial Soup: seeds scenario (evidence: `src/main.cpp`)
- Interactive Loop → Cell Behavior: creates cells (evidence: `src/main.cpp`)
- Primordial Soup → Particle System: adds particles
- Primordial Soup → Molecules: creates molecules
- Particle System → Spatial Grid: uses spatial index
- Particle System → Gravity Field: uses gravity field
- Physical Matter → Particle Base: extends
- Atoms → Physical Matter: extends
- Molecules → Physical Matter: extends
- Cell Behavior → Physical Matter: extends
- Cell Behavior → Molecules: absorbs and manages
- Cell Behavior → Genetic Rules: uses genetic rules
- Cell Behavior → Cytoplasm: manages contents
- Metabolism → Cell Behavior: implements conversions (evidence: `src/particles/cells/conversions/metabolize.cpp`)
- Metabolism → Particle System: uses simulation (evidence: `src/particles/cells/conversions/metabolize.cpp`)
- Molecules → Particle System: uses simulation (evidence: `src/particles/molecule/molecule.cpp`)
- Particle Base → Particle Factory: uses factory
- Particle Base → Random Generators: uses generators
- Particle Base → Serialization: uses serialization
