# common-member/nightrip architecture

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

- Interactive diagram: https://gitdiagram.com/common-member/nightrip
- Repository: https://github.com/common-member/nightrip

## Overview

##### Project type and purpose
- This is a full-stack, monolithic web application built with Ruby on Rails (v7.2.2.1) serving server-rendered HTML enhanced by Hotwire (Turbo + Stimulus).
- Purpose: “NighTrip” is a night-scape search & social sharing service where users can browse, post, comment on, and “diagnose” (quiz-driven recommendations of) night-view spots; it supports user auth (Devise + Omniauth), favoriting, rankings, and PWA features.

##### File structure
- app/ contains an MVC layout: controllers (app/controllers), models (app/models), views (app/views), plus channels (Action Cable), jobs (Active Job), mailers.
- app/javascript/controllers holds Stimulus controllers for dynamic behaviors (autocomplete, comments, form steps).
- app/assets/stylesheets uses Tailwind CSS + daisyUI.
- config/ defines routes, database (PostgreSQL), storage (Active Storage → Amazon S3), cable (WebSockets), environments, initializers (e.g. Devise, Geocoder).
- Dockerfile.*, compose.yml, and render.yaml orchestrate containerization & deployment on Render; GitHub Actions for CI; Procfile.dev for local process management.

##### README
- Confirms the tech stack: Rails, Ruby 3.3.6, Turbo+Stimulus, Tailwind/DaisyUI, Google Maps API, PostgreSQL, S3, Render, Docker, GitHub Actions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Clients["Users & Browsers"]:::client

    %% Frontend Layer
    subgraph "Web Front-End" 
        direction TB
        Layout["Layout (ERB)"]:::frontend
        Styles["Tailwind CSS + daisyUI"]:::frontend
        Stimulus["Stimulus JS controllers"]:::frontend
    end

    %% Rails Application Server
    subgraph "Rails App (Rails 7.2.2.1, Ruby 3.3.6)" 
        direction TB
        Router["Router & Controllers"]:::backend
        Views["Views & Partials"]:::backend
        Models["Models & Business Logic"]:::backend
        Jobs["Background Workers (Active Job)"]:::backend
        Channels["Action Cable (WebSockets)"]:::backend
        StorageInterface["Active Storage Interface"]:::backend
        Auth["Devise + OmniAuth"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        DB["PostgreSQL"]:::datastore
        S3["Amazon S3"]:::datastore
        Redis["Redis (Pub/Sub & Caching)"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Maps["Google Maps API"]:::external
        OAuth["OAuth Providers"]:::external
        SMTP["SMTP Email"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure & DevOps"
        direction TB
        Docker["Docker & Render"]:::infra
        CI["GitHub Actions (CI/CD)"]:::infra
    end

    %% Connections
    Clients -->|"HTTP/Turbo"| Layout
    Layout -->|"renders via Rails"| Router
    Styles -->|"served by Rails"| Router
    Stimulus -->|"enhances Turbo"| Router

    Router -->|"calls views"| Views
    Router -->|"invokes models"| Models
    Views -->|"uses Turbo Streams"| Channels
    Models -->|"persists"| DB
    Models -->|"attachments"| StorageInterface
    Router -->|"queues jobs"| Jobs
    Jobs -->|"reads/writes"| DB
    Jobs -->|"sends emails"| SMTP
    Channels -->|"pub/sub"| Redis
    Router -->|"uploads/downloads"| S3
    Router -->|"geocoding"| Maps
    Router -->|"auth flow"| OAuth
    Auth -->|"uses DB"| DB

    %% Infra connections
    Router -->|"deployed as container"| Docker
    Docker -->|"CI builds via"| CI

    %% Click Events
    click Layout "https://github.com/common-member/nightrip/blob/main/app/views/layouts/application.html.erb"
    click Styles "https://github.com/common-member/nightrip/blob/main/app/assets/stylesheets/application.tailwind.css"
    click Stimulus "https://github.com/common-member/nightrip/tree/main/app/javascript/controllers"
    click Router "https://github.com/common-member/nightrip/blob/main/config/routes.rb"
    click Router "https://github.com/common-member/nightrip/tree/main/app/controllers"
    click Views "https://github.com/common-member/nightrip/tree/main/app/views"
    click Models "https://github.com/common-member/nightrip/tree/main/app/models"
    click Jobs "https://github.com/common-member/nightrip/tree/main/app/jobs"
    click Channels "https://github.com/common-member/nightrip/tree/main/app/channels"
    click StorageInterface "https://github.com/common-member/nightrip/blob/main/config/storage.yml"
    click Auth "https://github.com/common-member/nightrip/blob/main/config/initializers/devise.rb"
    click DB "https://github.com/common-member/nightrip/blob/main/config/database.yml"
    click Maps "https://github.com/common-member/nightrip/blob/main/config/initializers/geocoder.rb"
    click Docker "https://github.com/common-member/nightrip/tree/main/Dockerfile"
    click CI "https://github.com/common-member/nightrip/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef client fill:#cce5ff,stroke:#66b0ff,color:#004085
    classDef frontend fill:#e2f0d9,stroke:#82c91e,color:#2f6627
    classDef backend fill:#d6d8db,stroke:#6c757d,color:#343a40
    classDef datastore fill:#fff3cd,stroke:#ffecb5,color:#664d03
    classDef external fill:#e5e5ff,stroke:#9f9fff,color:#2f2fa2
    classDef infra fill:#f8f9fa,stroke:#d6d8db,color:#6c757d
```
