# activescaffold/active_scaffold architecture

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

- Interactive diagram: https://gitdiagram.com/activescaffold/active_scaffold
- Repository: https://github.com/activescaffold/active_scaffold

## Overview

##### Project type and purpose
- This is a Ruby on Rails engine/gem (“active_scaffold”) that plugs into any Rails application to provide dynamic, ready-made CRUD UIs with search, pagination, layout control and more.
- The README confirms it’s distributed as a gem, supports Rails ≥6.1 and Ruby ≥3.0, supplies generators, assets, controllers, views and integration “bridges” to various ORMs and file-upload libraries.

##### File structure
- Top-level:
- bin/, lib/, app/, config/, test/ – standard Rails-engine layout.
- app/assets: JavaScript, stylesheets, images, all under an “active_scaffold” namespace.
- app/views/active_scaffold_overrides: default partials to render CRUD interfaces.
- lib/active_scaffold:
- engine.rb – mounts the Rails engine.
- core modules, actions (create, list, update, delete, show, search, etc.), config, data_structures, helpers, extensions, bridges (ActiveStorage, Paperclip, Ancestry, Cancan, etc.), generators.
- config/: engine-specific config and internationalization files.
- test/: unit and functional tests for every major piece: actions, config, bridges, helpers, data structures, plus a mock Rails app under test/mock_app.

##### README for additional insights
- It describes how the gem installs generators to wire assets and JavaScript into a host Rails application, how it integrates with the asset pipeline (importmap or sprockets), and how it hooks into Rails controllers/views as a mountable engine.
- It highlights per-request configuration, threadsafety, and supported Rails/Ruby versions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Host Rails Application
    subgraph "Host Rails Application" 
        direction TB
        Models["app/models"]:::host
        Controllers["app/controllers"]:::host
        Views["app/views"]:::host
    end

    %% ActiveScaffold Engine
    subgraph "ActiveScaffold Engine"
        direction TB
        EngineCore["Engine Core"]:::engine
        GeneratorLayer["Generator Layer"]:::engine
        subgraph "Asset Pipeline" 
            direction TB
            Manifest["config/active_scaffold/manifest.js"]:::asset
            JS["active_scaffold.js.erb"]:::asset
            CSS["active_scaffold.scss"]:::asset
            Images["images/"]:::asset
        end
        Actions["Controllers / Action Modules"]:::engine
        ViewsOverrides["Views & Overrides"]:::engine
        ConfigSubsystem["Configuration Subsystem"]:::engine
        subgraph "DataStructures & Registry"
            direction TB
            DataStructures["DataStructures"]:::engine
            Registry["Registry"]:::engine
        end
        subgraph "Helpers & Extensions"
            direction TB
            Helpers["Helpers"]:::engine
            Extensions["Extensions"]:::engine
        end
        Bridges["Bridges / Integration Adapters"]:::engine
    end

    %% External Services and ORM
    subgraph "External & ORM Services"
        direction TB
        ORM["ORM (ActiveRecord/Mongoid)"]:::external
        ExternalServices["External Services"]:::external
    end

    %% Request Flow
    HTTP["HTTP Request"]:::request --> Router["Rails Router"]:::engine
    Router -->|"mounts engine"| EngineCore
    GeneratorLayer -->|"scaffolds files"| Models
    GeneratorLayer --> Controllers
    GeneratorLayer --> Views
    EngineCore --> Actions
    Actions --> ConfigSubsystem
    Actions --> DataStructures
    Actions --> Registry
    Actions --> Bridges
    Actions --> ORM
    ORM -->|"data"| Models
    Actions --> ViewsOverrides
    ViewsOverrides --> Manifest
    ViewsOverrides --> JS
    ViewsOverrides --> CSS
    ViewsOverrides --> Images
    ViewsOverrides -->|"renders"| Views
    Views --> HTTPResponse["HTTP Response"]:::response

    %% Click Events
    click EngineCore "https://github.com/activescaffold/active_scaffold/blob/master/lib/active_scaffold/engine.rb"
    click GeneratorLayer "https://github.com/activescaffold/active_scaffold/tree/master/lib/generators/active_scaffold/"
    click Manifest "https://github.com/activescaffold/active_scaffold/blob/master/app/assets/config/active_scaffold/manifest.js"
    click JS "https://github.com/activescaffold/active_scaffold/blob/master/app/assets/javascripts/active_scaffold.js.erb"
    click CSS "https://github.com/activescaffold/active_scaffold/blob/master/app/assets/stylesheets/active_scaffold.scss"
    click Images "https://github.com/activescaffold/active_scaffold/tree/master/app/assets/images/active_scaffold/"
    click Actions "https://github.com/activescaffold/active_scaffold/tree/master/lib/active_scaffold/actions/"
    click ViewsOverrides "https://github.com/activescaffold/active_scaffold/tree/master/app/views/active_scaffold_overrides/"
    click ConfigSubsystem "https://github.com/activescaffold/active_scaffold/tree/master/lib/active_scaffold/config/"
    click DataStructures "https://github.com/activescaffold/active_scaffold/tree/master/lib/active_scaffold/data_structures/"
    click Registry "https://github.com/activescaffold/active_scaffold/blob/master/lib/active_scaffold/registry.rb"
    click Helpers "https://github.com/activescaffold/active_scaffold/tree/master/lib/active_scaffold/helpers/"
    click Extensions "https://github.com/activescaffold/active_scaffold/tree/master/lib/active_scaffold/extensions/"
    click Bridges "https://github.com/activescaffold/active_scaffold/tree/master/lib/active_scaffold/bridges/"

    %% Styles
    classDef host fill:#f9f,stroke:#333,stroke-width:1px
    classDef engine fill:#bbf,stroke:#333,stroke-width:1px
    classDef asset fill:#bfb,stroke:#333,stroke-width:1px
    classDef external fill:#fbf,stroke:#333,stroke-width:1px
    classDef request fill:#ffe,stroke:#333,stroke-width:1px
    classDef response fill:#efe,stroke:#333,stroke-width:1px
```
