# meltyness/ratchet-pawl architecture

> Architecture diagram of the GitHub repository meltyness/ratchet-pawl, 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/meltyness/ratchet-pawl
- Repository: https://github.com/meltyness/ratchet-pawl

## Overview

##### Main Components

a) Frontend Layer (React-based):
- User Interface Components (from pawl-js/src):
- Authentication (PawlLogin.js)
- Device Management (DeviceEditor.js, DeviceList.js)
- User Management (UserEditor.js, UserList.js)
- Navigation (SideBar.js, HomePanel.js)

b) Backend Layer (Rust-based):
- API Endpoints (mentioned in README)
- Authentication Handler
- Data Processing Logic

c) Database Layer:
- Data Storage
- Note about data masking and bcrypt hashing

d) External Systems:
- Interaction with the API

##### Component Relationships

- Frontend → Backend: REST API calls
- Backend → Database: Data persistence
- Ratchet TACACS Daemon → Backend: Configuration fetching
- Security context (bcrypt, data masking)

##### Technical Stack Callouts

- Backend: Rust, Rocket.rs
- Database: redb
- Security: Bcrypt, Data Masking

##### Architecture Patterns

Highlight:
- Client-Server architecture
- RESTful API design
- Stateless authentication
- Data encryption/hashing patterns

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        FE["Frontend Entry Point"]
        UI["User Interface Layer"]
        subgraph Components
            Auth["Authentication"]
            DevMgmt["Device Management"]
            UserMgmt["User Management"]
            Nav["Navigation"]
            Styles["Styles"]
            Assets["Public Assets"]
        end
        UI --> Auth & DevMgmt & UserMgmt & Nav
        FE --> UI
        UI --> Styles
        UI --> Assets
    end

    %% Backend Layer
    subgraph Backend
        BE["Backend Entry Point"]
        API["API Layer"]
        AuthHandler["Authentication Handler"]
        DataProc["Data Processing Logic"]
        BuildConfig["Build Configuration"]
        PkgConfig["Package Configuration"]
    end

    %% Database Layer
    subgraph Database
        DB[(Persistence Layer)]
        DataMask{"Data Masking"}
        BcryptHash{"Bcrypt Hashing"}
    end

    %% External Systems
    subgraph External
        Ratchet["Ratchet TACACS Daemon"]
    end

    %% Relationships
    Auth --> API
    DevMgmt --> API
    UserMgmt --> API
    API --> AuthHandler
    AuthHandler --> DataProc
    DataProc --> DB
    DataMask --> DB
    BcryptHash --> DB
    Ratchet --> API

    %% Future Features (dotted lines)
    WebSocket["WebSocket Connection"]:::external
    Replication["Distributed Replication"]:::external
    Monitor["Monitoring System"]:::external
    Security["Advanced Security"]:::security

    WebSocket -.-> API
    Replication -.-> DB
    Monitor -.-> Backend
    Security -.-> AuthHandler

    %% Click Events
    click Auth "https://github.com/meltyness/ratchet-pawl/blob/main/pawl-js/src/PawlLogin.js"
    click DevMgmt "https://github.com/meltyness/ratchet-pawl/blob/main/pawl-js/src/DeviceEditor.js"
    click UserMgmt "https://github.com/meltyness/ratchet-pawl/blob/main/pawl-js/src/UserEditor.js"
    click Nav "https://github.com/meltyness/ratchet-pawl/blob/main/pawl-js/src/SideBar.js"
    click FE "https://github.com/meltyness/ratchet-pawl/blob/main/pawl-js/src/index.js"
    click Styles "https://github.com/meltyness/ratchet-pawl/blob/main/pawl-js/src/styles.css"
    click Assets "https://github.com/meltyness/ratchet-pawl/tree/main/pawl-js/public/"
    click BE "https://github.com/meltyness/ratchet-pawl/blob/main/src/main.rs"
    click BuildConfig "https://github.com/meltyness/ratchet-pawl/blob/main/build.rs"
    click PkgConfig "https://github.com/meltyness/ratchet-pawl/blob/main/Cargo.toml"

    %% Legend
    subgraph Legend
        L1["Frontend Component"]:::frontend
        L2["Backend Component"]:::backend
        L3["Database Component"]:::database
        L4["External System"]:::external
        L5["Security Feature"]:::security
    end
```
