# edivandecastro/mocky_mouse architecture

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

- Interactive diagram: https://gitdiagram.com/edivandecastro/mocky_mouse
- Repository: https://github.com/edivandecastro/mocky_mouse

## Overview

##### Main Components

a. Client Layer:
- Web Interface (Rails Views)
- Asset Pipeline (JavaScript/CSS)
- User Authentication System (Devise)

b. Application Layer:
- Controllers (especially MockyMouse namespace)
- Models
- Routing System

c. Data Layer:
- PostgreSQL Database
- Active Record Models

d. Mock API Service Layer:
- Router Component
- Synchronizer
- Application State Handler

**[Client Browser] ←→ [Web Interface Layer]**
- ↑                    ↑

**[Mock API Endpoints] ←→ [Application Layer]**
- ↑                    ↑

**[Router Component] ←→ [Data Layer (PostgreSQL)]**

##### Key Relationships to Highlight

a. User Flow:
- Authentication flow through Devise
- Dashboard access and mock configuration
- Mock API consumption

b. Mock API Flow:
- Request handling through Router
- State management
- Response generation

##### Specific Implementation Details

a. Models Layer:
- User (devise integration)
- Mock (core mock configuration)
- Header (HTTP headers)
- ApplicationState (state management)
- Router (routing logic)

b. Controllers Layer:
- MockyMouse::MocksController
- MockyMouse::HomeController
- User management controllers

##### Additional Elements

- Docker container boundaries
- External service connections
- Asset pipeline flow
- HTTP/HTTPS endpoints

##### State management for mock responses

For this specific project, focus on:
- The separation between mock configuration interface and mock API serving
- The role of the Router and Synchronizer in handling mock requests
- The relationship between Users and their Mock configurations
- The state management system for mock responses

This will provide a clear understanding of both the administrative interface and the mock API service functionality.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        APIClient["API Client"]
    end

    subgraph "Web Interface Layer"
        WebViews["Views"]:::frontend
        Assets["Asset Pipeline"]:::frontend
        click WebViews "https://github.com/edivandecastro/mocky_mouse/tree/master/app/views/mocky_mouse/"
        click Assets "https://github.com/edivandecastro/mocky_mouse/tree/master/app/assets/"
    end

    subgraph "Authentication Layer"
        DeviseAuth["Devise Auth System"]:::auth
        SessionsCtrl["Sessions Controller"]:::auth
        RegCtrl["Registrations Controller"]:::auth
        click DeviseAuth "https://github.com/edivandecastro/mocky_mouse/tree/master/app/views/devise/"
        click SessionsCtrl "https://github.com/edivandecastro/mocky_mouse/blob/master/app/controllers/users/sessions_controller.rb"
        click RegCtrl "https://github.com/edivandecastro/mocky_mouse/blob/master/app/controllers/users/registrations_controller.rb"
    end

    subgraph "Application Layer"
        MocksCtrl["Mocks Controller"]:::controller
        HomeCtrl["Home Controller"]:::controller
        Router["Router Component"]:::service
        Sync["Synchronizer"]:::service
        StateHandler["Application State Handler"]:::service
        click MocksCtrl "https://github.com/edivandecastro/mocky_mouse/blob/master/app/controllers/mocky_mouse/mocks_controller.rb"
        click HomeCtrl "https://github.com/edivandecastro/mocky_mouse/blob/master/app/controllers/mocky_mouse/home_controller.rb"
        click Router "https://github.com/edivandecastro/mocky_mouse/blob/master/app/models/mocky_mouse/router.rb"
        click Sync "https://github.com/edivandecastro/mocky_mouse/blob/master/app/models/mocky_mouse/synchronizer.rb"
        click StateHandler "https://github.com/edivandecastro/mocky_mouse/blob/master/app/models/mocky_mouse/application_state.rb"
    end

    subgraph "Data Layer"
        UserModel["User Model"]:::model
        MockModel["Mock Model"]:::model
        HeaderModel["Header Model"]:::model
        DB[(PostgreSQL)]:::database
        click UserModel "https://github.com/edivandecastro/mocky_mouse/blob/master/app/models/user.rb"
        click MockModel "https://github.com/edivandecastro/mocky_mouse/blob/master/app/models/mocky_mouse/mock.rb"
        click HeaderModel "https://github.com/edivandecastro/mocky_mouse/blob/master/app/models/mocky_mouse/header.rb"
    end

    %% Relationships
    Browser --> WebViews
    Browser --> DeviseAuth
    APIClient --> Router
    
    WebViews --> Assets
    WebViews --> MocksCtrl
    WebViews --> HomeCtrl
    
    DeviseAuth --> SessionsCtrl
    DeviseAuth --> RegCtrl
    SessionsCtrl --> UserModel
    RegCtrl --> UserModel
    
    MocksCtrl --> Router
    MocksCtrl --> MockModel
    HomeCtrl --> StateHandler
    
    Router --> Sync
    Router --> HeaderModel
    Sync --> StateHandler
    
    StateHandler --> DB
    UserModel --> DB
    MockModel --> DB
    HeaderModel --> DB

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef auth fill:#9b59b6,stroke:#8e44ad,color:white
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#e74c3c,stroke:#c0392b,color:white
    classDef model fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Auth["Authentication Component"]:::auth
        Ctrl["Controller Component"]:::controller
        Svc["Service Component"]:::service
        Model["Model Component"]:::model
        DBComp["Database Component"]:::database
    end
```
