# dfe-digital/dfe-complete-conversions-transfers-and-changes architecture

> Architecture diagram of the GitHub repository dfe-digital/dfe-complete-conversions-transfers-and-changes, 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/dfe-digital/dfe-complete-conversions-transfers-and-changes
- Repository: https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes

## Overview

This project is a complex, monolithic Ruby on Rails application built for managing “conversions, transfers and changes” in the education context (specifically for academy-related processes). The overall architecture follows the classic MVC pattern and separates concerns well among controllers, models, views, and service objects. It also exposes API endpoints (under app/api) and leverages multiple external dependencies (such as APIs for academies data, GOV.UK Notify, Azure Application Insights for monitoring, and background job processing with Sidekiq/Redis).

##### Main components
- Client/User Interface – Represent browsers and end-user devices interacting with the application. Note that the frontend uses GOV.UK and DfE design components and JavaScript helpers.
- Web Application Layer – The core Rails monolith, including:
– API Layer: (app/api) exposing endpoints (v1/conversions, healthcheck, transfers, etc.)
– Controllers: Organized into separate domains (conversions, transfers, date history, local authorities, external contacts, etc.)
– Views and components: Handlebars-like components and ERB files for rendering the HTML UI.
– Service Layer: Service objects (in app/services and lib) handling business logic such as project creation, processing conversion/transfer tasks, exports, and integration with external APIs.
– Job Processing: Background jobs (in app/jobs) for non-interactive tasks.
- Data Storage – The database layer (schema/db & migrations) storing projects, user accounts, task lists, and additional domain entities.
- External Integrations:
– External APIs (academies API, persons API) – The Rails application calls these services to fetch data about establishments and trusts.
– Email Services: For instance, GOV.UK Notify (referenced in the documentation).
– Monitoring & Logging: Integration with Azure Application Insights (with distinct dashboards for development, test, production).
– Infrastructure as Code: Terraform components for managing deployment, container orchestration (Docker, Kubernetes or container host), and configuration.
– Background Processing: Likely a Redis-backed Sidekiq system as indicated by decisions to use “sidekiq and redis” for background job processing.

##### Relationships and interactions
- User devices send HTTP requests to the Rails application via a web server (using a Docker container or deployed on a managed service).
- Requests are routed through the application’s controllers and, if needed, interact with API endpoints to fetch or update project data.
- The controllers invoke service objects that encapsulate business logic and call out to:
– The database (active record ORM) for CRUD operations,
– External API clients to fetch updated academy/trust data,
– Background jobs for asynchronous processing such as imports or long-running tasks.
- Email notifications, logging, and monitoring actions cross-cut the application, with integrations to external services.
- Infrastructure components (Docker, GitHub workflows, Terraform) manage deployment, continuous integration, and maintainability of the application across environments.

##### Important architectural patterns and design principles
- MVC Pattern: Clear separation of presentation (views), control (controllers), and business logic (models & service objects).
- Modularization of Domain Concerns: The project separates conversions from transfers and further splits responsibilities using subdirectories (e.g., app/forms, app/services, app/controllers) for each domain.
- API-First Approach: With a dedicated API folder, the system supports both internal page rendering and external API consumption.
- Infrastructure as Code: Managed through Terraform scripts in the terraform directory and using containerization (Dockerfile, devcontainer) for development consistency.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    client["Client (Browser/UI)"]:::client

    %% Web Application Layer (Rails)
    subgraph "Web Application Layer (Rails)"
        direction TB
        api["API Layer"]:::api
        ctrl["Controllers"]:::ctrl
        views["Views & UI Components"]:::views
        service["Service Layer"]:::service
        jobs["Background Jobs"]:::job
    end

    %% Data Storage
    db["Data Storage (Database)"]:::db

    %% External Integrations
    extApi["External API Integrations"]:::ext
    emails["Email Services"]:::email
    monitor["Monitoring & Logging"]:::monitor

    %% Infrastructure / Deployment
    infra["Infrastructure & Deployment"]:::infra

    %% Connections from Client
    client -->|"HTTP_request"| ctrl
    client -->|"API_calls"| api

    %% Internal Rails Connections
    ctrl -->|"Business_logic"| service
    ctrl -->|"Render_UI"| views
    service -->|"CRUD_operations"| db
    service -->|"External_calls"| extApi
    service -->|"Queue_jobs"| jobs
    service -->|"Send_notifications"| emails
    service -->|"Telemetry"| monitor

    %% Background Job processing feedback
    jobs -->|"Async_updates"| db

    %% Infrastructure Deployment flows
    infra -->|"Deploys"| service

    %% Click Events
    click client "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/assets"
    click api "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/api"
    click ctrl "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/controllers"
    click views "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/views"
    click service "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/services"
    click jobs "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/jobs"
    click db "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/db"
    click extApi "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/models/api"
    click emails "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/app/mailers"
    click monitor "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/blob/main/app/javascript/application-insights.js"
    click infra "https://github.com/dfe-digital/dfe-complete-conversions-transfers-and-changes/tree/main/terraform"

    %% Styles
    classDef client fill:#f9e79f,stroke:#6e2c00,stroke-width:2px;
    classDef api fill:#d5f5e3,stroke:#1e8449,stroke-width:2px;
    classDef ctrl fill:#f5cba7,stroke:#ba4a00,stroke-width:2px;
    classDef views fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef service fill:#d6eaf8,stroke:#2471a3,stroke-width:2px;
    classDef job fill:#e8daef,stroke:#76448a,stroke-width:2px;
    classDef db fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
    classDef ext fill:#d1f2eb,stroke:#148f77,stroke-width:2px;
    classDef email fill:#fef9e7,stroke:#d68910,stroke-width:2px;
    classDef monitor fill:#f5eef8,stroke:#8e44ad,stroke-width:2px;
    classDef infra fill:#e8f8f5,stroke:#117864,stroke-width:2px;
```
