# icydrae/vaults architecture

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

- Interactive diagram: https://gitdiagram.com/icydrae/vaults
- Repository: https://github.com/icydrae/vaults

## Overview

##### Main Components

a. Client Side (Frontend)
- Vue.js Application Layer
- Components (Authentication, Vault Management, Item Management)
- State Management (Vuex Store)
- Security Services (Encryption/Decryption Layer)
- API Services Layer

b. Server Side (Backend)
- Nginx Web Server
- PHP/Symfony API
- Controllers Layer
- Entity Layer
- Repository Layer
- Security Layer

c. Database
- MySQL Database

**[Client Browser] <-HTTPS-> [Nginx Reverse Proxy] <-> [PHP/Symfony API] <-> [MySQL Database]**

**[Frontend Encryption Layer]**
- PBKDF2 Key Derivation
- AES-256 Encryption
- Authentication Hash Generation

**[Backend Security Layer]**
- CORS/CSRF Protection
- Additional PBKDF2 Hashing
- Authentication Management

**[Vue.js Components] -> [Vuex Store] -> [Security Services] -> [API Services] -> [Backend API] -> [Database]**

##### Important Elements to Highlight

- Blue: Frontend components
- Green: Security-related components
- Yellow: API/Backend services
- Red: Database and storage
- Purple: Infrastructure components (Docker, Nginx)

- Rectangles: Main components
- Hexagons: Security components

##### Specific Implementation Details

a. Authentication Flow:
**[Master Password] -> [Email Salt] -> [PBKDF2] -> [Encryption Key] -> [Auth Hash] -> [Backend Storage]**

b. Data Encryption Flow:
**[User Data] -> [AES-256 Encryption] -> [Encrypted Payload] -> [API] -> [Database Storage]**

c. Container Architecture:
**[Docker Compose]**
- [Frontend Container]
- [Nginx Container]
- [PHP/Symfony Container]
- [MySQL Container]

##### Key Relationships

- Frontend-Backend interaction through REST API
- Client-side encryption/decryption process
- Authentication flow
- Data storage flow
- Docker container relationships

##### Additional Notes

- Notes about security measures (HTTPS, CORS, CSRF)
- Separation between encrypted and unencrypted data flows
- Client-side nature of sensitive operations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Browser"]
        direction TB
        FE["Vue.js Frontend"]:::frontend
        COMP["Components Layer"]:::frontend
        STATE["State Management"]:::frontend
        SEC["Security Services"]:::security
        API["API Services"]:::api
        
        FE --> COMP
        FE --> STATE
        FE --> SEC
        FE --> API
    end

    subgraph Server["Server Infrastructure"]
        direction TB
        NGINX["Nginx Reverse Proxy"]:::infra
        
        subgraph Backend["PHP/Symfony Backend"]
            direction TB
            CONT["Controllers Layer"]:::backend
            ENT["Entity Layer"]:::backend
            REP["Repository Layer"]:::backend
            BSEC["Security Layer"]:::security
            
            CONT --> ENT
            CONT --> REP
            CONT --> BSEC
        end
        
        DB[(MySQL Database)]:::database
    end

    subgraph Security["Security Components"]
        direction TB
        CORS["CORS Protection"]:::security
        CSRF["CSRF Protection"]:::security
        AUTH["Authentication Handler"]:::security
    end

    subgraph Management["Application Components"]
        direction TB
        VAULT["Vault Management"]:::component
        ITEMS["Item Management"]:::component
        LOGIN["Login Items"]:::component
        NOTES["Notes"]:::component
        
        VAULT --> ITEMS
        ITEMS --> LOGIN
        ITEMS --> NOTES
    end

    Client -- HTTPS --> NGINX
    NGINX --> Backend
    Backend --> DB
    Backend --> Security

    %% Click Events
    click COMP "https://github.com/icydrae/vaults/tree/main/frontend/src/components/"
    click STATE "https://github.com/icydrae/vaults/tree/main/frontend/src/store/"
    click SEC "https://github.com/icydrae/vaults/blob/main/frontend/src/plugins/Security.js"
    click API "https://github.com/icydrae/vaults/tree/main/frontend/src/services/api/"
    click CONT "https://github.com/icydrae/vaults/tree/main/api/src/Controller/"
    click ENT "https://github.com/icydrae/vaults/tree/main/api/src/Entity/"
    click REP "https://github.com/icydrae/vaults/tree/main/api/src/Repository/"
    click BSEC "https://github.com/icydrae/vaults/tree/main/api/src/Security/"
    click CORS "https://github.com/icydrae/vaults/blob/main/api/src/EventSubscriber/CorsSubscriber.php"
    click CSRF "https://github.com/icydrae/vaults/blob/main/api/src/EventSubscriber/CsrfValidationSubscriber.php"
    click AUTH "https://github.com/icydrae/vaults/blob/main/api/src/Security/Authenticator.php"
    click NGINX "https://github.com/icydrae/vaults/blob/main/docker/nginx/default.conf"
    click VAULT "https://github.com/icydrae/vaults/tree/main/frontend/src/views/Vaults/"
    click LOGIN "https://github.com/icydrae/vaults/tree/main/frontend/src/components/Item/Login/"
    click NOTES "https://github.com/icydrae/vaults/tree/main/frontend/src/components/Item/Note/"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef security fill:#4CAF50,color:white
    classDef api fill:#FFC107,color:black
    classDef backend fill:#FF9800,color:white
    classDef database fill:#F44336,color:white
    classDef infra fill:#9C27B0,color:white
    classDef component fill:#607D8B,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        S[Security]:::security
        A[API]:::api
        B[Backend]:::backend
        D[(Database)]:::database
        I[Infrastructure]:::infra
        C[Components]:::component
    end
```
