# isaacbilsel/curling-cs6511 architecture

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

- Interactive diagram: https://gitdiagram.com/isaacbilsel/curling-cs6511
- Repository: https://github.com/isaacbilsel/curling-cs6511

## Overview

1. **Repository purpose**
   - This is a Python package for a **simulated curling environment**.
   - The core runtime is a physics simulation of curling stones, not a web or service application.

2. **Primary package boundary**
   - All runtime code lives under `src/`.
   - The package exposes a small public surface centered on `Curling`, `SimulationConstants`, `StoneColor`, and `StoneThrow` as shown in the README.
   - `src/__init__.py` likely acts as the top-level export layer for these user-facing types.

3. **Main simulation subsystem**
   - `src/curling.py` appears to be the orchestration layer for a curling end/game.
   - It likely owns game state, turn order, resetting, throwing stones, and scoring/evaluation.
   - This is the main entry point that external code interacts with.

4. **Stone-level physics subsystem**
   - `src/stone.pyx` is a Cython module, which strongly suggests the low-level stone motion and collision/curving physics are performance-sensitive.
   - This module is the computational core where the simulation likely steps stone trajectories and resolves interactions.
   - The use of Cython is an important architectural boundary: higher-level Python code delegates the expensive physics to compiled extension logic.

5. **Domain model and data contracts**
   - `src/enums.py` contains domain enums such as stone color and likely other simulation states.
   - `src/constants.py` holds the tunable simulation parameters, exposed as `SimulationConstants` in the README.
   - `StoneThrow` is documented in `docs/api/stone_throw.md`, indicating a structured input object for each throw with velocity, angle, spin, and color.

6. **Utility layer**
   - `src/utils.py` provides supporting functions used by the simulation and/or display logic.
   - This likely contains geometry, numeric helpers, or conversion functions that keep the core modules focused.

7. **Data flow through the system**
   - A caller creates a `Curling` instance, optionally resets it, then repeatedly submits `StoneThrow` inputs.
   - Each throw is processed using a chosen `SimulationConstants` configuration.
   - The simulation updates stone positions and game state, then exposes results through methods like `evaluate_position()` and state properties such as `next_stone_color`.

8. **Display/visualization boundary**
   - The README shows `display=True` during `throw()`, implying the simulator can render or visualize the environment.
   - This is an optional presentation layer attached to the physics/game loop, not the core model.
   - The rendered environment image in `docs/images/` suggests visualization is part of the package documentation and possibly debugging/inspection.

9. **Testing strategy**
   - `tests/test_physics.py` validates the physical simulation behavior.
   - `tests/test_gameplay.py` covers game rules and flow.
   - `tests/test_display.py` covers the rendering/display path.
   - This separation mirrors the architecture: physics, rules, and visualization are distinct concerns.

10. **Documentation and API surface**
    - `docs/api/` contains per-module API docs for `curling`, `enums`, and `stone_throw`.
    - `mkdocs.yml` and `.readthedocs.yml` show the project publishes documentation via MkDocs/ReadTheDocs.
    - The README is usage-oriented and documents the intended public API rather than internals.

11. **Packaging and build structure**
    - `pyproject.toml`, `setup.py`, and `pytest.ini` indicate a standard Python package with test tooling.
    - The presence of `src/stone.pyx` means the build process must compile a Cython extension as part of installation.

12. **External dependencies and integration**
    - The project is self-contained as a simulator; its only clearly stated external consumer is `betacurl`, which uses this package.
    - The physics model references a curling-specific research paper, which is a domain dependency rather than a software dependency.

13. **How to diagram it**
    - Model the system as: **client code → Curling orchestration → stone physics engine → updated game state/evaluation**, with an optional **display/rendering branch**.
    - Surround that with supporting modules for **constants**, **enums**, and **utility functions**, and show **tests** and **docs/build tooling** as adjacent, non-runtime parts of the repository.

