# sebarmano/garage architecture

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

- Interactive diagram: https://gitdiagram.com/sebarmano/garage
- Repository: https://github.com/sebarmano/garage

## Overview

##### Main Components
- Frontend/UI Layer – Represented by the assets and views folders. This layer handles the user interface (HTML, JavaScript, CSS) for various roles (e.g., admin, customer). Note the segmented views (e.g., dashboards, calendars, appointments) that indicate specific user interfaces.
- Application/Business Logic Layer – Represented by the controllers, models, and mailers. This includes:
- Controllers (appointments, customers, cars, dashboards, etc.) that orchestrate the HTTP requests.
- Models (appointment, car, customer, assignment, etc.) that capture the business domain.
- Mailers (appointment_mailer and devise mailers) which handle communications.
- Background job processing (e.g., delayed jobs as hinted by the presence of migration files and related rake tasks).
- Database – Evidently a PostgreSQL database (as configured in config/database.yml and schema files). This stores all persistent data such as customer records, appointments, assignments, and jobs.
- External Services – Although not depicted as separate microservices, note that email/SMS notifications may be using external providers. These should be displayed as external integration points communicating with the Application Layer (via mailer actions).

##### Depicting Relationships & Interactions
- From the User Interface (Browser) to the Application Server (via HTTP requests to controllers) for creating appointments, updating customer details, etc.
- From Controllers to Models (business logic layer) to persist and retrieve data.
- From Controllers to Mailers to trigger appointment confirmations and reminders.
- From the Rails application to external services (email providers/SMS gateways) for notifications.
- From background job components (e.g., Delayed Job) back to the Application for asynchronous tasks.
- Clearly label these interactions (e.g., “HTTP Request”, “Database Query”, “Email/SMS Notification”).

##### Architectural Patterns & Principles
- MVC Pattern – The application is clearly structured as a Model-View-Controller architecture.
- Service Separation & Asynchronous Processing – Emphasize that mailers and background jobs create a separation of concerns by handling notifications and heavy processes asynchronously.
- Modularization & Extensibility – The project’s directory structure indicates a modular organization (separate folders for assets, controllers, views, models, and configurations) that supports easy future extension.

##### Relevant Technologies, Frameworks, and Libraries
- Ruby on Rails framework is the backbone.
- Devise is used for authentication.
- The asset pipeline (JavaScript/CSS management) for frontend assets.
- Delayed Job (or similar) for background processing.
- PostgreSQL as the database engine.
- Testing frameworks (RSpec) for quality assurance (this might be noted as part of the overall development process).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    Browser["Web Browser"]:::frontend
    subgraph "Frontend/UI Layer"
        Assets["Assets (HTML/CSS/JS)"]:::frontend
        Views["Views"]:::frontend
    end

    %% Application/Business Logic Layer
    subgraph "Application/Business Logic Layer"
        subgraph "Controllers Layer"
            AppointmentsController["Appointments Controller"]:::backend
            CarsController["Cars Controller"]:::backend
            DashboardsController["Dashboards Controller"]:::backend
        end
        subgraph "Models Layer"
            AppointmentModel["Appointment Model"]:::backend
            CarModel["Car Model"]:::backend
            CustomerModel["Customer Model"]:::backend
            AssignmentModel["Assignment Model"]:::backend
            JobModel["Job Model"]:::backend
        end
        subgraph "Mailers & Jobs Layer"
            AppointmentMailer["Appointment Mailer"]:::backend
            DelayedJobs["Delayed Jobs"]:::backend
        end
    end

    %% Authentication & Authorization
    subgraph "Authentication Service"
        DeviseViews["Devise Views"]:::backend
        DeviseConfig["Devise Config"]:::backend
        Registrations["Registrations Controller"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["PostgreSQL Database"]:::database
        DBConfig["DB Config"]:::database
        DBSchema["DB Schema"]:::database
    end

    %% External Services
    External["External Email/SMS Provider"]:::external

    %% Data Flow / Interactions
    Browser -->|"HTTP_Request"| AppointmentsController
    Browser -->|"HTTP_Request"| CarsController
    Browser -->|"HTTP_Request"| DashboardsController
    Browser -->|"Auth_Login"| Registrations

    Assets -->|"Serve_Assets"| Views

    AppointmentsController -->|"CRUD"| AppointmentModel
    CarsController -->|"CRUD"| CarModel
    DashboardsController -->|"CRUD"| CustomerModel

    AppointmentModel -->|"DB_Operations"| DB
    CarModel -->|"DB_Operations"| DB
    CustomerModel -->|"DB_Operations"| DB
    AssignmentModel -->|"DB_Operations"| DB
    JobModel -->|"DB_Operations"| DB

    AppointmentsController -->|"Trigger_Email"| AppointmentMailer
    AppointmentMailer -->|"Send_Notification"| External
    AppointmentMailer -->|"Queue_Email"| DelayedJobs

    Registrations -->|"Render_Auth_Page"| DeviseViews
    Registrations -->|"Uses_Config"| DeviseConfig

    %% Click Events for Frontend/UI Layer
    click Assets "https://github.com/sebarmano/garage/tree/master/app/assets"
    click Views "https://github.com/sebarmano/garage/tree/master/app/views"

    %% Click Events for Application/Business Logic Layer
    click AppointmentsController "https://github.com/sebarmano/garage/blob/master/app/controllers/appointments_controller.rb"
    click CarsController "https://github.com/sebarmano/garage/blob/master/app/controllers/cars_controller.rb"
    click DashboardsController "https://github.com/sebarmano/garage/blob/master/app/controllers/dashboards_controller.rb"
    click AppointmentModel "https://github.com/sebarmano/garage/blob/master/app/models/appointment.rb"
    click CarModel "https://github.com/sebarmano/garage/blob/master/app/models/car.rb"
    click CustomerModel "https://github.com/sebarmano/garage/blob/master/app/models/customer.rb"
    click AssignmentModel "https://github.com/sebarmano/garage/blob/master/app/models/assignment.rb"
    click JobModel "https://github.com/sebarmano/garage/blob/master/app/models/job.rb"
    click AppointmentMailer "https://github.com/sebarmano/garage/blob/master/app/mailers/appointment_mailer.rb"
    click DelayedJobs "https://github.com/sebarmano/garage/blob/master/db/migrate/20151027155622_create_delayed_jobs.rb"

    %% Click Events for Authentication & Authorization
    click DeviseViews "https://github.com/sebarmano/garage/tree/master/app/views/devise"
    click DeviseConfig "https://github.com/sebarmano/garage/blob/master/config/initializers/devise.rb"
    click Registrations "https://github.com/sebarmano/garage/blob/master/app/controllers/registrations_controller.rb"

    %% Click Events for Database Layer
    click DBConfig "https://github.com/sebarmano/garage/blob/master/config/database.yml"
    click DBSchema "https://github.com/sebarmano/garage/blob/master/db/schema.rb"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
