# saint-james-fr/ripvinyl architecture

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

- Interactive diagram: https://gitdiagram.com/saint-james-fr/ripvinyl
- Repository: https://github.com/saint-james-fr/ripvinyl

## Overview

##### Main Components

a. Client Layer:
- Frontend (Rails Views + Stimulus.js)
- Asset Pipeline (SCSS, JavaScript)
- User Interface Components (devise views, releases views)

b. Application Layer:
- Controllers (Discogs, Releases, Pages)
- Models (User, Release, UserRelease)
- Background Jobs (Sidekiq workers)

c. External Services:
- Discogs API
- Cloudinary (Image Storage)
- Redis (for Sidekiq)

d. Data Storage:
- PostgreSQL Database
- Active Storage
- Redis Storage (for sessions)

**[Client Layer]**
- ↕️
**[Application Layer]**
- ↕️
**[Service Layer]**
- ↕️
**[Data Layer]**

##### Key Relationships to Highlight

a. Authentication Flow:
- Devise → OAuth → Discogs API
- Session Management through Redis

b. Data Flow:
- User Collection Import Process
- Background Job Processing
- Image Storage Pipeline

##### Specific Implementation Details

a. User Authentication Flow:
**[Devise] ↔️ [OAuth] ↔️ [Discogs API]**
- ↕️
**[User Model] ↔️ [Database]**

b. Collection Management Flow:
**[Discogs Controller] ↔️ [Discogs API]**
- ↓
**[Background Jobs]**
- ↙️        ↘️
**[Database]    [Cloudinary]**

##### Important Architectural Patterns

- MVC Pattern (clearly separate Models, Views, Controllers)
- Background Job Architecture (Sidekiq workers)
- Service Integration Pattern (Discogs API wrapper)
- Asset Management (Cloudinary integration)

##### Technical Stack Indicators

- Ruby on Rails
- Stimulus.js
- PostgreSQL
- Redis
- Sidekiq
- Cloudinary
- Discogs API

##### Additional Elements

Supporting components:
- OAuth Flow
- Background Job Queues
- Asset Pipeline
- Active Storage

- Any abbreviations used
- Special indicators (like async processes)

This will create a comprehensive visualization of how the vinyl ripping tracking system works, from user authentication through collection management and background processing.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        FE[Frontend Views]
        AP[Asset Pipeline]
        ST[Stimulus Controllers]
        DV[Devise Views]
    end

    subgraph Application
        direction TB
        subgraph Controllers
            DC[Discogs Controller]
            RC[Releases Controller]
            SC[Sessions Controller]
        end
        
        subgraph Models
            UM[User Model]
            RM[Release Model]
            URM[UserRelease Model]
        end
        
        subgraph Jobs
            SCJ[Save Collection Job]
            PDJ[Photo Download Job]
            FCJ[Fetch Collection Job]
        end
    end

    subgraph Services
        DA[Discogs API]
        CL[Cloudinary]
        RD[Redis]
    end

    subgraph Storage
        DB[(PostgreSQL)]
        AS[(Active Storage)]
        RS[(Redis Store)]
    end

    %% Relationships
    FE --> Controllers
    ST --> Controllers
    AP --> FE
    DV --> SC

    DC <--> DA
    DC --> Jobs
    RC --> Models
    SC --> UM

    Jobs --> DB
    Jobs --> CL
    
    Models --> DB
    Models --> AS

    RD --> Jobs
    RS --> SC

    %% Click Events
    click FE "https://github.com/saint-james-fr/ripvinyl/tree/master/app/views"
    click AP "https://github.com/saint-james-fr/ripvinyl/tree/master/app/assets"
    click ST "https://github.com/saint-james-fr/ripvinyl/tree/master/app/javascript/controllers"
    click DC "https://github.com/saint-james-fr/ripvinyl/blob/master/app/controllers/discogs_controller.rb"
    click RC "https://github.com/saint-james-fr/ripvinyl/blob/master/app/controllers/releases_controller.rb"
    click SC "https://github.com/saint-james-fr/ripvinyl/blob/master/app/controllers/users/sessions_controller.rb"
    click UM "https://github.com/saint-james-fr/ripvinyl/blob/master/app/models/user.rb"
    click RM "https://github.com/saint-james-fr/ripvinyl/blob/master/app/models/release.rb"
    click URM "https://github.com/saint-james-fr/ripvinyl/blob/master/app/models/user_release.rb"
    click SCJ "https://github.com/saint-james-fr/ripvinyl/blob/master/app/jobs/save_collection_job.rb"
    click PDJ "https://github.com/saint-james-fr/ripvinyl/blob/master/app/jobs/download_photo_job.rb"
    click FCJ "https://github.com/saint-james-fr/ripvinyl/blob/master/app/jobs/fetch_more_collection_job.rb"
    click DV "https://github.com/saint-james-fr/ripvinyl/tree/master/app/views/devise"

    %% Styling
    classDef client fill:#a8dadc
    classDef controller fill:#457b9d
    classDef model fill:#1d3557
    classDef job fill:#e63946
    classDef service fill:#f1faee
    classDef storage fill:#fca311

    class FE,AP,ST,DV client
    class DC,RC,SC controller
    class UM,RM,URM model
    class SCJ,PDJ,FCJ job
    class DA,CL,RD service
    class DB,AS,RS storage

    %% Legend
    subgraph Legend
        C1[Client Components]:::client
        C2[Controllers]:::controller
        C3[Models]:::model
        C4[Background Jobs]:::job
        C5[External Services]:::service
        C6[Storage]:::storage
    end
```
