# bardurt/odontograma architecture

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

- Interactive diagram: https://gitdiagram.com/bardurt/odontograma
- Repository: https://github.com/bardurt/odontograma

## Overview

##### Main Components
- HTML & Entry Point – The index.html file is the entry point that sets up the user interface and loads the JavaScript code.
- JavaScript Modules – The “js” directory contains all the core modules. Each module plays an important role:
- engine.js: Acts as the central simulation or game loop engine, driving the application’s logic.
- renderer.js: Handles drawing to the screen, likely using the HTML5 Canvas or similar.
- odontogramaGenerator.js: Responsible for generating the odontogram structure, creating tooth objects, or laying out the dental chart.
- tooth.js: Defines the data/behavior for individual tooth objects.
- collisionHandler.js & rect.js: Likely manage collision detection and geometric bounds for interactive or movable components.
- menuItem.js and textBox.js: Deal with user interface elements – menus, buttons, and text overlays.
- constants.js & settings.js: Provide configuration data and constants used throughout the application.
- damage.js: Perhaps handles representation of dental damage or modifications to the odontogram.

##### Relationships and Interactions
- The engine.js serves as the central coordinator that repeatedly updates the state of the system. It calls:
- renderer.js for drawing the updated state.
- odontogramaGenerator.js to create or refresh the odontogram.
- Collision and input handlers (via collisionHandler.js) to manage interactions.
- The tooth objects (from tooth.js) are generated and manipulated by the odontogramaGenerator, while any graphical representation might be processed by renderer.js.
- MenuItem.js and textBox.js interact with engine.js to modify settings or display feedback during user interactions.
- Settings and constants modules provide shared configurations to all major modules.

##### Architectural Patterns and Design Principles
- Modular JavaScript design: The project is divided into multiple well-defined modules, keeping concerns separated.
- MVC-like Separation (loosely speaking): Although not formally structured as MVC, you have components responsible for:
– Data (tooth.js, damage.js)
– Logic/Control (engine.js, collisionHandler.js)
– View (renderer.js, textBox.js, menuItem.js)
- Reusability & Separation of Concerns: Each file/module is dedicated to a specific aspect of the overall functionality ensuring extensibility and ease of maintenance.

##### Including Relevant Technologies
- Core Web technologies: HTML5 and JavaScript.
- Likely usage of Canvas or DOM manipulation for rendering.
- No explicit external libraries are mentioned so it appears to be a custom built solution.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        HTML["index.html (Entry Point)"]:::presentation
        RENDERER["renderer.js (Rendering Module)"]:::presentation
        MENU["menuItem.js (Menu Element)"]:::presentation
        TEXT["textBox.js (Text Display)"]:::presentation
    end

    %% Business/Logic Layer
    subgraph "Business/Logic Layer"
        ENGINE["engine.js (Central Engine)"]:::logic
        ODONTO["odontogramaGenerator.js (Odontogram Generator)"]:::logic
        COLLISION["collisionHandler.js (Collision Manager)"]:::logic
        DAMAGE["damage.js (Dental Damage Handler)"]:::logic
    end

    %% Data/Models Layer
    subgraph "Data/Models Layer"
        TOOTH["tooth.js (Tooth Model)"]:::data
        RECT["rect.js (Geometry/Bounds)"]:::data
        CONSTANTS["constants.js (Constants)"]:::data
        SETTINGS["settings.js (Settings)"]:::data
    end

    %% Relationships
    HTML -->|"loads"| ENGINE
    ENGINE -->|"calls render"| RENDERER
    ENGINE -->|"generates odontogram"| ODONTO
    ENGINE -->|"handles collisions"| COLLISION
    ENGINE -->|"updates damage"| DAMAGE
    ODONTO -->|"creates/manages"| TOOTH
    COLLISION -->|"validates bounds"| RECT
    MENU -->|"triggers actions"| ENGINE
    TEXT -->|"provides feedback"| ENGINE
    CONSTANTS -->|"configures"| ENGINE
    SETTINGS -->|"configures"| ENGINE

    %% Styling
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef logic fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef data fill:#ffcc99,stroke:#000,stroke-width:1px;

    %% Click Events
    click HTML "https://github.com/bardurt/odontograma/blob/master/index.html"
    click ENGINE "https://github.com/bardurt/odontograma/blob/master/js/engine.js"
    click RENDERER "https://github.com/bardurt/odontograma/blob/master/js/renderer.js"
    click ODONTO "https://github.com/bardurt/odontograma/blob/master/js/odontogramaGenerator.js"
    click TOOTH "https://github.com/bardurt/odontograma/blob/master/js/tooth.js"
    click COLLISION "https://github.com/bardurt/odontograma/blob/master/js/collisionHandler.js"
    click RECT "https://github.com/bardurt/odontograma/blob/master/js/rect.js"
    click MENU "https://github.com/bardurt/odontograma/blob/master/js/menuItem.js"
    click TEXT "https://github.com/bardurt/odontograma/blob/master/js/textBox.js"
    click CONSTANTS "https://github.com/bardurt/odontograma/blob/master/js/constants.js"
    click SETTINGS "https://github.com/bardurt/odontograma/blob/master/js/settings.js"
    click DAMAGE "https://github.com/bardurt/odontograma/blob/master/js/damage.js"
```
