# richardmaycode/mobbwash_clone architecture

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

- Interactive diagram: https://gitdiagram.com/richardmaycode/mobbwash_clone
- Repository: https://github.com/richardmaycode/mobbwash_clone

## Overview

##### Project type and purpose
- This is a Ruby on Rails full-stack web application (monolith) that serves both customer and admin interfaces, exposes JSON endpoints (e.g. prices/show.json.jbuilder), supports real-time updates via ActionCable, background processing via ActiveJob, push notifications (WebPush), PWA features, and integrates with external services (Stripe, mailers, etc.).

##### File structure (high-level)
- Top-level:
- app/ (MVC folders: controllers, models, views; assets & JavaScript packs using importmap + Stimulus + Tailwind)
- config/ (routes, environments, initializers, cable, database, job queue config)
- lib/webpush (notification logic)
- db/ (migrations, seeds, schema)
- bin/, Dockerfile, Procfile.dev, .github CI workflows
- Patterns:
- MVC (app/controllers → app/models → app/views)
- Concerns (reusable modules under app/controllers/concerns, app/models/concerns)
- Stimulus controllers under app/javascript/controllers
- PWA: manifest + service-worker in app/views/pwa
- ActiveJob with custom adapter (solid_queue.yml)
- ActionCable (app/channels)
- External integrators (Stripe controllers, WebPush, ActionMailer)

##### README
- Placeholder, so infer standard Rails deployment: Puma web server, PostgreSQL (or similar), job queue, Redis if used, SMTP or third-party mailer, S3/local storage for ActiveStorage.

