# rafaelbarbosatec/bonfire architecture

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

- Interactive diagram: https://gitdiagram.com/rafaelbarbosatec/bonfire
- Repository: https://github.com/rafaelbarbosatec/bonfire

## Overview

##### Project type and purpose
- This is an open-source Flutter plugin/library (“Bonfire”) built on top of the Flame game engine.
- Its goal is to provide a modular RPG game framework (tile maps, input, behaviors, collisions, lighting, UI) and an example/demo app.

##### File structure
- Top-level: GitHub config (workflows, ISSUE_TEMPLATE), pubspec, README, CHANGELOG.
- lib/: the core Bonfire engine, subdivided into modules (base game loop, camera, input, map readers/builders, collision, lighting, behaviors, NPCs, mixins, utilities, widgets).
- example/: a Flutter application exercising Bonfire’s API, with its own assets, pages, shaders, tests, and pubspec.
- awesome/: showcase games built with Bonfire.
- media/, docs, CI/CD workflows for publishing and testing.

##### README
- Confirms it’s a Flutter/Flame-powered RPG game framework.
- Points to demos, docs site, and an “awesome” gallery.
- Emphasizes extensibility via packages (bonfire_bloc, bonfire_spine).

##### Elements
- Platform & external (gray)
- Library modules (green)
- Example App (orange)
- Rounded rectangles for controllers/providers
- Solid rectangles for core modules

##### Detailed call-outs (don’t overthink – break into as many components as possible)
- Drill into lib/map: show TiledReader, SpritefusionReader, world builders, cache providers.
- Lib/scene_builder actions as plugin points.
- How mixins slot into GameComponent to add behaviors.
- CI/CD block with steps: unit tests (unit.yml) → publish.yml → pub.dev.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Dependencies
    FL["Flutter Platform"]:::external
    FE["Flame Engine"]:::external
    ASSETS[/"Assets (tile maps, sprites, shaders)"/]:::external

    %% Example App
    subgraph "Example App" 
        ExApp["Example App"]:::example
    end

    %% Bonfire Library Container
    subgraph "Bonfire Library" 
        BL["Public API"]:::library
        GLR["Game Loop & Rendering"]:::library
        IGM["Input & Gesture Manager"]:::library
        SBAM["Scene Builder & Action Manager"]:::library
        MAM["Map & Asset Management"]:::library
        CP["Collision & Physics"]:::library
        LIT["Lighting"]:::library
        CF["Color Filter"]:::library
        BM["Behavior Manager"]:::library
        NPC["NPC Manager"]:::library
        WID["Widgets"]:::library
        GI["Game Interface"]:::library
        UM["Utilities & Mixins"]:::library
    end

    %% CI/CD Workflows
    subgraph "CI/CD Workflows" 
        Unit["unit.yml"]:::external
        Publish["publish.yml"]:::external
    end

    %% Relationships
    ExApp -->|"imports API"| BL
    BL -->|exposes modules| GLR
    BL -->|exposes modules| IGM
    BL -->|exposes modules| SBAM
    BL -->|exposes modules| MAM
    BL -->|exposes modules| CP
    BL -->|exposes modules| LIT
    BL -->|exposes modules| CF
    BL -->|exposes modules| BM
    BL -->|exposes modules| NPC
    BL -->|exposes modules| WID
    BL -->|exposes modules| GI
    BL -->|exposes modules| UM

    GLR -->|depends on| FE
    GLR -->|runs on| FL

    IGM -->|dispatches events| SBAM
    IGM -->|dispatches events| BM

    SBAM -->|orchestrates game loop| GLR

    MAM -->|loads assets| GLR
    MAM -->|uses assets| ASSETS

    BM -->|updates| NPC
    BM -->|updates| CP

    NPC -->|collides via| CP

    CP -->|integrates with| GLR

    LIT -->|applies to| GLR
    CF -->|applies to| GLR

    WID -->|renders on| GLR
    GI -->|renders on| GLR

    UM -->|extends| GLR
    UM -->|extends| SBAM
    UM -->|extends| BM

    Unit -->|tests| BL
    Unit --> Publish
    Publish -->|publishes| BL

    %% Click Events
    click GLR "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/base"
    click IGM "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/input"
    click SBAM "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/scene_builder"
    click MAM "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/map"
    click CP "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/collision"
    click LIT "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/lighting"
    click CF "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/color_filter"
    click BM "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/behavior"
    click NPC "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/npc"
    click WID "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/widgets"
    click GI "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/game_interface"
    click UM "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/mixins"
    click UM "https://github.com/rafaelbarbosatec/bonfire/tree/master/lib/util"
    click ExApp "https://github.com/rafaelbarbosatec/bonfire/tree/master/example/"
    click Unit "https://github.com/rafaelbarbosatec/bonfire/blob/master/.github/workflows/unit.yml"
    click Publish "https://github.com/rafaelbarbosatec/bonfire/blob/master/.github/workflows/publish.yml"

    %% Styles
    classDef external fill:#ddd,stroke:#999,stroke-width:1px
    classDef library fill:#cfc,stroke:#2a2,stroke-width:1px
    classDef example fill:#fc9,stroke:#d60,stroke-width:1px
```
