# tarunvelli/rails-tabler-starter architecture

> Architecture diagram of the GitHub repository tarunvelli/rails-tabler-starter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tarunvelli/rails-tabler-starter
- Repository: https://github.com/tarunvelli/rails-tabler-starter

## Overview

##### Main Components

A. Frontend Layer:
- Views (app/views) using ERB templates
- Assets (JavaScript, CSS) using Tabler UI framework
- Client-side controllers using Stimulus.js (app/javascript/controllers)

B. Backend Layer:
- Rails Controllers (app/controllers)
- Models (app/models)
- Background Jobs (Sidekiq)
- Authentication (Devise)
- Authorization (Pundit)

C. Data Layer:
- PostgreSQL Database
- Redis (for Sidekiq)
- Active Storage

##### Component Relationships

**[Client Browser] ←→ [Frontend Layer]**
- ↓
**[Rails Application]**
- ↙     ↓     ↘
**[PostgreSQL] [Redis] [Storage]**

##### Specific Implementation Details

a) User Management System:
- Devise Authentication
- OmniAuth Integration
- User Roles & Permissions

b) Multi-tenant Architecture:
- Spaces (Organizations/Teams)
- Subscription Management
- Role Management

c) Background Processing:
- Sidekiq Workers
- Scheduled Jobs

##### Important Flows to Highlight

a) Authentication Flow:
**User → Devise → OmniAuth → Application**

b) Authorization Flow:
**Request → Pundit Policies → Controller → Response**

c) Multi-tenant Flow:
**User → Space → Roles → Permissions**

##### Additional Elements

Architectural patterns:
- MVC pattern implementation
- Service-oriented components
- Policy objects (Pundit)
- Background job processing

##### Technical Stack Callouts

Key technologies:
- Ruby on Rails
- PostgreSQL
- Redis
- Sidekiq
- Devise
- Pundit
- Tabler UI
- Stimulus.js

##### Deployment Components

Deployment-related elements:
- Asset compilation
- Database migrations
- Background job workers
- Storage service

Remember to emphasize:
##### The background processing capabilities

This will give other developers a clear understanding of how the different parts of the system interact while highlighting the key architectural decisions that make this starter template powerful and flexible.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Frontend Layer"
        Views["Views (ERB)"]:::frontend
        Assets["Assets (Tabler UI)"]:::frontend
        StimulusControllers["Stimulus Controllers"]:::frontend
    end

    subgraph "Application Layer"
        Controllers["Rails Controllers"]:::backend
        Models["Models"]:::backend
        
        subgraph "Authentication"
            Devise["Devise"]:::auth
            OmniAuth["OmniAuth"]:::auth
        end
        
        subgraph "Authorization"
            Pundit["Pundit Policies"]:::auth
        end
        
        subgraph "Multi-tenant"
            Spaces["Spaces"]:::tenant
            Roles["Roles"]:::tenant
            Subscriptions["Subscriptions"]:::tenant
        end
        
        subgraph "Background Processing"
            Sidekiq["Sidekiq Workers"]:::worker
            ScheduledJobs["Scheduled Jobs"]:::worker
        end
    end

    subgraph "Data Layer"
        PostgreSQL[(PostgreSQL)]:::storage
        Redis[(Redis)]:::storage
        ActiveStorage["Active Storage"]:::storage
    end

    Browser --> Views
    Views --> Controllers
    Assets --> Views
    StimulusControllers --> Views
    
    Controllers --> Models
    Models --> PostgreSQL
    
    Controllers --> Devise
    Devise --> OmniAuth
    Controllers --> Pundit
    
    Controllers --> Spaces
    Spaces --> Roles
    Spaces --> Subscriptions
    
    Controllers --> Sidekiq
    Sidekiq --> Redis
    ScheduledJobs --> Sidekiq
    
    Models --> ActiveStorage

    %% Component Mappings
    click Views "https://github.com/tarunvelli/rails-tabler-starter/tree/main/app/views/"
    click Assets "https://github.com/tarunvelli/rails-tabler-starter/tree/main/app/assets/stylesheets/"
    click StimulusControllers "https://github.com/tarunvelli/rails-tabler-starter/tree/main/app/javascript/controllers/"
    click Controllers "https://github.com/tarunvelli/rails-tabler-starter/tree/main/app/controllers/"
    click Models "https://github.com/tarunvelli/rails-tabler-starter/tree/main/app/models/"
    click Devise "https://github.com/tarunvelli/rails-tabler-starter/blob/main/config/initializers/devise.rb"
    click Pundit "https://github.com/tarunvelli/rails-tabler-starter/blob/main/app/policies/application_policy.rb"
    click Spaces "https://github.com/tarunvelli/rails-tabler-starter/blob/main/app/models/space.rb"
    click Roles "https://github.com/tarunvelli/rails-tabler-starter/blob/main/app/models/role.rb"
    click Subscriptions "https://github.com/tarunvelli/rails-tabler-starter/blob/main/app/models/subscription.rb"
    click Sidekiq "https://github.com/tarunvelli/rails-tabler-starter/blob/main/config/initializers/sidekiq.rb"
    click PostgreSQL "https://github.com/tarunvelli/rails-tabler-starter/blob/main/config/database.yml"
    click ActiveStorage "https://github.com/tarunvelli/rails-tabler-starter/blob/main/config/storage.yml"

    %% Styling
    classDef frontend fill:#e1bee7,stroke:#000
    classDef backend fill:#90caf9,stroke:#000
    classDef auth fill:#81c784,stroke:#000
    classDef tenant fill:#fff59d,stroke:#000
    classDef worker fill:#ce93d8,stroke:#000
    classDef storage fill:#ffab91,stroke:#000

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Backend["Backend"]:::backend
        Auth["Auth"]:::auth
        Tenant["Multi-tenant"]:::tenant
        Worker["Background Jobs"]:::worker
        Storage["Storage"]:::storage
    end
```