##### Detail
- PWA service worker component and manifest.
- Stimulus controllers interacting with specific Rails endpoints.
- Call out the importmap module loader.
- Where Tailwind CSS is applied (assets pipeline).
- Initialization via config/initializers (e.g., permissions_policy, content_security_policy).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Web Browser (HTML/CSS/JS)"]:::frontend
        PWAManifest["Web App Manifest"]:::frontend
        ServiceWorker["Service Worker"]:::frontend
        Stimulus["Stimulus Controllers"]:::frontend
        Tailwind["Tailwind CSS Styles"]:::frontend
        Importmap["Importmap Module Loader"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        DockerPuma["Docker / Puma Server"]:::backend
        RailsRouter["Rails Router"]:::backend
        AdminCtrl["Rails Controllers (Admin)"]:::backend
        CustomerCtrl["Rails Controllers (Customer)"]:::backend
        PricesCtrl["API JSON Endpoints (Prices Controller)"]:::backend
        PriceJSONView["Prices Jbuilder View"]:::backend
        ActiveJobNode["ActiveJob (Background)"]:::backend
        subgraph ActionCable["ActionCable (WebSocket)"]
            Connection["Connection"]:::backend
            Channel["Channel"]:::backend
        end
        Models["ActiveRecord Models"]:::backend
        Mailer["ActionMailer"]:::backend

        %% Config & Initializers
        Routing["Routing (config/routes.rb)"]:::config
        CSP["Content Security Policy"]:::config
        PermissionsPolicy["Permissions Policy"]:::config
        WebSocketConfig["ActionCable Config"]:::config
        ImportmapConfig["Importmap Config"]:::config
        TailwindConfig["Tailwind Config"]:::config
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["PostgreSQL Database"]:::data
        ActiveStorage["ActiveStorage (File Storage)"]:::data
        JobQueue["Job Queue Adapter"]:::data
    end

    %% External Services
    subgraph "External Services"
        Stripe["Stripe API"]:::external
        SMTP["SMTP / Email Service"]:::external
        WebPushService["WebPush Service"]:::external
    end

    %% Deployment & Dependencies
    Dockerfile["Dockerfile"]:::config
    Procfile["Procfile.dev"]:::config
    GemfileNode["Gemfile / Gemfile.lock"]:::config
    RubyVersion[".ruby-version"]:::config

    %% Connections - Frontend to Backend
    Browser -->|"HTTP Requests"| DockerPuma
    DockerPuma --> RailsRouter
    Stimulus -->|"XHR / Fetch"| RailsRouter
    Browser -->|"Service Worker Registration"| ServiceWorker
    Browser -->|"Load Manifest"| PWAManifest

    %% Backend Routing to Controllers
    RailsRouter --> AdminCtrl
    RailsRouter --> CustomerCtrl
    RailsRouter --> PricesCtrl
    PricesCtrl --> PriceJSONView

    %% Controllers to Models & Jobs
    AdminCtrl --> Models
    CustomerCtrl --> Models
    PricesCtrl --> Models
    AdminCtrl -->|enqueue job| ActiveJobNode
    CustomerCtrl -->|enqueue job| ActiveJobNode

    %% Background Jobs to Queue & Models/External
    ActiveJobNode --> JobQueue
    JobQueue --> Models
    ActiveJobNode -->|send email| Mailer
    ActiveJobNode -->|trigger push| WebPushService

    %% Real-time via ActionCable
    CustomerCtrl -->|broadcast| Channel
    Channel --> Connection
    Connection -->|WebSocket| Browser

    %% Data Layer interactions
    Models --> DB
    Models --> ActiveStorage

    %% External Integrations
    CustomerCtrl -->|payment calls| Stripe
    PricesCtrl -->|payment calls| Stripe
    Mailer --> SMTP
    WebPushService -->|push notifications| ServiceWorker

    %% Config & Deployment connections
    DockerPuma --> Routing
    DockerPuma --> WebSocketConfig
    RailsRouter --> CSP
    RailsRouter --> PermissionsPolicy
    RailsRouter --> ImportmapConfig
    RailsRouter --> TailwindConfig
    DockerPuma --> Dockerfile
    DockerPuma --> Procfile
    RailsRouter --> GemfileNode
    RailsRouter --> RubyVersion

    %% Click Events
    click AdminCtrl "https://github.com/richardmaycode/mobbwash_clone/tree/main/app/controllers/admin"
    click CustomerCtrl "https://github.com/richardmaycode/mobbwash_clone/tree/main/app/controllers/customer"
    click PricesCtrl "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/controllers/prices_controller.rb"
    click PriceJSONView "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/views/prices/show.json.jbuilder"
    click Connection "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/channels/application_cable/connection.rb"
    click Channel "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/channels/application_cable/channel.rb"
    click Models "https://github.com/richardmaycode/mobbwash_clone/tree/main/app/models"
    click ActiveJobNode "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/jobs/application_job.rb"
    click WebPushService "https://github.com/richardmaycode/mobbwash_clone/blob/main/lib/webpush/notification.rb"
    click PWAManifest "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/views/pwa/manifest.json.erb"
    click ServiceWorker "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/views/pwa/service-worker.js"
    click Stimulus "https://github.com/richardmaycode/mobbwash_clone/tree/main/app/javascript/controllers"
    click Tailwind "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/assets/stylesheets/application.tailwind.css"
    click TailwindConfig "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/tailwind.config.js"
    click ImportmapConfig "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/importmap.rb"
    click Routing "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/routes.rb"
    click DB "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/database.yml"
    click ActiveStorage "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/storage.yml"
    click JobQueue "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/solid_queue.yml"
    click WebSocketConfig "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/cable.yml"
    click CSP "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/initializers/content_security_policy.rb"
    click PermissionsPolicy "https://github.com/richardmaycode/mobbwash_clone/blob/main/config/initializers/permissions_policy.rb"
    click Mailer "https://github.com/richardmaycode/mobbwash_clone/blob/main/app/mailers/application_mailer.rb"
    click Dockerfile "https://github.com/richardmaycode/mobbwash_clone/tree/main/Dockerfile"
    click Procfile "https://github.com/richardmaycode/mobbwash_clone/blob/main/Procfile.dev"
    click GemfileNode "https://github.com/richardmaycode/mobbwash_clone/tree/main/Gemfile"
    click RubyVersion "https://github.com/richardmaycode/mobbwash_clone/blob/main/.ruby-version"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef backend fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef data fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef external fill:#eeeeee,stroke:#757575,color:#424242
    classDef config fill:#e1bee7,stroke:#8e24aa,color:#4a148c
```
