# okturan/catching-app architecture

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

- Interactive diagram: https://gitdiagram.com/okturan/catching-app
- Repository: https://github.com/okturan/catching-app

## Overview

##### Project type and purpose
- Catching App is a full-stack web application built in Ruby on Rails.
- Its main purpose is event planning and scheduling among friends, with features like user authentication, event creation, invitations, and time-slot visualization.

##### File structure
- Top-level “app” directory splits MVC concerns:
- app/controllers (business logic & HTTP endpoints)
- app/models (domain objects: User, Event, Activity, TimeSlot, UserEvent)
- app/views (ERB templates for HTML rendering)
- app/javascript & app/assets handle front-end assets:
- JavaScript packs (Webpacker), custom components, ActionCable channels
- SCSS stylesheets organized by components/pages
- config/: Rails environment & routing (config/routes.rb)
- db/: migrations, schema, seeds (PostgreSQL)
- lib/: custom rake tasks or code generators
- test/: automated tests (controllers, models, system)

##### Key insights from README
- Uses Devise for authentication
- ActionCable enables real-time features (e.g., live time-slot updates)
- Bootstrap + SCSS for styling; Moment.js for date/time in JS components
- PostgreSQL database
- Standard Rails toolchain (Rake, Puma, Webpacker)

##### Main components & their interactions
a. Client (Browser)
- Issues HTTP requests for pages (Rails views) and JSON endpoints via AJAX
- Opens WebSocket channel for real-time updates (ActionCable)
- Runs JS components (time-slot definer, multiple select) bundled by Webpacker
b. Rails App Server (Puma)
- Routes incoming HTTP to controllers
- Renders views or serves JSON
- Authenticates via Devise
- Broadcasts/subscribes over ActionCable
c. Database (PostgreSQL)
- Persists Users, Events, TimeSlots, Activities, UserEvents
- Schema defined via db/migrate/ and db/schema.rb
d. Background Jobs (ActiveJob + optional adapter)
- Handles asynchronous tasks (e.g., sending invitation emails via ActionMailer)
e. Asset Pipeline & Webpacker
- SCSS → CSS (Sprockets pipeline)
- JS modules → bundled scripts (Webpack)
f. External Services
- Email delivery via SMTP or third-party (SendGrid, Mailgun)
- File storage if using ActiveStorage (e.g., AWS S3)

##### Architectural patterns & design principles
- MVC separation (app/controllers, models, views)
- Real-time pub/sub via WebSockets (ActionCable)
- Single code-base deployment (monolith) with clear modular sub-directories
- Convention-over-configuration (standard Rails conventions)
- RESTful routing (config/routes.rb)

