# digital-land/submit architecture

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

- Interactive diagram: https://gitdiagram.com/digital-land/submit
- Repository: https://github.com/digital-land/submit

## Overview

##### Main System Components

a) Frontend Layer
- Web Application (Node.js)
- GOV.UK Design System Components
- Client-side JavaScript Components
- SCSS/Styling Components

b) Backend Layer
- Node.js Server
- Controllers Layer
- Services Layer
- Middleware Layer
- View Engine (Nunjucks)

c) External Services & Dependencies
- Redis (Session Store)
- Local Authorities API
- AWS Infrastructure
- Analytics Services (Smartlook, Google Analytics)
- Error Monitoring (Sentry)

##### Component Relationships

a) User Flow
- User → Frontend → Controllers → Services → External APIs
- Session management flow through Redis

b) Data Flow
- File Upload Path
- URL Submission Path
- Validation Pipeline
- Results Display Path

##### Specific Architectural Elements

a) Application Structure
**Frontend Layer**
- Assets (JS/SCSS)
- Views (Nunjucks Templates)
- Public Resources

**Backend Layer**
- Controllers
- Services
- Middleware
- Routes

b) Key Services
- Async Request Processing
- Validation Services
- Boundary Services
- Mail Client Services

##### Integration Points

Clear integration with:
- AWS Infrastructure
- External APIs
- Monitoring Services
- Analytics Platforms

Use the following visual elements:

- Rectangles: Core Components
- Clouds: External Services
- Hexagons: AWS Services

- Blue: Frontend Components
- Green: Backend Services
- Yellow: External Dependencies
- Red: Critical Infrastructure

- Solid: Synchronous Communications

##### Environment Configurations

Different configurations for:
- Development
- Staging
- Production
- Testing

Key Relationships to Emphasize:

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph User
        U[User Browser]
    end

    subgraph "Frontend Layer"
        WA[Web Application]
        GDS[GOV.UK Design System]
        JSC["JavaScript Components"]:::frontend
        SCSS["SCSS Styling"]:::frontend
        VT["View Templates"]:::frontend
    end

    subgraph "Backend Layer"
        NJS[Node.js Server]:::server
        
        subgraph "Core Services"
            direction TB
            CTRL["Controllers"]:::backend
            SVC["Services"]:::backend
            MID["Middleware"]:::backend
            RT["Routes"]:::backend
            CONF["Configuration"]:::backend
        end
        
        subgraph "Server Components"
            direction TB
            VE["View Engine (Nunjucks)"]
            SM["Session Management"]:::backend
            FP["Form Processing"]:::backend
        end
    end

    subgraph "External Services"
        direction TB
        RD[(Redis)]
        LA["Local Authorities API"]
        
        subgraph "AWS Infrastructure"
            direction TB
            AWS["AWS Services"]:::aws
        end
        
        subgraph "Monitoring"
            direction TB
            GA["Google Analytics"]:::monitoring
            SL["Smartlook"]:::monitoring
            SE["Sentry"]:::monitoring
        end
    end

    subgraph "Development Tools"
        direction TB
        DC["Docker"]
        WM["Wiremock"]
    end

    %% Connections
    U --> WA
    WA --> JSC
    WA --> SCSS
    WA --> VT
    
    JSC --> CTRL
    VT --> VE
    
    CTRL --> SVC
    SVC --> MID
    MID --> RT
    
    NJS --> SM
    SM --> RD
    
    SVC --> LA
    SVC --> AWS
    
    NJS --> GA
    NJS --> SL
    NJS --> SE

    %% Development Flow
    DC --> WM
    WM --> LA

    %% Styles
    classDef frontend fill:#3498db
    classDef backend fill:#2ecc71
    classDef server fill:#95a5a6
    classDef aws fill:#f1c40f
    classDef monitoring fill:#e74c3c

    %% Click Events
    click JSC "https://github.com/digital-land/submit/tree/main/src/assets/js"
    click SCSS "https://github.com/digital-land/submit/tree/main/src/assets/scss"
    click VT "https://github.com/digital-land/submit/tree/main/src/views"
    click CTRL "https://github.com/digital-land/submit/tree/main/src/controllers"
    click SVC "https://github.com/digital-land/submit/tree/main/src/services"
    click MID "https://github.com/digital-land/submit/tree/main/src/middleware"
    click RT "https://github.com/digital-land/submit/tree/main/src/routes"
    click NJS "https://github.com/digital-land/submit/tree/main/src/serverSetup"
    click GA "https://github.com/digital-land/submit/blob/main/src/views/common/google-analytics.js"
    click SL "https://github.com/digital-land/submit/blob/main/src/views/common/smartlook.js"
    click SE "https://github.com/digital-land/submit/blob/main/src/serverSetup/sentry.js"
    click SM "https://github.com/digital-land/submit/blob/main/src/serverSetup/session.js"
    click AWS "https://github.com/digital-land/submit/tree/main/.github/actions/awscli-setup"
    click CONF "https://github.com/digital-land/submit/tree/main/config/"
    click WM "https://github.com/digital-land/submit/tree/main/docker/request-api-stub"
    click FP "https://github.com/digital-land/submit/tree/main/src/routes/form-wizard"
```
