Module Map and Symbol Guide
This page provides a whole-project inventory of the active phids.* runtime package. It is intended
as the quickest canonical answer to the question: where in the codebase does a given concern
actually live?
Unlike the narrative chapters elsewhere in the docs, this page is organized by package ownership and symbol responsibility.
How to Use This Page
Use this guide when you need to answer one of the following:
- which module owns a behavior,
- which package defines a particular symbol,
- where a change should be made,
- where to jump from a narrative chapter into implementation reference.
Top-Level Package Structure
The active runtime package is phids.* under src/phids/.
Its top-level subpackages are:
phids.apiphids.enginephids.iophids.sharedphids.telemetry
phids.api
This package owns schema validation, route surfaces, and the server-side UI draft state.
phids.api.schemas
Primary responsibility:
- validated schema boundary for scenarios, triggers, placements, and API payloads.
Key symbols:
SimulationConfigTriggerConditionSchemaFloraSpeciesParamsPredatorSpeciesParamsDietCompatibilityMatrixSimulationStatusResponseWindUpdatePayload
Narrative docs:
docs/scenarios/docs/interfaces/
phids.api.main
Primary responsibility:
- FastAPI application, REST routes, HTMX partial routes, and WebSocket endpoints.
Key concerns:
- scenario load/import/export,
- simulation lifecycle control,
- UI polling and diagnostics,
/ws/simulation/stream,/ws/ui/stream.
Narrative docs:
docs/interfaces/rest-and-websocket-surfaces.mddocs/ui/
phids.api.ui_state
Primary responsibility:
- mutable server-side
DraftStateused by the scenario builder.
Key symbols:
DraftStateTriggerRuleSubstanceDefinitionPlacedPlantPlacedSwarmget_draftset_draftreset_draft
Narrative docs:
docs/ui/draft-state-and-load-workflow.mddocs/scenarios/scenario-authoring-and-trigger-semantics.md
phids.engine
This package owns the deterministic runtime execution model.
phids.engine.loop
Primary responsibility:
- orchestrate the ordered simulation phases.
Key symbol:
SimulationLoop
Narrative docs:
docs/engine/index.mddocs/architecture/index.md
phids.engine.components
Primary responsibility:
- runtime ECS component dataclasses.
Modules and symbols:
phids.engine.components.plant→PlantComponentphids.engine.components.swarm→SwarmComponentphids.engine.components.substances→SubstanceComponent
Narrative docs:
docs/engine/lifecycle.mddocs/engine/interaction.mddocs/engine/signaling.md
phids.engine.core.biotope
Primary responsibility:
- vectorized environmental state and buffering.
Key symbol:
GridEnvironment
Narrative docs:
docs/engine/biotope-and-double-buffering.md
phids.engine.core.ecs
Primary responsibility:
- ECS registry, component indexing, and spatial hash.
Key symbols:
EntityECSWorld
Narrative docs:
docs/engine/ecs-and-spatial-hash.md
phids.engine.core.flow_field
Primary responsibility:
- global flow-field generation and camouflage attenuation.
Key symbols:
compute_flow_fieldapply_camouflage
Narrative docs:
docs/engine/flow-field.md
phids.engine.systems.lifecycle
Primary responsibility:
- plant growth, reproduction, mycorrhizal connectivity, and death.
Key symbol:
run_lifecycle
Narrative docs:
docs/engine/lifecycle.md
phids.engine.systems.interaction
Primary responsibility:
- swarm movement, feeding, starvation, reproduction, mitosis, and toxin casualties.
Key symbol:
run_interaction
Narrative docs:
docs/engine/interaction.md
phids.engine.systems.signaling
Primary responsibility:
- trigger evaluation, substance lifecycle, emission, relay, and diffusion delegation.
Key symbol:
run_signaling
Narrative docs:
docs/engine/signaling.md
phids.io
This package owns scenario and replay persistence helpers.
phids.io.scenario
Primary responsibility:
- load and serialize
SimulationConfigvalues.
Key symbols:
load_scenario_from_dictload_scenario_from_jsonscenario_to_json
Narrative docs:
docs/scenarios/schema-and-curated-examples.mddocs/scenarios/scenario-authoring-and-trigger-semantics.md
phids.io.replay
Primary responsibility:
- msgpack-based replay serialization and replay-file framing.
Key symbols:
ReplayBufferserialise_statedeserialise_state
Narrative docs:
docs/telemetry/replay-and-termination-semantics.md
phids.shared
This package owns cross-cutting constants and logging helpers.
phids.shared.constants
Primary responsibility:
- shared numerical and architectural constants.
Key constants:
MAX_FLORA_SPECIESMAX_PREDATOR_SPECIESMAX_SUBSTANCE_TYPESGRID_W_MAXGRID_H_MAXSIGNAL_EPSILONSUBSTANCE_EMIT_RATETOXIN_CASUALTY_FACTOR
Narrative docs:
docs/foundations/docs/engine/biotope-and-double-buffering.mddocs/engine/flow-field.md
phids.shared.logging_config
Primary responsibility:
- logging configuration and recent-log support used by the diagnostics UI.
Narrative docs:
docs/interfaces/docs/ui/
phids.telemetry
This package owns summary metrics, termination logic, and export helpers.
phids.telemetry.analytics
Primary responsibility:
- per-tick metric accumulation.
Key symbol:
TelemetryRecorder
Narrative docs:
docs/telemetry/analytics-and-export-formats.md
phids.telemetry.conditions
Primary responsibility:
Z1–Z7termination checks.
Key symbols:
TerminationResultcheck_termination
Narrative docs:
docs/telemetry/replay-and-termination-semantics.mddocs/telemetry/index.md
phids.telemetry.export
Primary responsibility:
- CSV and NDJSON export helpers.
Key symbols:
export_csvexport_jsonexport_bytes_csvexport_bytes_json
Narrative docs:
docs/telemetry/analytics-and-export-formats.md
Fastest Symbol-to-Page Guide
If you know the symbol but not the page, start here:
SimulationLoop→docs/engine/index.mdDraftState→docs/ui/draft-state-and-load-workflow.mdECSWorld→docs/engine/ecs-and-spatial-hash.mdGridEnvironment→docs/engine/biotope-and-double-buffering.mdTelemetryRecorder→docs/telemetry/analytics-and-export-formats.mdReplayBuffer→docs/telemetry/replay-and-termination-semantics.mdSimulationConfig→docs/scenarios/schema-and-curated-examples.mdTriggerConditionSchema→docs/scenarios/scenario-authoring-and-trigger-semantics.md
Reference vs Narrative Rule
Use the narrative chapters when you need to know:
- why a subsystem exists,
- what invariants it preserves,
- how it behaves as part of a scientific workflow.
Use the API reference when you need to know:
- exact signatures,
- fields and docstrings,
- symbol-level declarations.
Where to Read Next
- For rendered symbol-level API docs:
api.md - For contributor-facing documentation rules:
../development/documentation-standards.md - For the repository-facing summary:
../appendices/readme.md