# nhsuk/manage-vaccinations-in-schools architecture

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

- Interactive diagram: https://gitdiagram.com/nhsuk/manage-vaccinations-in-schools
- Repository: https://github.com/nhsuk/manage-vaccinations-in-schools

## Overview

##### High-Level Architecture (Context View)

- Core MAVIS System
- External Systems:
- NHS Care Identity Service (CIS2) for authentication
- NHS MESH for vaccination data exchange
- NHS PDS for patient demographics
- GOV.UK Notify for communications
- PostgreSQL database

##### Container View

a) Frontend Layer:
- View Components (app/components/)
- Assets (JavaScript, CSS)
- Service Worker for offline support

b) Backend Layer:
- Rails Application Server
- Key Controllers:
- Vaccination Management
- Patient Management
- Session Management
- Consent Management
- Import/Export Management

c) Data Layer:
- PostgreSQL Database
- Active Storage for file handling

##### Component View

a) Core Domain Components:
- Patient Management (app/models/patient.rb)
- Vaccination Records (app/models/vaccination_record.rb)
- Consent Management (app/models/consent.rb)
- Session Management (app/models/session.rb)
- School/Location Management (app/models/location.rb)

b) Supporting Components:
- Authentication & Authorization (app/controllers/concerns/authentication_concern.rb)
- Offline Support (app/javascript/serviceworker/)
- Import/Export Services (app/jobs/)
- Notification Services (app/mailers/)

##### Key Interactions

Main data flows:
- User Authentication Flow (CIS2)
- Vaccination Recording Process
- Consent Management Process
- Data Synchronization (Online/Offline)
- External System Integration

##### Technical Details

a) Infrastructure:
- AWS Deployment (using Copilot)
- Multiple environments (Production, Training, Preview, etc.)

b) Security:
- CIS2 Authentication
- CSRF Protection
- Offline Security Measures

c) Integration Points:
- MESH API Connection
- PDS API Integration
- GOV.UK Notify Integration

##### Additional Elements

- Deployment configuration
- Data backup flows
- Monitoring and logging points
- Security boundaries and authentication checkpoints

- The system's role in NHS vaccination management
- Robust security measures for medical data
- Offline capability for field use
- Integration with NHS systems
- Data flow for vaccination records

Remember to include legends and notes explaining any technical terms or NHS-specific terminology for clarity.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Services"]
        CIS2[NHS CIS2]
        MESH[NHS MESH]
        PDS[NHS PDS]
        GOVUK[GOV.UK Notify]
    end

    subgraph Frontend["Frontend Layer"]
        VC["View Components"]:::frontend
        Assets["Assets"]:::frontend
        SW["Service Worker"]:::frontend
    end

    subgraph Backend["Backend Layer"]
        subgraph Controllers["Controllers"]
            VacCtrl["Vaccination Controller"]:::controller
            PatCtrl["Patient Controller"]:::controller
            SesCtrl["Session Controller"]:::controller
            ConCtrl["Consent Controller"]:::controller
        end

        subgraph Models["Domain Models"]
            Patient["Patient Model"]:::model
            VacRec["Vaccination Record"]:::model
            Consent["Consent Model"]:::model
            Session["Session Model"]:::model
            Location["Location Model"]:::model
        end

        subgraph Services["Services"]
            Auth["Authentication"]:::service
            Import["Import Service"]:::service
            Export["Export Service"]:::service
            Notify["Notification Service"]:::service
        end

        subgraph Integration["Integration Layer"]
            MeshInt["MESH Integration"]:::integration
            PDSInt["PDS Integration"]:::integration
            NHSApi["NHS API"]:::integration
        end
    end

    subgraph Data["Data Layer"]
        DB[(PostgreSQL)]
        Storage["Active Storage"]
    end

    %% Frontend to Backend Connections
    VC --> Controllers
    SW --> Controllers

    %% Controller to Model Connections
    VacCtrl --> VacRec
    PatCtrl --> Patient
    SesCtrl --> Session
    ConCtrl --> Consent
    Controllers --> Location

    %% Service Connections
    Auth --> CIS2
    MeshInt --> MESH
    PDSInt --> PDS
    Notify --> GOVUK

    %% Data Layer Connections
    Models --> DB
    Storage --> DB

    %% Integration Layer Connections
    Export --> MeshInt
    Import --> PDSInt
    Controllers --> NHSApi

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef controller fill:#ff9e9e
    classDef model fill:#94ff94
    classDef service fill:#ffd700
    classDef integration fill:#e6ccff

    %% Click Events
    click VC "https://github.com/nhsuk/manage-vaccinations-in-schools/tree/main/app/components/"
    click Assets "https://github.com/nhsuk/manage-vaccinations-in-schools/tree/main/app/assets/"
    click SW "https://github.com/nhsuk/manage-vaccinations-in-schools/tree/main/app/javascript/serviceworker/"
    click Patient "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/models/patient.rb"
    click VacRec "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/models/vaccination_record.rb"
    click Consent "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/models/consent.rb"
    click Session "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/models/session.rb"
    click Location "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/models/location.rb"
    click VacCtrl "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/controllers/vaccinations_controller.rb"
    click PatCtrl "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/controllers/patients_controller.rb"
    click SesCtrl "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/controllers/sessions_controller.rb"
    click ConCtrl "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/controllers/consents_controller.rb"
    click Auth "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/controllers/concerns/authentication_concern.rb"
    click MeshInt "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/lib/mesh.rb"
    click PDSInt "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/lib/nhs/pds.rb"
    click NHSApi "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/lib/nhs/api.rb"
    click Import "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/jobs/process_import_job.rb"
    click Export "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/jobs/mesh_dps_export_job.rb"
    click Notify "https://github.com/nhsuk/manage-vaccinations-in-schools/blob/main/app/lib/govuk_notify_personalisation.rb"
```