- Controllers (HTTP entry points)
- Views (ERB templates)
- Models (ActiveRecord, business logic)
- Channels (ActionCable)
- Assets (SCSS & Webpacker bundles)
- Initializers & config modules

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        JS_Pack["application.js"]:::frontend
        TS_Definer["time_slot_definer.js"]:::frontend
        Multi_Select["multiple_select.js"]:::frontend
        TS_Show["time_slot_show.js"]:::frontend
        Dashboard_Tabs["dashboard_tabs.js"]:::frontend
        WS_Consumer["consumer.js"]:::frontend
        WS_Index["index.js"]:::frontend
        SCSS_Component["_time_slot_definer.scss"]:::frontend
        SCSS_Page["_index.scss"]:::frontend
    end

    %% Rails Server Layer
    subgraph "Rails Server (Puma)" 
        direction TB
        subgraph "Controllers" 
            direction TB
            EventsCtrl["events_controller.rb"]:::backend
            TimeSlotsCtrl["time_slots_controller.rb"]:::backend
            ActivitiesCtrl["activities_controller.rb"]:::backend
            DashboardsCtrl["dashboards_controller.rb"]:::backend
            PagesCtrl["pages_controller.rb"]:::backend
            DeviseInit["devise.rb (initializer)"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["user.rb"]:::backend
            EventModel["event.rb"]:::backend
            ActivityModel["activity.rb"]:::backend
            TimeSlotModel["time_slot.rb"]:::backend
            UserEventModel["user_event.rb"]:::backend
        end
        subgraph "Views"
            direction TB
            ERB_EventNew["events/new.html.erb"]:::backend
            ERB_EventShow["events/show.html.erb"]:::backend
            ERB_TimeSlotNew["time_slots/new.html.erb"]:::backend
            ERB_ActivityIndex["activities/index.html.erb"]:::backend
            ERB_ActivityShow["activities/show.html.erb"]:::backend
            ERB_Dashboard["dashboards/show.html.erb"]:::backend
            DeviseViews["views/devise/*"]:::backend
            Layouts["layouts/application.html.erb"]:::backend
            SharedViews["shared/_navbar.html.erb"]:::backend
        end
        subgraph "Channels (ActionCable)"
            direction TB
            Conn["connection.rb"]:::backend
            ChannelBase["channel.rb"]:::backend
            CableConfig["cable.yml"]:::backend
        end
        subgraph "Assets & Config"
            direction TB
            Webpacker["webpacker.yml"]:::backend
            WebpackerJS["config/webpack/*.js"]:::backend
            Routes["routes.rb"]:::backend
            PumaCfg["puma.rb"]:::backend
        end
    end

    %% Database Layer
    Database["PostgreSQL"]:::datastore

    %% Background Worker
    Worker["ActiveJob / Mailers"]:::backend

    %% External Services
    subgraph "External Services"
        direction TB
        EmailSvc["SMTP / SendGrid"]:::external
        StorageSvc["AWS S3 (ActiveStorage)"]:::external
    end

    %% Connections
    JS_Pack -->|HTTP/HTML, JSON| EventsCtrl
    TS_Definer -->|AJAX/JSON| TimeSlotsCtrl
    Multi_Select -->|AJAX/JSON| ActivitiesCtrl
    TS_Show -->|AJAX/JSON| TimeSlotsCtrl
    Dashboard_Tabs -->|AJAX/JSON| DashboardsCtrl
    JS_Pack -.->|WebSocket| Conn
    WS_Consumer -.->|WebSocket| ChannelBase
    WS_Index -.->|WebSocket| ChannelBase

    EventsCtrl -->|SQL| Database
    TimeSlotsCtrl -->|SQL| Database
    ActivitiesCtrl -->|SQL| Database
    DashboardsCtrl -->|SQL| Database
    PagesCtrl -->|SQL| Database

    EventsCtrl -->|Enqueue Job| Worker
    TimeSlotsCtrl -->|Enqueue Job| Worker

    Worker -->|SMTP API| EmailSvc
    Worker -->|S3 API| StorageSvc

    %% Click Events
    click JS_Pack "https://github.com/okturan/catching-app/blob/master/app/javascript/packs/application.js"
    click TS_Definer "https://github.com/okturan/catching-app/blob/master/app/javascript/components/time_slot_definer.js"
    click Multi_Select "https://github.com/okturan/catching-app/blob/master/app/javascript/components/multiple_select.js"
    click TS_Show "https://github.com/okturan/catching-app/blob/master/app/javascript/components/time_slot_show.js"
    click Dashboard_Tabs "https://github.com/okturan/catching-app/blob/master/app/javascript/components/dashboard_tabs.js"
    click WS_Consumer "https://github.com/okturan/catching-app/blob/master/app/javascript/channels/consumer.js"
    click WS_Index "https://github.com/okturan/catching-app/blob/master/app/javascript/channels/index.js"
    click SCSS_Component "https://github.com/okturan/catching-app/blob/master/app/assets/stylesheets/components/_time_slot_definer.scss"
    click SCSS_Page "https://github.com/okturan/catching-app/blob/master/app/assets/stylesheets/pages/_index.scss"
    click EventsCtrl "https://github.com/okturan/catching-app/blob/master/app/controllers/events_controller.rb"
    click TimeSlotsCtrl "https://github.com/okturan/catching-app/blob/master/app/controllers/time_slots_controller.rb"
    click ActivitiesCtrl "https://github.com/okturan/catching-app/blob/master/app/controllers/activities_controller.rb"
    click DashboardsCtrl "https://github.com/okturan/catching-app/blob/master/app/controllers/dashboards_controller.rb"
    click PagesCtrl "https://github.com/okturan/catching-app/blob/master/app/controllers/pages_controller.rb"
    click DeviseInit "https://github.com/okturan/catching-app/blob/master/config/initializers/devise.rb"
    click UserModel "https://github.com/okturan/catching-app/blob/master/app/models/user.rb"
    click EventModel "https://github.com/okturan/catching-app/blob/master/app/models/event.rb"
    click ActivityModel "https://github.com/okturan/catching-app/blob/master/app/models/activity.rb"
    click TimeSlotModel "https://github.com/okturan/catching-app/blob/master/app/models/time_slot.rb"
    click UserEventModel "https://github.com/okturan/catching-app/blob/master/app/models/user_event.rb"
    click ERB_EventNew "https://github.com/okturan/catching-app/blob/master/app/views/events/new.html.erb"
    click ERB_EventShow "https://github.com/okturan/catching-app/blob/master/app/views/events/show.html.erb"
    click ERB_TimeSlotNew "https://github.com/okturan/catching-app/blob/master/app/views/time_slots/new.html.erb"
    click ERB_ActivityIndex "https://github.com/okturan/catching-app/blob/master/app/views/activities/index.html.erb"
    click ERB_ActivityShow "https://github.com/okturan/catching-app/blob/master/app/views/activities/show.html.erb"
    click ERB_Dashboard "https://github.com/okturan/catching-app/blob/master/app/views/dashboards/show.html.erb"
    click DeviseViews "https://github.com/okturan/catching-app/tree/master/app/views/devise/registrations/"
    click Layouts "https://github.com/okturan/catching-app/blob/master/app/views/layouts/application.html.erb"
    click SharedViews "https://github.com/okturan/catching-app/blob/master/app/views/shared/_navbar.html.erb"
    click Conn "https://github.com/okturan/catching-app/blob/master/app/channels/application_cable/connection.rb"
    click ChannelBase "https://github.com/okturan/catching-app/blob/master/app/channels/application_cable/channel.rb"
    click CableConfig "https://github.com/okturan/catching-app/blob/master/config/cable.yml"
    click Webpacker "https://github.com/okturan/catching-app/blob/master/config/webpacker.yml"
    click WebpackerJS "https://github.com/okturan/catching-app/tree/master/config/webpack/"
    click Routes "https://github.com/okturan/catching-app/blob/master/config/routes.rb"
    click PumaCfg "https://github.com/okturan/catching-app/blob/master/config/puma.rb"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#2980B9;
    classDef backend fill:#D5F5E3,stroke:#27AE60;
    classDef datastore fill:#FCF3CF,stroke:#F1C40F;
    classDef external fill:#F2F2F2,stroke:#7F8C8D;
```
