# f1nal3/juniorgram architecture

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

- Interactive diagram: https://gitdiagram.com/f1nal3/juniorgram
- Repository: https://github.com/f1nal3/juniorgram

## Overview

##### Project Type & Purpose
- It’s a full-stack C++ client–server messenger application.
- The README states it’s a “C++ messenger for learning purposes,” and the file tree reinforces this with distinct client, server, and common Base libraries.
- Key goals include practicing modular design (with separate modules for logging, cryptography, network handling, and data access) and tooling integration (CMake, CI/CD via GitHub Actions, testing frameworks).

##### Key Components to Highlight
- Client Subsystem:
– Contains a CLI application (Client.CLI) as the user-facing front end.
– Organized into core functionalities (Client.Core) and supporting test objects (Client.TestObject).
- Server Subsystem:
– Divided into Server.Core (the backbone with components like argument parser, server builder, settings management) and an executable (Server.Exec).
– Numerous tests in Server.Test to validate functionality.
- Network Module:
– Provides core networking capabilities (Connection, EncryptionHandler, CompressionHandler, Serialization via YasSerializer).
– Acts as the communication layer between client and server.
- Data Access Layer:
– Implemented with multiple adaptations, including Debug, Mock, and Postgre versions.
– Contains repositories and adapters for managing database interactions.
- Base Library:
– Includes crucial cross-cutting concerns such as Logger, Crypto, and Models.
– Logger: Offers both static and public versions for logging strategies.
– Crypto: Handles cryptographic functions to secure messaging.
– Models: Defines data structures and primitives (likely utilized by both client and server).
- Utility Modules:
– Contains SQL utilities, exception handling, and other generic helpers supporting the overall system.
- Test & Documentation:
– Several dedicated testing modules (under Test, DataAccess.Test, Server.Test, etc.) indicating a strong emphasis on quality.
– Documentation and style guides provide insight into coding standards and usage.

##### Relationships & Interactions
- The Client communicates with the Server over the Network layer using the provided APIs (from the Network/Public module).
- Both client and server leverage shared components from the Base library (Logger, Crypto, Models) for logging and data integrity.
- The Server uses the Data Access layer to interact with persistent storage (via different adapters: FileDB, Postgre, etc.).
- Utility modules supplement these components with additional functionality like SQL schema management and validation.
- Test directories confirm module interactions and independent unit tests for key components.

##### Architectural Patterns & Principles
- The project exhibits modularity; all features (crypto, logging, models, network) are clearly separated into modules with their own CMake build scripts.
- There’s an implicit layered architecture:
– Presentation layer: Client application (CLI)
– Business logic layer: Server.Core and Client.Core
– Data access layer: DataAccess modules
– Cross-cutting concerns: Base modules and Utility
- Testing is pervasive, indicating a design that encourages verification and separation of responsibilities.
- Use of CMake for managing builds suggests that dependency management & module isolation are key architectural principles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Subsystem
    subgraph "Client Subsystem"
        CLI("Client CLI"):::service
        CoreClient("Client Core"):::service
        TestClient("Client Test Objects"):::test
    end

    %% Server Subsystem
    subgraph "Server Subsystem"
        ServerCore("Server Core"):::service
        ServerExec("Server Exec"):::service
        ServerTest("Server Test"):::test
    end

    %% Network Module
    subgraph "Network Module"
        Network("Network Public APIs"):::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DataPublic("DataAccess Public"):::service
        Debug("Debug Implementation"):::service
        Mock("Mock Implementation"):::service
        Postgre("Postgre Implementation"):::service
    end

    %% Base Library
    subgraph "Base Library"
        Logger("Logger"):::shared
        Crypto("Crypto"):::shared
        Models("Models"):::shared
    end

    %% Utility Modules
    subgraph "Utility Modules"
        UtilityPublic("Utility Public"):::utility
        SQL("SQL Utilities"):::utility
    end

    %% Relationships and Interactions
    %% Client to Network Communication
    CLI -->|"sendsRequest"| Network
    CoreClient -->|"processesData"| Network

    %% Network to Server Communication
    Network -->|"routesMessage"| ServerCore

    %% Server to Data Access
    ServerCore -->|"accesses"| DataPublic
    DataPublic -->|"implements"| Debug
    DataPublic -->|"implements"| Mock
    DataPublic -->|"implements"| Postgre

    %% Shared Base Library usage by Client and Server
    CoreClient -->|"logsVia"| Logger
    CoreClient -->|"encryptsVia"| Crypto
    CoreClient -->|"structures"| Models
    ServerCore -->|"logsVia"| Logger
    ServerCore -->|"encryptsVia"| Crypto
    ServerCore -->|"structures"| Models

    %% Utility Modules support
    UtilityPublic -->|"assists"| CoreClient
    UtilityPublic -->|"assists"| ServerCore
    DataPublic -->|"utilizes"| SQL

    %% Testing Relationships
    TestClient -.->|"testsCLI"| CLI
    ServerTest -.->|"testsServer"| ServerCore

    %% Click Events
    click CLI "https://github.com/f1nal3/juniorgram/blob/dev/Client/Client.CLI"
    click CoreClient "https://github.com/f1nal3/juniorgram/blob/dev/Client/Client.Core"
    click TestClient "https://github.com/f1nal3/juniorgram/blob/dev/Client/Client.TestObject"
    click ServerCore "https://github.com/f1nal3/juniorgram/blob/dev/Server/Server.Core"
    click ServerExec "https://github.com/f1nal3/juniorgram/blob/dev/Server/Server.Exec"
    click ServerTest "https://github.com/f1nal3/juniorgram/blob/dev/Server/Server.Test"
    click Network "https://github.com/f1nal3/juniorgram/tree/dev/Network/Public"
    click DataPublic "https://github.com/f1nal3/juniorgram/tree/dev/DataAccess"
    click Debug "https://github.com/f1nal3/juniorgram/blob/dev/DataAccess/DataAccess.Debug"
    click Mock "https://github.com/f1nal3/juniorgram/blob/dev/DataAccess/DataAccess.Mock"
    click Postgre "https://github.com/f1nal3/juniorgram/blob/dev/DataAccess/DataAccess.Postgre"
    click Logger "https://github.com/f1nal3/juniorgram/tree/dev/Base/Logger"
    click Crypto "https://github.com/f1nal3/juniorgram/tree/dev/Base/Crypto"
    click Models "https://github.com/f1nal3/juniorgram/tree/dev/Base/Models"
    click UtilityPublic "https://github.com/f1nal3/juniorgram/blob/dev/Utility/Utility.Public"
    click SQL "https://github.com/f1nal3/juniorgram/tree/dev/Utility/SQL"

    %% Styles
    classDef service fill:#bbdefb,stroke:#2196F3,stroke-width:2px;
    classDef shared fill:#c8e6c9,stroke:#388E3C,stroke-width:2px;
    classDef utility fill:#ffecb3,stroke:#FFA000,stroke-width:2px;
    classDef test fill:#f8bbd0,stroke:#D81B60,stroke-dasharray: 5,5,stroke-width:2px;
```
