# scottcgi/mojoc architecture

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

- Interactive diagram: https://gitdiagram.com/scottcgi/mojoc
- Repository: https://github.com/scottcgi/mojoc

## Overview

##### Main Architecture Layers

**Application Layer**
- Platform-specific (Android/iOS)
- Core Application Components

**Engine Modules Layer**
- Graphics (OpenGL ES3)
- Physics
- Audio
- Extension
- Input

**Toolkit Foundation Layer**
- Math
- Utils
- Platform Abstractions

##### Component Relationships

a) Core Components:
- Application manages the game lifecycle
- Component system handles entity management
- Scheduler manages update loops
- Input system handles user interactions

b) Graphics Pipeline:
**Graphics Module**
- OpenGL Wrapper
- Shaders
- Textures
- Meshes
- Sprites
- Primitives
- Camera System

##### Platform-Specific Elements
**Android Layer               iOS Layer**
- JNI Bridge            ├── Native Bridge
- Activity Handling     ├── View Controllers
- Asset Management      └── Asset Management

##### Key Design Elements to Highlight

- Core Engine Components (Blue)
- Platform-Specific Code (Green)
- Third-Party Integration (Orange)
- Utility Services (Gray)

##### Technical Details

**Memory Management**
- Array-based collections
- String utilities
- Resource handling

**Math & Physics**
- Vector operations
- Matrix transformations
- Collision detection

**Extension System**
- Font handling
- Spine integration

##### Implementation Notes

- Use standardized UML notation where applicable
- Notes for critical implementation details
- Version compatibility (OpenGL ES3)

##### Data Flow

**Input → Application → Physics → Graphics → Render**

- The pure C99 implementation
- Platform independence of core components
- The lightweight OOC model
- Component-based architecture
- State machine implementation
- Message-driven design

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph AL["Application Layer"]
        App["Core Application"]
        Comp["Component System"]
        Input["Input System"]
        Sched["Scheduler"]
        
        subgraph Platform["Platform-Specific"]
            Android["Android Layer"]
            IOS["iOS Layer"]
        end
    end

    subgraph EML["Engine Modules Layer"]
        subgraph Graphics["Graphics Module"]
            OGLE["OpenGL ES3"]
            Shader["Shader System"]
            Camera["Camera System"]
            Draw["Draw System"]
            Sprite["Sprite System"]
            Texture["Texture Management"]
        end

        subgraph Physics["Physics Module"]
            PhysCore["Core Physics"]
            PhysBody["Physics Body"]
            Collision["Collision System"]
            PhysWorld["Physics World"]
        end

        subgraph Audio["Audio Module"]
            AudioCore["Core Audio"]
            AudioPlat["Platform Audio"]
        end

        subgraph Ext["Extension Module"]
            ExtCore["Core Extension"]
            DrawAtlas["Draw Atlas"]
            Font["Font System"]
            Spine["Spine Animation"]
        end
    end

    subgraph TFL["Toolkit Foundation Layer"]
        Math["Math Utils"]
        Utils["Core Utils"]
        Platform["Platform Abstractions"]
        Array["Array Collections"]
    end

    %% Relationships
    App --> Comp
    App --> Input
    App --> Sched
    App --> Graphics
    App --> Physics
    App --> Audio
    App --> Ext

    Graphics --> TFL
    Physics --> TFL
    Audio --> TFL
    Ext --> TFL

    Android -.-> Platform
    IOS -.-> Platform

    %% Click events
    click App "https://github.com/scottcgi/Mojoc/blob/master/Engine/Application/Application.h"
    click Comp "https://github.com/scottcgi/Mojoc/blob/master/Engine/Application/Component.h"
    click Input "https://github.com/scottcgi/Mojoc/blob/master/Engine/Application/Input.h"
    click Sched "https://github.com/scottcgi/Mojoc/blob/master/Engine/Application/Scheduler.h"
    click Android "https://github.com/scottcgi/Mojoc/tree/master/Engine/Application/Platform/Android/"
    click IOS "https://github.com/scottcgi/Mojoc/tree/master/Engine/Application/Platform/IOS/"
    click OGLE "https://github.com/scottcgi/Mojoc/tree/master/Engine/Graphics/OpenGL/"
    click Shader "https://github.com/scottcgi/Mojoc/tree/master/Engine/Graphics/OpenGL/Shader/"
    click Camera "https://github.com/scottcgi/Mojoc/blob/master/Engine/Graphics/OpenGL/Camera.h"
    click Draw "https://github.com/scottcgi/Mojoc/tree/master/Engine/Graphics/Draw/"
    click Sprite "https://github.com/scottcgi/Mojoc/blob/master/Engine/Graphics/OpenGL/Sprite.h"
    click Texture "https://github.com/scottcgi/Mojoc/blob/master/Engine/Graphics/OpenGL/Texture.h"
    click PhysCore "https://github.com/scottcgi/Mojoc/blob/master/Engine/Physics/Physics.h"
    click PhysBody "https://github.com/scottcgi/Mojoc/blob/master/Engine/Physics/PhysicsBody.h"
    click Collision "https://github.com/scottcgi/Mojoc/blob/master/Engine/Physics/PhysicsCollision.h"
    click PhysWorld "https://github.com/scottcgi/Mojoc/blob/master/Engine/Physics/PhysicsWorld.h"
    click AudioCore "https://github.com/scottcgi/Mojoc/blob/master/Engine/Audio/Platform/Audio.h"
    click AudioPlat "https://github.com/scottcgi/Mojoc/tree/master/Engine/Audio/Platform/"
    click ExtCore "https://github.com/scottcgi/Mojoc/blob/master/Engine/Extension/Extension.h"
    click DrawAtlas "https://github.com/scottcgi/Mojoc/blob/master/Engine/Extension/DrawAtlas.h"
    click Font "https://github.com/scottcgi/Mojoc/blob/master/Engine/Extension/Font.h"
    click Spine "https://github.com/scottcgi/Mojoc/tree/master/Engine/Extension/Spine/"
    click Math "https://github.com/scottcgi/Mojoc/tree/master/Engine/Toolkit/Math/"
    click Utils "https://github.com/scottcgi/Mojoc/tree/master/Engine/Toolkit/Utils/"
    click Platform "https://github.com/scottcgi/Mojoc/tree/master/Engine/Toolkit/Platform/"
    click Array "https://github.com/scottcgi/Mojoc/blob/master/Engine/Toolkit/Utils/Array.h"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef core fill:#ddf,stroke:#333
    classDef platform fill:#dfd,stroke:#333
    classDef extension fill:#ffd,stroke:#333
    classDef toolkit fill:#f8f8f8,stroke:#333

    class App,Comp,Input,Sched core
    class Android,IOS platform
    class ExtCore,DrawAtlas,Font,Spine extension
    class Math,Utils,Platform,Array toolkit
```
