# yashsharma1101/cricket-auction-app architecture

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

- Interactive diagram: https://gitdiagram.com/yashsharma1101/cricket-auction-app
- Repository: https://github.com/yashsharma1101/cricket-auction-app

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Ruby on Rails (MVC).
- It manages Users, Teams, Matches, and Admins; sends emails via Action Mailer; stores assets (Active Storage + Cloudinary); provides real-time features via Action Cable; and runs background jobs via Active Job.

##### File Structure for Architectural Components
- app/controllers, app/models, app/views → MVC layers.
- app/assets, app/javascript/packs → Frontend assets & JavaScript (Webpacker/Yarn).
- app/channels → WebSocket channels (Action Cable).
- app/jobs → Background tasks (Active Job, queued in Redis/Sidekiq or default).
- app/mailers → Email generation (SMTP or external).
- config/routes.rb → HTTP and WebSocket entry points.
- config/database.yml, db/migrate → Relational database (e.g., PostgreSQL).
- config/storage.yml, config/cloudinary.yml → File storage (Cloudinary or S3).
- bin/webpack, config/webpack/* → JS build pipeline.
- config/environments → Environment-specific settings.
- Gemfile → Ruby gem dependencies.
- package.json → NPM/Yarn dependencies.
- Rakefile → Build & maintenance tasks.
- render.yaml → Deployment configuration (Render.com).

##### Core System Components
a. Client (Web Browser / JS)
- Sends HTTP(S) requests.
- Connects via WebSockets for real-time updates.
b. Web Server & App Server
- Puma serving Rails Rack app (config.ru).
- Routes to controllers.
c. Rails MVC
- Controllers handle business logic.
- Models (Active Record) interact with the database.
- Views render HTML/JSON.
d. Database
- PostgreSQL (or configured SQL DB).
e. File Storage
- Active Storage pointing to Cloudinary (configured in storage.yml & cloudinary.yml).
f. Asset Pipeline & Bundler
- Sprockets (app/assets) + Webpacker (app/javascript) for CSS/JS.
g. Background Processing
- Active Job enqueues mailers (MailerJob) and other jobs to a queue backend (e.g., Redis/Sidekiq).
h. Action Mailer
- Sends transactional emails (AccessFormMailer, AuctionMailer).
i. Action Cable
- Real-time channels (app/channels) over Redis (pub/sub) for live updates (e.g., bidding sounds).
j. External Services
- Cloudinary for media.
- SMTP provider for email.
- Redis for caching/Action Cable / job queue.
- Optional: CDN for static assets.
k. Deployment
- Render.com (render.yaml), Docker or native builds via bin/render-build.sh.

##### Relationships and Data Flow
- Browser → HTTP → Puma → Rails Router → Controller → Model → Database → Model → Controller → View → Browser.
- Browser → WebSocket → Action Cable Server → Channel → Broadcast → Browser.
- Controller enqueues background jobs for heavy tasks or emails.
- Jobs run asynchronously, interacting with DB, Storage, Mailer.
- Active Storage handles file I/O to Cloudinary.
- Gems and npm packages support various subsystems (authentication, admin UI, asset compilation).

##### Architectural Patterns & Design Principles
- MVC for clear separation of concerns.
- Service-oriented within Rails: Mailers, Jobs, Channels as distinct services.
- Convention over configuration—standard Rails directory layout.
- Modular assets: separation of Sprockets assets vs. Webpacker packs.
- Namespaced admin area (app/controllers/admin, app/views/admin).
- Use of concerns to share code.

1. Sketch the browser at the left, splitting HTTP vs. WebSocket.
- Web Server (Puma)
- Router & Controllers
- Models & Active Record
- Views & Asset Server
- Channels & Jobs & Mailers
4. Storage (Cloudinary) connected to Active Storage.
5. External SMTP service linked to Action Mailer.
6. Build-time step: Yarn/Webpack → compiled JS/CSS output to app/public/assets.
7. Admin namespace (ActiveAdmin assets, admin controllers/views).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Browser"]:::frontend
        Assets["Assets (images, CSS, JS)"]:::frontend
        Packs["JS Bundle (application.js)"]:::frontend
    end

    %% Rails Application Layer
    subgraph "Rails Application"
        direction TB

        subgraph "Server"
            direction TB
            Puma["Puma Server"]:::rails
            Rack["Rack Entry Point (config.ru)"]:::rails
        end

        Router["Router (config/routes.rb)"]:::rails

        subgraph "Controllers"
            direction TB
            UsersCtrl["UsersController"]:::rails
            MatchesCtrl["MatchesController"]:::rails
            TeamsCtrl["TeamsController"]:::rails
            AdmDashCtrl["Admin::DashboardController"]:::rails
            AdmUsersCtrl["Admin::UsersController"]:::rails
            AdmMainCtrl["AdminController"]:::rails
            AdmSessionsCtrl["AdminSessionsController"]:::rails
        end

        subgraph "Models"
            direction TB
            UserModel["user.rb"]:::rails
            TeamModel["team.rb"]:::rails
            MatchModel["match.rb"]:::rails
            AdminModel["admin.rb"]:::rails
            AccessFormModel["access_form.rb"]:::rails
        end

        subgraph "Views & Templates"
            direction TB
            PublicViews["Public Views"]:::rails
            AdminViews["Admin Views"]:::rails
            MailerViews["Mailer Views"]:::rails
        end

        subgraph "Channels, Jobs & Mailers"
            direction TB
            CableServer["Action Cable Channels"]:::rails
            Jobs["Background Jobs"]:::background
            Mailers["Action Mailer"]:::rails
        end

        subgraph "Asset Pipeline & Bundler"
            direction TB
            Sprockets["Sprockets (app/assets)"]:::rails
            Webpacker["Webpacker"]:::rails
        end
    end

    %% Data Layer
    subgraph "Data & Storage"
        direction TB
        DB["PostgreSQL"]:::external
        Redis["Redis (Cache/Queue)"]:::external
        Storage["Active Storage → Cloudinary"]:::external
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP Provider"]:::external
        CDN["CDN"]:::external
    end

    %% Deployment & Config
    subgraph "Deployment & Config"
        direction TB
        DeployCFG["render.yaml"]:::external
        BuildScript["bin/render-build.sh"]:::external
        EnvSettings["Environment Settings"]:::external
        Initializers["Initializers"]:::external
        RakeTasks["Rakefile & lib/tasks"]:::external
        Tests["Test Suite"]:::external
    end

    %% Connections: Client → Server
    Browser -->|HTTPS| Puma
    Browser -->|WebSocket| CableServer
    Assets -->|served by| Sprockets
    Packs -->|served by| Webpacker

    %% Server Internals
    Puma --> Rack
    Rack --> Router
    Router --> UsersCtrl
    Router --> MatchesCtrl
    Router --> TeamsCtrl
    Router --> AdmDashCtrl
    Router --> AdmUsersCtrl
    Router --> AdmMainCtrl
    Router --> AdmSessionsCtrl

    %% MVC Flow
    UsersCtrl --> UserModel
    MatchesCtrl --> MatchModel
    TeamsCtrl --> TeamModel
    AdmDashCtrl --> AdminModel
    AdmUsersCtrl --> AdminModel
    UsersCtrl --> Views
    MatchesCtrl --> Views
    TeamsCtrl --> Views
    AdmDashCtrl --> Views
    AdmUsersCtrl --> Views
    Controllers -->|async| Jobs
    Controllers -->|async| Mailers

    %% Models to DB & Storage
    UserModel --> DB
    TeamModel --> DB
    MatchModel --> DB
    AdminModel --> DB
    AccessFormModel --> DB
    UserModel --> Storage
    TeamModel --> Storage

    %% Channels & Jobs
    CableServer --> Redis
    Jobs --> Redis
    Jobs --> DB
    Jobs --> Storage
    Jobs -->|send| Mailers
    Mailers --> SMTP

    %% Asset Pipeline Output
    Sprockets --> Browser
    Webpacker --> Browser
    CDN --> Browser

    %% Deployment & Config Flows
    DeployCFG --> Puma
    BuildScript --> Webpacker
    EnvSettings --> Puma
    Initializers --> RailsApplication
    RakeTasks --> RailsApplication
    Tests --> RailsApplication

    %% Click Events
    click Assets "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/assets"
    click Packs "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/javascript/packs/application.js"
    click Puma "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/puma.rb"
    click Rack "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config.ru"
    click Router "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/routes.rb"
    click UsersCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/users_controller.rb"
    click MatchesCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/matches_controller.rb"
    click TeamsCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/teams_controller.rb"
    click AdmDashCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/admin/dashboard_controller.rb"
    click AdmUsersCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/admin/users_controller.rb"
    click AdmMainCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/admin_controller.rb"
    click AdmSessionsCtrl "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/controllers/admin_sessions_controller.rb"
    click UserModel "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/models/user.rb"
    click TeamModel "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/models/team.rb"
    click MatchModel "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/models/match.rb"
    click AdminModel "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/models/admin.rb"
    click AccessFormModel "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/models/access_form.rb"
    click PublicViews "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/views/users"
    click PublicViews "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/views/matches"
    click PublicViews "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/views/teams"
    click AdminViews "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/views/admin/dashboard"
    click AdminViews "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/views/admin/users"
    click MailerViews "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/views/access_form_mailer"
    click CableServer "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/channels/application_cable/connection.rb"
    click CableServer "https://github.com/yashsharma1101/cricket-auction-app/tree/master/app/javascript/channels"
    click Jobs "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/jobs/application_job.rb"
    click Mailers "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/jobs/mailer_job.rb"
    click Mailers "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/mailers/access_form_mailer.rb"
    click Mailers "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/mailers/auction_mailer.rb"
    click Mailers "https://github.com/yashsharma1101/cricket-auction-app/blob/master/app/mailers/application_mailer.rb"
    click DB "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/database.yml"
    click Storage "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/storage.yml"
    click Storage "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/cloudinary.yml"
    click Redis "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/cable.yml"
    click DeployCFG "https://github.com/yashsharma1101/cricket-auction-app/blob/master/render.yaml"
    click BuildScript "https://github.com/yashsharma1101/cricket-auction-app/blob/master/bin/render-build.sh"
    click EnvSettings "https://github.com/yashsharma1101/cricket-auction-app/blob/master/config/environments/development.rb"
    click Initializers "https://github.com/yashsharma1101/cricket-auction-app/tree/master/config/initializers"
    click RakeTasks "https://github.com/yashsharma1101/cricket-auction-app/tree/master/Rakefile"
    click Tests "https://github.com/yashsharma1101/cricket-auction-app/tree/master/test/"
    
    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366D6;
    classDef rails fill:#E6FFEA,stroke:#22863A;
    classDef external fill:#FFF5B1,stroke:#E36209;
    classDef background fill:#FFEFE6,stroke:#D73A49;
```
