# hassyyy/expense-manager-hassyyy architecture

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

- Interactive diagram: https://gitdiagram.com/hassyyy/expense-manager-hassyyy
- Repository: https://github.com/hassyyy/expense-manager-hassyyy

## Overview

##### Main Components
- Client (Browser)
- Load Balancer / Procfile (Heroku-style process)
- Web Server (Puma)
- Rails Application
- Router & Middleware
- Controllers (including Avo admin controllers)
- Models (ActiveRecord + DB)
- Views & Assets (Importmap, Stimulus controllers, CSS)
- ActiveJob (background jobs)
- ActionMailer (emails)
- ActionCable (WebSockets)
- Avo Admin (dashboard, cards, filters, actions)
- Database (PostgreSQL / MySQL / SQLite)
- Storage (ActiveStorage local/files or cloud)
- External Services
- Expensify API integration (via app/avo/actions/expensify.rb)
- Email SMTP provider

##### Relationships & Interactions
- Browser → HTTP(S) → Load Balancer / Dyno → Puma → Rails Router
- Router dispatches to Controllers → interact with Models (ActiveRecord → DB)
- Controllers render Views (ERB) and serve Assets (JS/CSS via Importmap + Stimulus)
- Avo Admin UI is a mounted Rails Engine under /avo, using its own Controllers, Views, Cards, Filters, and Actions
- Background tasks (e.g., sending receipts, scheduled jobs) flow from Controllers or Jobs → ActiveJob → Job Adapter → execution
- Real-time features (if any) use ActionCable → browser WebSocket connection
- ActiveStorage manages file uploads → Storage layer (local disk or S3)
- External API calls (Expensify) originate from Avo Actions or Jobs
- Outbound email via ActionMailer → SMTP service

##### Architectural Patterns & Technologies
- MVC (Model-View-Controller) at core
- Rails Engine (Avo) for admin interface
- Importmap + Stimulus.js for front-end interactivity (no webpacker)
- ActiveJob for asynchronous processing
- ActionCable for real-time channel support
- ActiveStorage for file handling
- Standard Rails initializers & config/environments for environment-specific behavior

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client/Web Tier
    Browser["Client (Browser)"]:::client
    Procfile["Load Balancer / Procfile Dyno"]:::web
    Puma["Puma Web Server"]:::web

    Browser -->|"HTTP(S)"| Procfile
    Procfile -->|"forwards request"| Puma

    %% Application Tier
    subgraph "Rails Application"
        direction TB
        Router["Router & Middleware"]:::app
        Controllers["Controllers"]:::app
        AvoControllers["Avo Admin Controllers"]:::app
        subgraph "Views & Assets"
            direction TB
            Views["Views (ERB)"]:::app
            JSAssets["JS Entry & Controllers"]:::app
            CSSAssets["Stylesheets"]:::app
            Importmap["Importmap Config"]:::app
        end
        Models["Models (ActiveRecord)"]:::app
        Jobs["ActiveJob"]:::app
        Mailers["ActionMailer"]:::app
        Channels["ActionCable"]:::app
        subgraph "Avo Engine"
            direction TB
            AvoInit["Avo Config"]:::app
            AvoActions["Actions"]:::app
            AvoCards["Cards"]:::app
            AvoDash["Dashboards"]:::app
            AvoFilters["Filters"]:::app
            AvoResources["Resources"]:::app
            AvoViews["Avo Views/Partials"]:::app
        end
    end

    Puma -->|"routes to"| Router
    Router -->|"invokes"| Controllers
    Router -->|"mounts /avo"| AvoControllers
    Controllers -->|"DB query (SQL)"| Models
    Models -->|"reads/writes"| Database
    Controllers -->|"render"| Views
    Controllers -->|"serve assets"| JSAssets
    Controllers -->|"serve assets"| CSSAssets
    Controllers -->|"serve assets"| Importmap
    Controllers -->|"enqueue job"| Jobs
    Controllers -->|"send email"| Mailers
    Controllers -->|"upload/download"| Storage
    Browser -->|"WebSocket"| Channels
    AvoControllers -->|"load engine"| AvoInit
    AvoControllers -->|"execute actions"| AvoActions
    AvoControllers -->|"render cards"| AvoCards
    AvoControllers -->|"render dashboards"| AvoDash
    AvoControllers -->|"apply filters"| AvoFilters
    AvoControllers -->|"manage resources"| AvoResources
    AvoControllers -->|"render views"| AvoViews
    AvoActions -->|"API request"| Expensify

    %% Data Tier
    Database["Database (PostgreSQL/etc.)"]:::data
    Storage["Storage (ActiveStorage)"]:::data

    %% External Services
    subgraph "External Services"
        SMTP["SMTP Provider"]:::external
        Expensify["Expensify API"]:::external
    end

    Mailers -->|"SMTP"| SMTP
    AvoActions -->|"HTTP API"| Expensify

    %% Click events
    click Procfile "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/Procfile"
    click Puma "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/puma.rb"
    click Router "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/routes.rb"
    click Controllers "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/controllers"
    click AvoControllers "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/controllers/avo"
    click Models "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/models"
    click Views "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/views"
    click JSAssets "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/app/javascript/application.js"
    click JSAssets "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/javascript/controllers"
    click CSSAssets "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/app/assets/stylesheets/application.css"
    click Importmap "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/importmap.rb"
    click Jobs "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/jobs"
    click Mailers "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/app/mailers/application_mailer.rb"
    click Channels "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/cable.yml"
    click AvoInit "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/initializers/avo.rb"
    click AvoActions "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/avo/actions"
    click AvoCards "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/avo/cards"
    click AvoDash "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/avo/dashboards"
    click AvoFilters "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/avo/filters"
    click AvoResources "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/avo/resources"
    click AvoViews "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/app/views/avo"
    click Database "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/database.yml"
    click Database "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/db/migrate"
    click Database "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/db/schema.rb"
    click Storage "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/storage.yml"
    click Storage "https://github.com/hassyyy/expense-manager-hassyyy/tree/main/storage/"
    click Expensify "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/app/avo/actions/expensify.rb"
    click SMTP "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/config/environments/production.rb"
    click SMTP "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/app/views/layouts/mailer.html.erb"
    click SMTP "https://github.com/hassyyy/expense-manager-hassyyy/blob/main/app/views/layouts/mailer.text.erb"

    %% Styles
    classDef client fill:#a2d5f2,stroke:#2176ae,stroke-width:2px
    classDef web fill:#cce5ff,stroke:#004085,stroke-width:2px
    classDef app fill:#d4edda,stroke:#155724,stroke-width:2px
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px
```