Main entry points: [`src/curling.py`](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/curling.py) (Curling), [`src/__init__.py`](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/__init__.py) (Package API), [`src/stone.pyx`](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/stone.pyx) (Stone Physics), [`docs/api/stone_throw.md`](https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/stone_throw.md) (StoneThrow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_src_init["Package API<br/>exports<br/>[__init__.py]"]
  node_curling["Curling<br/>orchestrator<br/>[curling.py]"]
  node_stone["Stone Physics<br/>cython-engine<br/>[stone.pyx]"]
  node_constants["Constants<br/>config<br/>[constants.py]"]
  node_enums["Enums<br/>domain-model<br/>[enums.py]"]
  node_utils["Utilities<br/>helpers<br/>[utils.py]"]
  node_stone_throw["StoneThrow<br/>input-contract<br/>[stone_throw.md]"]
  node_state[("Game State<br/>state-model")]
  node_display(("Display<br/>rendering"))
  node_position_eval{{"Position Eval<br/>scoring"}}
end

subgraph group_docs["Docs"]
  node_api_docs["API Docs<br/>documentation<br/>[curling.md]"]
  node_enums_docs["Enums Doc<br/>documentation<br/>[enums.md]"]
  node_throw_docs["Throw Doc<br/>documentation<br/>[stone_throw.md]"]
  node_readme["README<br/>usage-doc<br/>[README.md]"]
end

subgraph group_tests["Tests"]
  node_physics_tests["Physics Tests<br/>test-suite<br/>[test_physics.py]"]
  node_gameplay_tests["Gameplay Tests<br/>test-suite<br/>[test_gameplay.py]"]
  node_display_tests["Display Tests<br/>test-suite<br/>[test_display.py]"]
end

subgraph group_tooling["Tooling"]
  node_build["Packaging<br/>build-config<br/>[pyproject.toml]"]
  node_ci["CI<br/>automation<br/>[testing.yml]"]
end

node_src_init -->|"exports"| node_curling
node_src_init -->|"exports"| node_constants
node_src_init -->|"exports"| node_enums
node_src_init -->|"exports"| node_stone_throw
node_curling -->|"delegates"| node_stone
node_curling -->|"uses"| node_constants
node_curling -->|"uses"| node_enums
node_curling -->|"accepts"| node_stone_throw
node_curling -->|"owns"| node_state
node_curling -->|"computes"| node_position_eval
node_curling -.->|"optionally renders"| node_display
node_stone -->|"uses"| node_utils
node_state -->|"feeds"| node_position_eval
node_display -.->|"visualizes"| node_stone
node_physics_tests -->|"verifies"| node_stone
node_gameplay_tests -->|"verifies"| node_curling
node_display_tests -->|"verifies"| node_display
node_api_docs -->|"documents"| node_curling
node_api_docs -->|"documents"| node_stone_throw
node_enums_docs -->|"documents"| node_enums
node_throw_docs -->|"documents"| node_stone_throw
node_readme -.->|"shows"| node_src_init
node_build -->|"builds"| node_stone
node_ci -.->|"runs"| node_physics_tests
node_ci -.->|"runs"| node_gameplay_tests
node_ci -.->|"runs"| node_display_tests

click node_src_init "https://github.com/isaacbilsel/curling-cs6511/blob/master/src/__init__.py"
click node_curling "https://github.com/isaacbilsel/curling-cs6511/blob/master/src/curling.py"
click node_stone "https://github.com/isaacbilsel/curling-cs6511/blob/master/src/stone.pyx"
click node_constants "https://github.com/isaacbilsel/curling-cs6511/blob/master/src/constants.py"
click node_enums "https://github.com/isaacbilsel/curling-cs6511/blob/master/src/enums.py"
click node_utils "https://github.com/isaacbilsel/curling-cs6511/blob/master/src/utils.py"
click node_stone_throw "https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/stone_throw.md"
click node_physics_tests "https://github.com/isaacbilsel/curling-cs6511/blob/master/tests/test_physics.py"
click node_gameplay_tests "https://github.com/isaacbilsel/curling-cs6511/blob/master/tests/test_gameplay.py"
click node_display_tests "https://github.com/isaacbilsel/curling-cs6511/blob/master/tests/test_display.py"
click node_api_docs "https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/curling.md"
click node_enums_docs "https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/enums.md"
click node_throw_docs "https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/stone_throw.md"
click node_readme "https://github.com/isaacbilsel/curling-cs6511/blob/master/README.md"
click node_build "https://github.com/isaacbilsel/curling-cs6511/blob/master/pyproject.toml"
click node_ci "https://github.com/isaacbilsel/curling-cs6511/blob/master/.github/workflows/testing.yml"

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_src_init,node_curling,node_stone,node_constants,node_enums,node_utils,node_stone_throw,node_state,node_display,node_position_eval toneBlue
class node_api_docs,node_enums_docs,node_throw_docs,node_readme toneAmber
class node_physics_tests,node_gameplay_tests,node_display_tests toneMint
class node_build,node_ci toneRose
```

## Components

### Runtime

Public package and simulation engine

- [Package API](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/__init__.py): exports · Top-level package exports for the public surface · `src/__init__.py`
- [Curling](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/curling.py): orchestrator · Main game and end simulation controller · `src/curling.py`
- [Stone Physics](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/stone.pyx): cython-engine · Low-level motion and collision simulation core · `src/stone.pyx`
- [Constants](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/constants.py): config · Tunable simulation parameters · `src/constants.py`
- [Enums](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/enums.py): domain-model · Domain enums such as stone color and state · `src/enums.py`
- [Utilities](https://github.com/isaacbilsel/curling-cs6511/blob/master/src/utils.py): helpers · Shared numeric and geometry helpers · `src/utils.py`
- [StoneThrow](https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/stone_throw.md): input-contract · Structured throw input with velocity, angle, spin, and color · `docs/api/stone_throw.md`
- **Game State**: state-model · Turn order, stone positions, and scoring state
- **Display**: rendering · Optional visualization path attached to throws
- **Position Eval**: scoring · State evaluation and scoring results

### Docs

API docs and rendered examples

- [API Docs](https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/curling.md): documentation · Published module and object reference docs · `docs/api/curling.md`
- [Enums Doc](https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/enums.md): documentation · API reference for enums · `docs/api/enums.md`
- [Throw Doc](https://github.com/isaacbilsel/curling-cs6511/blob/master/docs/api/stone_throw.md): documentation · API reference for StoneThrow · `docs/api/stone_throw.md`
- [README](https://github.com/isaacbilsel/curling-cs6511/blob/master/README.md): usage-doc · Usage-oriented overview of the public API · `README.md`

### Tests

Behavioral and display validation

- [Physics Tests](https://github.com/isaacbilsel/curling-cs6511/blob/master/tests/test_physics.py): test-suite · Validates simulation behavior · `tests/test_physics.py`
- [Gameplay Tests](https://github.com/isaacbilsel/curling-cs6511/blob/master/tests/test_gameplay.py): test-suite · Validates game rules and flow · `tests/test_gameplay.py`
- [Display Tests](https://github.com/isaacbilsel/curling-cs6511/blob/master/tests/test_display.py): test-suite · Validates rendering and visualization · `tests/test_display.py`

### Tooling

Build, packaging, and CI

- [Packaging](https://github.com/isaacbilsel/curling-cs6511/blob/master/pyproject.toml): build-config · Project packaging and extension build setup · `pyproject.toml`
- [CI](https://github.com/isaacbilsel/curling-cs6511/blob/master/.github/workflows/testing.yml): automation · Continuous integration workflow · `.github/workflows/testing.yml`

## Connections

- Package API → Curling: exports · Re-exports the main simulation entry point
- Package API → Constants: exports · Exposes simulation constants
- Package API → Enums: exports · Exposes domain enums
- Package API → StoneThrow: exports · Exposes the throw input contract
- Curling → Stone Physics: delegates · Hands off motion and collisions to the physics engine
- Curling → Constants: uses · Runs with a chosen constants configuration
- Curling → Enums: uses · Uses stone colors and related domain values
- Curling → StoneThrow: accepts · Consumes structured throw inputs
- Curling → Game State: owns · Maintains game and end state
- Curling → Position Eval: computes · Evaluates stone positions and scoring
- Curling → Display: optionally renders · Can attach a display path during throws
- Stone Physics → Utilities: uses · Relies on shared helpers for math and geometry
- Game State → Position Eval: feeds · State is the basis for scoring and evaluation
- Display → Stone Physics: visualizes · Renders the simulated stone motion
- Physics Tests → Stone Physics: verifies · Checks low-level physics behavior
- Gameplay Tests → Curling: verifies · Checks game rules and flow
- Display Tests → Display: verifies · Checks the rendering path
- API Docs → Curling: documents · Documents the main runtime entry point
- API Docs → StoneThrow: documents · Documents the throw input contract
- Enums Doc → Enums: documents · Documents the domain enums
- Throw Doc → StoneThrow: documents · Detailed reference for throw inputs
- README → Package API: shows · Explains the package-level public API
- Packaging → Stone Physics: builds · Compiles the Cython extension during installation
- CI → Physics Tests: runs · Executes test suite in automation
- CI → Gameplay Tests: runs · Executes test suite in automation
- CI → Display Tests: runs · Executes test suite in automation
