# sean-o-reilly/2d-physics-engine architecture

> Architecture diagram of the GitHub repository sean-o-reilly/2d-physics-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sean-o-reilly/2d-physics-engine
- Repository: https://github.com/sean-o-reilly/2d-physics-engine

## Overview

##### Project Type and Purpose
- This is a 2D physics and game engine, intended to simulate physics (e.g., via basic geometric objects like circles) and render them using the raylib framework.
- The project is built in C++ and developed in CLion, so you’re working with modern C++ practices and integrating an external graphics/interaction library.

##### File Structure
- At the top level, you have main.cpp, which contains the entry point and likely initializes the engine and simulation loop.

##### Components
a. Core Engine/Simulation Loop:
- Main entry point (main.cpp) that initializes and drives the engine.
- Where the simulation loop resides, which will handle physics updates and interactions.
b. Physics Components:
c. Rendering and External Dependencies:
- Raylib as an external/rendering library component. This shows how the engine uses raylib for drawing graphics, handling inputs, and possibly managing window/context creation.
d. Data Flow & Interactions:
- Also, illustrate that the physics engine repeatedly loops over the simulation state (using Circle, Point, etc.) and passes the computed data to raylib.

##### Architectural Patterns or Design Principles
- Although simple and in progress, the engine appears to follow a modular design where core simulation logic is separated from rendering logic.
- Separation of concerns: the simulation (physics engine) versus the visualization (raylib integration).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Engine Layer"
        Main["Main (main.cpp) / Engine Initialization"]:::engine
        Physics["Physics Engine / Game Loop"]:::engine
    end

    subgraph "Domain Components"
        Circle["Domain Object: Circle"]:::domain
        Point["Domain Object: Point"]:::domain
    end

    Rendering("Rendering: raylib"):::external

    Main -->|"init"| Physics
    Physics -->|"uses"| Circle
    Physics -->|"uses"| Point
    Physics -->|"renders"| Rendering

    click Main "https://github.com/sean-o-reilly/2d-physics-engine/blob/main/main.cpp"
    click Physics "https://github.com/sean-o-reilly/2d-physics-engine/blob/main/main.cpp"
    click Circle "https://github.com/sean-o-reilly/2d-physics-engine/blob/main/Circle.cpp"
    click Circle "https://github.com/sean-o-reilly/2d-physics-engine/blob/main/Circle.h"
    click Point "https://github.com/sean-o-reilly/2d-physics-engine/blob/main/Point.h"

    classDef engine fill:#ADD8E6,stroke:#00008B,stroke-width:2px,color:#00008B
    classDef domain fill:#90EE90,stroke:#006400,stroke-width:2px,color:#006400
    classDef external fill:#FFD700,stroke:#FFA500,stroke-width:2px,color:#FF8C00
```
