# potomak/gist-txt architecture

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

- Interactive diagram: https://gitdiagram.com/potomak/gist-txt
- Repository: https://github.com/potomak/gist-txt

## Overview

##### Main Components Identification

a) Client-Side Application
- Frontend Engine (Browser-based)
- Scene Renderer
- State Manager
- Cache System

b) External Services
- GitHub Gist API (for story storage)
- Local Development Environment

##### Story Source Layer (Top)
- GitHub Gist API
- Local Development Environment (/dist/dev)

##### Processing Layer (Middle)
- Markdown Processing
- YAML Front Matter Processing
- Mustache Template Engine

##### Rendering Layer (Bottom)
- Scene Renderer
- Style Manager
- State Manager

##### Specific Implementation Details

- Blue: Core engine components
- Green: External services (GitHub Gist)
- Orange: Processing components
- Purple: Rendering components

##### Component Relationships

a) Data Flow
- Gist API → Parser → Scene Renderer
- Local Files → Parser → Scene Renderer
- State Manager ↔ Scene Renderer
- Cache System ↔ Parser

b) Control Flow
- User Interaction → Scene Navigation
- Scene Initialization → State Updates
- Style Management → DOM Updates

##### Technical Details

Annotations for:
- Markdown processing capability
- YAML Front Matter support
- Mustache templating
- Custom CSS handling
- Scene initialization hooks

##### Development Tools Integration

A separate section showing:
- Webpack build process
- Jest testing framework
- Flow type checking
- ESLint integration

##### Notes Section

A notes section describing:
- Development mode vs. Production mode
- Local development environment setup
- Testing and type checking workflow
- Build process workflow

- The GitHub Gist integration for story storage
- The scene-based navigation system
- The state management system
- The custom styling capability
- The development environment setup

Remember to emphasize the separation between the core engine components and the story content storage, as this is a key architectural decision in the project's design.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Story Source Layer"
        GistAPI["GitHub Gist API"]
        LocalDev["Local Development"]:::dev
    end

    subgraph "Core Engine Layer"
        Engine["Frontend Engine"]:::core
        Parser["Scene Parser"]:::core
        CompMgr["Component Manager"]:::core
        Cache["Cache System"]:::core
        Utils["Core Utilities"]:::core
    end

    subgraph "Processing Layer"
        MarkProc["Markdown Processing"]:::process
        YAMLProc["YAML Front Matter"]:::process
        MustacheEng["Mustache Template"]:::process
    end

    subgraph "Backend Services"
        HTTPServ["HTTP Service"]:::backend
        BackendMgr["Backend Manager"]:::backend
        GistInteg["Gist Integration"]:::backend
        LocalInt["Local Integration"]:::backend
    end

    subgraph "Rendering Layer"
        SceneRend["Scene Renderer"]:::render
        StyleMgr["Style Manager"]:::render
        StateMgr["State Manager"]:::render
    end

    subgraph "Development Tools"
        Webpack["Webpack Build"]:::dev
        Jest["Jest Testing"]:::dev
        Flow["Flow Types"]:::dev
        ESLint["ESLint"]:::dev
    end

    %% Connections
    GistAPI --> HTTPServ
    LocalDev --> LocalInt
    HTTPServ --> BackendMgr
    LocalInt --> BackendMgr
    BackendMgr --> Engine
    Engine --> Parser
    Parser --> CompMgr
    CompMgr --> Cache
    Parser --> MarkProc
    Parser --> YAMLProc
    Parser --> MustacheEng
    MarkProc --> SceneRend
    YAMLProc --> SceneRend
    MustacheEng --> SceneRend
    SceneRend --> StyleMgr
    SceneRend <--> StateMgr
    Cache <--> Parser

    %% Development Flow
    Webpack -.-> Engine
    Jest -.-> Parser
    Flow -.-> Engine
    ESLint -.-> Engine

    %% Click Events
    click Engine "https://github.com/potomak/gist-txt/blob/master/src/index.js"
    click Parser "https://github.com/potomak/gist-txt/blob/master/src/parse.js"
    click Cache "https://github.com/potomak/gist-txt/blob/master/src/cache.js"
    click CompMgr "https://github.com/potomak/gist-txt/blob/master/src/components.js"
    click Utils "https://github.com/potomak/gist-txt/blob/master/src/basic.js"
    click GistInteg "https://github.com/potomak/gist-txt/blob/master/src/backend/gist.js"
    click LocalInt "https://github.com/potomak/gist-txt/blob/master/src/backend/local.js"
    click HTTPServ "https://github.com/potomak/gist-txt/blob/master/src/backend/httpGet.js"
    click BackendMgr "https://github.com/potomak/gist-txt/blob/master/src/backend/index.js"
    click LocalDev "https://github.com/potomak/gist-txt/tree/master/dist"
    click Jest "https://github.com/potomak/gist-txt/tree/master/test"
    click Webpack "https://github.com/potomak/gist-txt/blob/master/webpack.config.js"
    click Flow "https://github.com/potomak/gist-txt/blob/master/.flowconfig"
    click ESLint "https://github.com/potomak/gist-txt/blob/master/.eslintrc.js"

    %% Styles
    classDef core fill:#2374ab
    classDef process fill:#ff7f50
    classDef render fill:#9370db
    classDef backend fill:#4caf50
    classDef dev fill:#ffa726

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Processing Components"]:::process
        L3["Rendering Components"]:::render
        L4["Backend Services"]:::backend
        L5["Development Tools"]:::dev
    end
```
