# adrianrbp/monitoring-schedule architecture

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

- Interactive diagram: https://gitdiagram.com/adrianrbp/monitoring-schedule
- Repository: https://github.com/adrianrbp/monitoring-schedule

## Overview

##### Main Components
- Frontend Container: A Vue.js application (located in the "frontend" directory) that contains components, API calls (e.g., CompanyServiceApi.ts and AvailabilityApi.ts), and views for shift and availability management. It is containerized using a Devcontainer (in .devcontainer/vue-container).
- Backend Container: A Ruby on Rails API (located in the "backend" directory) with controllers, models, views (mostly for JSON responses using jbuilder), service objects, and tests. This container is defined in .devcontainer/rails-container and managed by Docker.
- Database: Though not explicitly mentioned as a separate container, the Rails configuration (database.yml) and migrations indicate the presence of a relational database supporting persistence.
- DevOps/Containerization: Docker Compose (defined in .devcontainer/docker-compose.yml) to orchestrate the two containers and manage the development environment.
- Testing Infrastructure: Includes the GitHub Actions workflows (.github/workflows) and e2e tests (using tools like Playwright and Jest) in the frontend and backend specs.

##### Relationships and Interactions
- The backend follows a typical MVC pattern: Controllers (e.g., company_services_controller, weeks_controller), Models (e.g., Engineer, CompanyService, Shift), and Service Objects (such as FetchShiftsService and WeekService). Show a breakdown or grouping of these underlying layers inside the Backend container.
- The backend, in turn, interacts with the database (as indicated by migration files, schema.rb, and seeds) – connect the Backend container to a Database component with a clear direction of data persistence and retrieval.

##### Important Architectural Patterns and Design Principles
- MVC (Model-View-Controller) in the Rails backend explaining the separation between concerns.
- Service/Worker Pattern: The presence of service objects in the backend for business logic encapsulation.
- Containerization: Using Devcontainers and Docker Compose to simplify dependency management and development environment setup.
- API-Driven Communication: REST endpoints that clearly define interaction points.
- Component-Based Architecture in the frontend: Vue.js components combined with mixins for managing business logic (e.g., useShiftManagement).
- Testing as a first-class citizen: Including specs for models, controllers, services, and e2e tests.

##### Relevant Technologies and Frameworks
- Backend: Ruby on Rails (API mode), Docker, RSpec, and Factory Bot.
- Frontend: Vue.js (with components, mixins, and supporting TypeScript integration), Tailwind CSS, and testing tools (Jest, Playwright).
- DevOps: Docker Compose, GitHub Actions, and Devcontainer configuration guiding the development and testing environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user

    subgraph "Docker Compose & Devcontainer"
        DockerCompose["DevOps/Containerization"]:::docker
        subgraph "Frontend Container"
            FEApp["Frontend (Vue.js)"]:::frontend
            FEComponents["Components (frontend/src)"]:::frontend
            FEAPI["API Integrations (frontend/src/api)"]:::frontend
            FEApp --- FEComponents
            FEApp --- FEAPI
        end
        subgraph "Backend Container"
            BEApp["Backend (Rails API)"]:::backend
            BEControllers["Controllers (backend/app/controllers)"]:::backend
            BEModels["Models (backend/app/models)"]:::backend
            BEServices["Services (backend/app/services)"]:::backend
            BEViews["Views (backend/app/views)"]:::backend
            BEConfig["Config (backend/config)"]:::backend
            BEApp --- BEControllers
            BEApp --- BEModels
            BEApp --- BEServices
            BEApp --- BEViews
            BEApp --- BEConfig
        end
    end

    DB["Database"]:::database
    Test["Testing Infrastructure"]:::testing

    User -->|"Interacts"| FEApp
    FEApp -->|"GET/POST /api/company_services..."| BEApp
    BEApp -->|"ActiveRecordCalls"| DB
    FEApp -->|"E2E_Tests"| Test
    BEApp -->|"RSpec_Tests"| Test

    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef database fill:#FFECB3,stroke:#F57F17,stroke-width:2px;
    classDef docker fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef testing fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
    classDef user fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;

    click FEApp "https://github.com/adrianrbp/monitoring-schedule/tree/main/.devcontainer/vue-container"
    click FEComponents "https://github.com/adrianrbp/monitoring-schedule/tree/main/frontend/src"
    click FEAPI "https://github.com/adrianrbp/monitoring-schedule/tree/main/frontend/src/api"

    click BEApp "https://github.com/adrianrbp/monitoring-schedule/tree/main/.devcontainer/rails-container"
    click BEControllers "https://github.com/adrianrbp/monitoring-schedule/tree/main/backend/app/controllers"
    click BEModels "https://github.com/adrianrbp/monitoring-schedule/tree/main/backend/app/models"
    click BEServices "https://github.com/adrianrbp/monitoring-schedule/tree/main/backend/app/services"
    click BEViews "https://github.com/adrianrbp/monitoring-schedule/tree/main/backend/app/views"
    click BEConfig "https://github.com/adrianrbp/monitoring-schedule/blob/main/backend/config/routes.rb"

    click DB "https://github.com/adrianrbp/monitoring-schedule/blob/main/backend/config/database.yml"
    click DockerCompose "https://github.com/adrianrbp/monitoring-schedule/blob/main/.devcontainer/docker-compose.yml"
    click Test "https://github.com/adrianrbp/monitoring-schedule/tree/main/.github/workflows"
```
