# reallygoodsoftware/h1rails architecture

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

- Interactive diagram: https://gitdiagram.com/reallygoodsoftware/h1rails
- Repository: https://github.com/reallygoodsoftware/h1rails

## Overview

##### Project Overview
- This is a Ruby on Rails web application boilerplate designed to help both experienced Rails developers and beginners build polished web apps quickly.
- It’s “HTML First,” meaning that it emphasizes quick setup, no excessive client-side build tooling, and leverages static assets (CSS/JS) placed in the public folder.
- It comes with batteries-included support for common UI & UX patterns (modals, toasts, tooltips, type-to-search, etc.) and uses HTMX for interactivity instead of frameworks like Hotwire/Turbo.

##### Main Components
- Frontend/UI Layer:
- Views: Located in app/views, with subdirectories for standard application pages, admin-specific views, and demos (under h1rails/demos).
- Assets: Includes conventional Rails assets in app/assets (with stylesheets, JavaScript, images) plus public assets for CSS and JS libraries.
- Components & Partials: Separated into components (shared, h1rails/partials, shared partials) to implement various UI patterns.
- Documentation and demo pages (accessible under /demos as noted by the readme).

- Backend Layer:
- Controllers: Standard MVC controllers under app/controllers, including API controllers (namespaced under api/v1), user authentication controllers, h1rails demos, and streaming controllers.
- Models: Business logic and persistence are clearly represented in app/models with common Rails patterns. Specific models such as User, AdminUser, MessageTemplate, and Category are used.
- Jobs & Mailers: Background processing via jobs (app/jobs) and email notifications via mailers (app/mailers).
- Admin Interfaces: The app/admin folder and integration (via ActiveAdmin, as seen with ActiveAdmin initializer) provide the backend admin functionality.

- Configuration & Infrastructure:
- Config directory: Contains environment settings, routes in config/routes and custom routes for demos (h1_demo_routes.rb and h1_expo_routes.rb), initializers, and secrets.
- Database: Represented in db directory with migrations for Devise, Active Storage, and custom tables. There are explicit migration files (e.g., create_message_templates.rb, add_auth_token_to_users.rb).
- External Libraries & Tools: Includes configuration files like Gemfile, package.json, Tailwind config, and environment-specific files.

- Supporting Services & Utilities:
- Utility Scripts: Located under app/utils for miscellaneous helper functionalities.
- Documentation: Provided in the docs directory (and the single readme file) that further explains UI patterns, setup, and best practices.

##### Relationships and Interactions
- MVC Pattern: Clearly, the project follows the Rails Model-View-Controller pattern with direct interaction from controllers to models and views.
- API Layer: The API namespaces indicate a separation for web service interactions, potentially used by client-side JS or external integrations.
- Admin Integration: ActiveAdmin and admin-specific controllers/models indicate a management module that interacts with core user & data models.
- Asset and Static File Flow: The public folder houses unbundled CSS/JS assets that are directly loaded by the front end, reducing the need for build tooling.
- Routing & Configuration: Centralized routing (config/routes.rb and associated demo/expo routes) directs traffic amongst general app functionality, admin, and API endpoints.
- Utilization of HTMX: As documented, many UI interactions (like modal pop-ups and multistep forms) use HTMX for progressive enhancement, placing more logic in the HTML and server responses.

