# destino92/freelance architecture

> Architecture diagram of the GitHub repository destino92/freelance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/destino92/freelance
- Repository: https://github.com/destino92/freelance

## Overview

##### Main Components

A. Client Layer:
- Web Interface (Rails Views + Bulma CSS)
- JavaScript Components (Webpack + Stimulus)
- WebSocket Connections (Action Cable)

B. Application Layer:
- Authentication System (Devise)
- Admin Panel (Trestle)
- Controllers Layer
- Action Cable Channels
- Background Jobs

C. Service Integrations:
- Stripe Payment Gateway
- PayPal Integration
- File Storage (Active Storage)
- Search Service (Algolia)

D. Database Layer:
- PostgreSQL Database
- Key Models and Relationships

##### Detailed Component Breakdown

Core Features to Highlight:
**1. User Management**
- Authentication (Devise)
- User Profiles
- Wallet System

**2. Marketplace Features**
- Gigs Management
- Orders Processing
- Basket/Cart System
- Reviews System

**3. Communication Systems**
- Real-time Messaging
- Negotiations
- Comments
- Notifications

**4. Payment Systems**
- Stripe Integration
- PayPal Integration
- Transaction Management

##### Key Relationships

**Client Browser ←→ Rails Application**
- ↓
**Authentication Layer (Devise)**
- ↓
**Application Core**
- ↓
**Service Layer (Payments, Storage, Search)**
- ↓
**Database Layer**

##### Implementation Details

**[Client Layer]**
- ↓
**[Authentication & Authorization]**
- ↓
**[Application Core]**
- ↓
**[Service Integrations]**
- ↓
**[Data Persistence]**

##### Additional Elements

- Annotations for key processes like payment flow
- Scaling components (like background jobs)
- Security boundaries
- API endpoints

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WI["Web Interface"]:::ui
        JS["JavaScript Components"]:::ui
        WS["WebSocket Connections"]:::websocket
    end

    subgraph Auth
        AS["Authentication System"]:::security
        click AS "https://github.com/destino92/freelance/blob/master/app/controllers/users/sessions_controller.rb"
        DV["Devise"]:::security
        click DV "https://github.com/destino92/freelance/blob/master/config/initializers/devise.rb"
    end

    subgraph Core
        AP["Admin Panel"]:::admin
        click AP "https://github.com/destino92/freelance/tree/master/app/admin"
        
        subgraph Features
            GS["Gigs System"]:::feature
            click GS "https://github.com/destino92/freelance/blob/master/app/controllers/gigs_controller.rb"
            OS["Orders System"]:::feature
            click OS "https://github.com/destino92/freelance/blob/master/app/controllers/orders_controller.rb"
            BS["Basket System"]:::feature
            click BS "https://github.com/destino92/freelance/blob/master/app/controllers/baskets_controller.rb"
            RS["Reviews System"]:::feature
            click RS "https://github.com/destino92/freelance/blob/master/app/controllers/reviews_controller.rb"
            NS["Negotiation System"]:::feature
            click NS "https://github.com/destino92/freelance/blob/master/app/controllers/negotiations_controller.rb"
        end

        subgraph Communication
            MS["Messaging System"]:::comm
            click MS "https://github.com/destino92/freelance/blob/master/app/controllers/messages_controller.rb"
            NT["Notifications"]:::comm
        end
    end

    subgraph "Real-time Channels"
        MC["Message Channel"]:::websocket
        click MC "https://github.com/destino92/freelance/blob/master/app/channels/message_channel.rb"
        CC["Comment Channel"]:::websocket
        click CC "https://github.com/destino92/freelance/blob/master/app/channels/comment_channel.rb"
        NC["Negotiation Channel"]:::websocket
        click NC "https://github.com/destino92/freelance/blob/master/app/channels/negotiation_channel.rb"
        OC["Optimism Channel"]:::websocket
        click OC "https://github.com/destino92/freelance/blob/master/app/channels/optimism_channel.rb"
    end

    subgraph "External Services"
        ST["Stripe"]:::external
        click ST "https://github.com/destino92/freelance/blob/master/config/initializers/stripe.rb"
        PP["PayPal"]:::external
        AS["Active Storage"]:::external
        AL["Algolia Search"]:::external
        click AL "https://github.com/destino92/freelance/blob/master/config/initializers/algoliasearch.rb"
    end

    subgraph "Database Layer"
        DB[(PostgreSQL)]:::database
        UM["User Model"]:::model
        click UM "https://github.com/destino92/freelance/blob/master/app/models/user.rb"
        GM["Gig Model"]:::model
        click GM "https://github.com/destino92/freelance/blob/master/app/models/gig.rb"
        OM["Order Model"]:::model
        click OM "https://github.com/destino92/freelance/blob/master/app/models/order.rb"
        BM["Basket Model"]:::model
        click BM "https://github.com/destino92/freelance/blob/master/app/models/basket.rb"
        CM["Conversation Model"]:::model
        click CM "https://github.com/destino92/freelance/blob/master/app/models/conversation.rb"
        MM["Message Model"]:::model
        click MM "https://github.com/destino92/freelance/blob/master/app/models/message.rb"
        RM["Review Model"]:::model
        click RM "https://github.com/destino92/freelance/blob/master/app/models/review.rb"
        NM["Negotiation Model"]:::model
        click NM "https://github.com/destino92/freelance/blob/master/app/models/negotiation.rb"
        TM["Transaction Model"]:::model
        click TM "https://github.com/destino92/freelance/blob/master/app/models/transaction.rb"
    end

    %% Connections
    WI --> AS
    WI --> JS
    WI --> WS
    WS --> MC & CC & NC & OC
    AS --> DV
    DV --> Core
    Core --> ST & PP & AS & AL
    Features --> DB
    Communication --> DB
    MC & CC & NC & OC --> Communication

    %% Styles
    classDef ui fill:#B8D4FF,stroke:#2E75B6
    classDef security fill:#FF9999,stroke:#CC0000
    classDef admin fill:#FFB366,stroke:#CC7A00
    classDef feature fill:#99CC99,stroke:#006600
    classDef comm fill:#CC99FF,stroke:#6600CC
    classDef websocket fill:#FF99CC,stroke:#CC0066
    classDef external fill:#99CCFF,stroke:#0066CC
    classDef database fill:#FFE699,stroke:#CC9900
    classDef model fill:#FFD966,stroke:#996600

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Security Components"]:::security
        L3["Admin Components"]:::admin
        L4["Core Features"]:::feature
        L5["Communication"]:::comm
        L6["WebSocket"]:::websocket
        L7["External Services"]:::external
        L8["Database"]:::database
        L9["Models"]:::model
    end
```
