# acero-ad/youcook architecture

> Architecture diagram of the GitHub repository acero-ad/youcook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acero-ad/youcook
- Repository: https://github.com/acero-ad/youcook

## Overview

##### Main Components

a) Client Layer:
- Web Browser Interface
- PWA Components (manifest.json and service-worker.js)
- Hotwire (Turbo and Stimulus.js) for frontend interactivity

b) Application Layer:
- Controllers (RecipesController)
- Command Layer (CreateRecipeCommand)
- Query Layer (SearchRecipesByKeywordQuery)
- Views (ERB templates)

c) Data Layer:
- PostgreSQL Database
- Full-text Search Implementation
- Models (Recipe)

**┌─ Client Layer ─────────────────────┐**
- Web Browser                      │
- PWA Components                   │
- Hotwire (Turbo + Stimulus.js)   │
- ┬───────────────────┘
- ↓
**┌─ Application Layer ────────────────┐**
- ┌─ Controllers ─┐  ┌─ Commands ─┐  │
- Recipes    │←→│ - Create   │  │
- ┘  └───────────┘   │
- ┌─ Queries ────┐  ┌─ Views ────┐  │
- Search     │←→│ - ERB      │  │
- ┘  └───────────┘   │
- ┬───────────────────┘
- ↓
**┌─ Data Layer ──────────────────────┐**
- ┌─ PostgreSQL ─────────────────┐  │
- Full-text Search Index     │  │
- Recipe Table              │  │
- ┘  │
- ┘

##### Additional Elements

- Testing Framework (RSpec)
- Development Tools (Devcontainer, Docker)
- CI/CD Pipeline (.github/workflows)
- Deployment (Railway.app)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL[Client Layer]
        WB[Web Browser]
        PWA[PWA Components]
        HW[Hotwire Components]
    end

    %% Application Layer
    subgraph AL[Application Layer]
        subgraph Controllers
            RC[RecipesController]:::controller
            AC[ApplicationController]:::controller
        end

        subgraph Commands
            CRC[CreateRecipeCommand]:::command
        end

        subgraph Queries
            SRQ[SearchRecipesByKeywordQuery]:::query
        end

        subgraph Views
            RV[Recipe Views]:::view
        end
    end

    %% Data Layer
    subgraph DL[Data Layer]
        subgraph DB[PostgreSQL Database]
            RM[Recipe Model]:::model
            FTS[Full-text Search Index]
            GT[GIN Index]
        end
    end

    %% Development & Testing
    subgraph DevOps[Development & Testing]
        DC[DevContainer]:::devops
        CI[CI/CD Pipeline]:::devops
        TS[Test Suite]:::test
    end

    %% Relationships
    WB --> RC
    PWA --> WB
    HW --> WB
    RC --> CRC
    RC --> SRQ
    RC --> RV
    CRC --> RM
    SRQ --> RM
    RM --> FTS
    RM --> GT

    %% Click Events
    click PWA "https://github.com/Acero-AD/youcook/tree/master/app/views/pwa/"
    click HW "https://github.com/Acero-AD/youcook/tree/master/app/javascript/controllers/"
    click RC "https://github.com/Acero-AD/youcook/blob/master/app/controllers/recipes_controller.rb"
    click AC "https://github.com/Acero-AD/youcook/blob/master/app/controllers/application_controller.rb"
    click CRC "https://github.com/Acero-AD/youcook/blob/master/app/command/create_recipe_command.rb"
    click SRQ "https://github.com/Acero-AD/youcook/blob/master/app/query/recipes/search_recipes_by_keyword_query.rb"
    click RV "https://github.com/Acero-AD/youcook/tree/master/app/views/recipes/"
    click RM "https://github.com/Acero-AD/youcook/blob/master/app/models/recipe.rb"
    click FTS "https://github.com/Acero-AD/youcook/blob/master/db/migrate/20241219140442_add_search_vector_to_recipes.rb"
    click GT "https://github.com/Acero-AD/youcook/blob/master/db/migrate/20241215210324_add_gin_index_to_keywords.rb"
    click TS "https://github.com/Acero-AD/youcook/tree/master/spec/"
    click CI "https://github.com/Acero-AD/youcook/blob/master/.github/workflows/ci.yml"
    click DC "https://github.com/Acero-AD/youcook/tree/master/.devcontainer/"

    %% Styles
    classDef controller fill:#90EE90
    classDef command fill:#FFB6C1
    classDef query fill:#ADD8E6
    classDef view fill:#DDA0DD
    classDef model fill:#F0E68C
    classDef devops fill:#D3D3D3
    classDef test fill:#98FB98

    %% Legend
    subgraph Legend
        L1[Controller]:::controller
        L2[Command]:::command
        L3[Query]:::query
        L4[View]:::view
        L5[Model]:::model
        L6[DevOps]:::devops
        L7[Test]:::test
    end
```