##### Final Steps for the Principal Software Engineer
- Gradually drill down to represent subcomponents (like API controllers, admin-specific flows, and static asset management).
- Use annotations to indicate important patterns such as the MVC design, modular routing, and integration with external libraries like HTMX and ActiveAdmin.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        direction TB
        FV["Views"]:::frontend
        VC["Components (app/views/components)"]:::frontend
        H1P["H1 Partials (app/views/h1rails/partials)"]:::frontend
        DV["Demo Views (app/views/h1rails/demos)"]:::frontend
        AS["Assets (app/assets)"]:::frontend
        PA["Public Assets (public)"]:::frontend
        DOC["Documentation & UI References"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        CT["Controllers (app/controllers)"]:::backend
        subgraph "Controller Types"
            direction TB
            SC["Standard Controllers"]:::backend
            API["API Controllers (app/controllers/api/v1)"]:::backend
            DC["Demo Controllers (app/controllers/h1rails)"]:::backend
            STC["Streaming Controller (app/controllers/streaming_controller.rb)"]:::backend
        end
        MD["Models (app/models)"]:::backend
        subgraph "Background & Email"
            direction TB
            JOB["Jobs (app/jobs)"]:::backend
            MAIL["Mailers (app/mailers)"]:::backend
        end
        ADMIN["Admin Interfaces (app/admin)"]:::admin
        AA["ActiveAdmin Config (config/initializers/active_admin.rb)"]:::admin
    end

    %% Configuration & Infrastructure
    subgraph "Configuration & Infrastructure"
        direction TB
        RT["Routes (config/routes.rb)"]:::config
        DR["Demo Routes (config/routes/h1_demo_routes.rb)"]:::config
        ER["Expo Routes (config/routes/h1_expo_routes.rb)"]:::config
        ENV["Environment Settings (config/environments)"]:::config
        DB["Database (db)"]:::config
    end

    %% Supporting Services & Utilities
    subgraph "Supporting Services & Utilities"
        direction TB
        UTIL["Utility Scripts (app/utils)"]:::utils
        DOCS["Documentation (docs)"]:::utils
    end

    %% Data Flow Connections
    RT --> CT
    DR --> CT
    ER --> CT
    CT --> SC
    CT --> API
    CT --> DC
    CT --> STC
    SC --> FV
    API --> MD
    DC --> FV
    STC --> FV
    CT --> JOB
    CT --> MAIL
    ADMIN --> MD
    AA --> ADMIN
    AS --> FV
    PA --> FV
    VC --> FV
    H1P --> FV
    UTIL --> CT
    DOCS --> FV
    FV --> DOC

    %% Click Events
    click FV "https://github.com/reallygoodsoftware/h1rails/tree/master/app/views"
    click VC "https://github.com/reallygoodsoftware/h1rails/tree/master/app/views/components"
    click H1P "https://github.com/reallygoodsoftware/h1rails/tree/master/app/views/h1rails/partials"
    click DV "https://github.com/reallygoodsoftware/h1rails/tree/master/app/views/h1rails/demos"
    click AS "https://github.com/reallygoodsoftware/h1rails/tree/master/app/assets"
    click PA "https://github.com/reallygoodsoftware/h1rails/tree/master/public"
    click CT "https://github.com/reallygoodsoftware/h1rails/tree/master/app/controllers"
    click API "https://github.com/reallygoodsoftware/h1rails/tree/master/app/controllers/api/v1"
    click DC "https://github.com/reallygoodsoftware/h1rails/tree/master/app/controllers/h1rails"
    click STC "https://github.com/reallygoodsoftware/h1rails/blob/master/app/controllers/streaming_controller.rb"
    click MD "https://github.com/reallygoodsoftware/h1rails/tree/master/app/models"
    click JOB "https://github.com/reallygoodsoftware/h1rails/tree/master/app/jobs"
    click MAIL "https://github.com/reallygoodsoftware/h1rails/tree/master/app/mailers"
    click ADMIN "https://github.com/reallygoodsoftware/h1rails/tree/master/app/admin"
    click AA "https://github.com/reallygoodsoftware/h1rails/blob/master/config/initializers/active_admin.rb"
    click RT "https://github.com/reallygoodsoftware/h1rails/blob/master/config/routes.rb"
    click DR "https://github.com/reallygoodsoftware/h1rails/blob/master/config/routes/h1_demo_routes.rb"
    click ER "https://github.com/reallygoodsoftware/h1rails/blob/master/config/routes/h1_expo_routes.rb"
    click ENV "https://github.com/reallygoodsoftware/h1rails/tree/master/config/environments"
    click DB "https://github.com/reallygoodsoftware/h1rails/tree/master/db"
    click UTIL "https://github.com/reallygoodsoftware/h1rails/tree/master/app/utils"
    click DOCS "https://github.com/reallygoodsoftware/h1rails/tree/master/docs"
    click DOC "https://github.com/reallygoodsoftware/h1rails/tree/master/docs"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef config fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef utils fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef admin fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
