# nuwcdivnpt/stig-manager architecture

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

- Interactive diagram: https://gitdiagram.com/nuwcdivnpt/stig-manager
- Repository: https://github.com/nuwcdivnpt/stig-manager

## Overview

##### Main Components

a. Client Layer:
- Web Client (ExtJS-based frontend)
- Client-side Services (Authentication, State Management)
- UI Components (Grids, Forms, Panels)

b. API Layer:
- RESTful API endpoints
- Controllers (Asset, Collection, Metrics, Review, STIG, User)
- Service Layer
- Authentication/Authorization

c. Data Layer:
- MySQL Database
- Migration System
- Data Models

d. External Integrations:
- DISA STIG/SRG Integration
- Authentication Provider (Keycloak)

##### Component Relationships

**[Client Layer]**

- HTTP/REST
- v
**[API Gateway/Load Balancer]**

**[API Layer]**

- v           v
**[Database]    [External Services]**

##### Detailed Component Breakdown

Client Layer:
**[Web Client]**
- SM/ Components
- Authentication Module
- State Management
- UI Components

API Layer:
**[API Server]**
- Controllers/
- Asset
- Collection
- Metrics
- Review
- STIG
- User

- Services/
- Business Logic
- Data Access

- Utils/
- Authentication
- Configuration
- Logging

Data Layer:
**[MySQL Database]**
- Tables
- Views
- Migrations

##### Key Interactions to Highlight

- Authentication flow between client, API, and authentication provider
- STIG data import/export processes
- Review and assessment workflows
- Metrics collection and reporting
- Asset management operations

##### Additional Elements

- Security boundaries and zones
- Data flow directions
- API endpoints grouping
- Database schema relationships
- Caching mechanisms
- Service worker implementation

##### Implementation Details

Use a diagramming tool that supports:
- Nested components
- Grouping/clustering
- Labels and annotations

##### Integration points with external systems

This architecture represents a modern web application with clear separation of concerns, robust security, and scalable design patterns.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef db fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        WebClient["Web Client (ExtJS)"]
        UIComponents["UI Components"]
        StateManagement["State Management"]
    end

    %% API Layer
    subgraph APILayer["API Layer"]
        APIGateway["API Gateway"]
        
        subgraph Controllers["Controllers"]
            AssetCtrl["Asset Controller"]
            CollectionCtrl["Collection Controller"]
            MetricsCtrl["Metrics Controller"]
            ReviewCtrl["Review Controller"]
            STIGCtrl["STIG Controller"]
            UserCtrl["User Controller"]
        end
        
        subgraph Services["Services"]
            AssetSvc["Asset Service"]
            CollectionSvc["Collection Service"]
            MetricsSvc["Metrics Service"]
            ReviewSvc["Review Service"]
            STIGSvc["STIG Service"]
            UserSvc["User Service"]
        end
        
        subgraph Utils["Utilities"]
            Auth["Authentication"]
            Config["Configuration"]
            ErrorHandler["Error Handling"]
        end
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        MySQL[(MySQL Database)]
        Migrations["DB Migrations"]
        Schema["Schema Definition"]
    end

    %% External Services
    subgraph ExternalServices["External Services"]
        Keycloak["Keycloak Auth"]
        DISA["DISA STIG/SRG"]
    end

    %% Relationships
    WebClient --> APIGateway
    UIComponents --> WebClient
    StateManagement --> WebClient
    
    APIGateway --> Controllers
    Controllers --> Services
    Services --> MySQL
    Auth --> Keycloak
    STIGSvc --> DISA
    
    %% Apply styles
    class WebClient,UIComponents,StateManagement client
    class APIGateway,AssetCtrl,CollectionCtrl,MetricsCtrl,ReviewCtrl,STIGCtrl,UserCtrl,AssetSvc,CollectionSvc,MetricsSvc,ReviewSvc,STIGSvc,UserSvc api
    class MySQL,Migrations,Schema db
    class Keycloak,DISA external
    class Auth,Config,ErrorHandler security

    %% Click events
    click WebClient "https://github.com/NUWCDIVNPT/stig-manager/tree/main/client/src/js/SM/"
    click UIComponents "https://github.com/NUWCDIVNPT/stig-manager/tree/main/client/src/js/SM/Components/"
    click StateManagement "https://github.com/NUWCDIVNPT/stig-manager/blob/main/client/src/js/SM/State.js"
    click AssetCtrl "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/controllers/Asset.js"
    click CollectionCtrl "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/controllers/Collection.js"
    click MetricsCtrl "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/controllers/Metrics.js"
    click ReviewCtrl "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/controllers/Review.js"
    click STIGCtrl "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/controllers/STIG.js"
    click UserCtrl "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/controllers/User.js"
    click AssetSvc "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/service/AssetService.js"
    click CollectionSvc "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/service/CollectionService.js"
    click MetricsSvc "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/service/MetricsService.js"
    click ReviewSvc "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/service/ReviewService.js"
    click STIGSvc "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/service/STIGService.js"
    click UserSvc "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/service/UserService.js"
    click Auth "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/utils/auth.js"
    click Config "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/utils/config.js"
    click ErrorHandler "https://github.com/NUWCDIVNPT/stig-manager/blob/main/api/source/utils/error.js"
    click Migrations "https://github.com/NUWCDIVNPT/stig-manager/tree/main/api/source/service/migrations/"
    click Schema "https://github.com/NUWCDIVNPT/stig-manager/blob/main/data/schemas/Stigman-Model.mwb"
```
