# danielchc/eride-server architecture

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

- Interactive diagram: https://gitdiagram.com/danielchc/eride-server
- Repository: https://github.com/danielchc/eride-server

## Overview

##### Main Components
- gRPC Client – Representing external clients which use client certificates (as generated in the README) to initiate secure communication.
- gRPC Server – The entry point is “cmd/main.go” that starts the server and loads the various application modules.
- Authentication Service – Defined in “service/auth_service.go” and its associated proto file (“proto/auth_service.proto”). This is the core business logic handling authentication requests.
- Application Modules:
○ Authentication Module (app/auth) – Contains “auth_store.go”, “jwt.go”, and “user.go”. This module handles user data, token generation, and auth logic.
○ Configuration Module (app/config) – Reads and manages configuration settings from “config.yaml.example”.
○ Database Module (app/db) – Provides the database connection and interaction logic via “db_provider.go”.
○ Constants Module (app/consts) – Defines application-wide constants in “consts.go”.
○ Security Module (app/security) – Manages TLS settings and certificate handling (especially important for gRPC security) using “tls.go”.

##### Relationships and Interactions
- The gRPC Server (initiated via “cmd/main.go”) acts as the central hub. It receives client requests and routes them to the Authentication Service.
- The Authentication Service interfaces with the Authentication module for user and JWT handling.
- Read configuration settings via the Configuration module.
- Call the Database module for any data persistence or retrieval.
- Use the Constants and Security modules in supporting roles.

##### Architectural Patterns / Design Principles
- Modularity and Separation of Concerns: Each domain (auth, config, db, security, constants) is separated into its own package.
- gRPC-based Microservice Style: The service exposes its functionalities via a gRPC interface (with explicit use of protocol buffers).
- Secure Communication: The design emphasizes TLS with mutual certificate authentication, with steps outlined in the README.

##### Final Recommendations
- Clear labels on all components.
- As much detail as possible, breaking down the service into subcomponents; do not hesitate to include extra nodes if they represent significant parts of the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["gRPC Client (Uses Client Certificates)"]:::external
    Server["gRPC Server (cmd/main.go)"]:::server
    AuthService["Authentication Service (service/auth_service.go)"]:::service
    Proto["Proto Interface (proto/auth_service.proto)"]:::proto
    AuthModule["app/auth - User Auth & JWT Management"]:::module
    ConfigModule["app/config - Configuration"]:::module
    DBModule["app/db - Database Connection"]:::db
    ConstsModule["app/consts - Global Constants"]:::module
    SecurityModule["app/security - TLS & Certificate Management"]:::module

    Client -->|"TLSsecured"| Server
    Server -->|"RoutesRequests"| AuthService
    AuthService -->|"Implements"| Proto
    AuthService -->|"Uses"| AuthModule
    AuthService -->|"Reads"| ConfigModule
    AuthService -->|"Queries"| DBModule
    AuthService -->|"Utilizes"| ConstsModule
    AuthService -->|"SecuresWith"| SecurityModule

    click Server "https://github.com/danielchc/eride-server/blob/master/cmd/main.go"
    click AuthService "https://github.com/danielchc/eride-server/blob/master/service/auth_service.go"
    click Proto "https://github.com/danielchc/eride-server/blob/master/proto/auth_service.proto"
    click AuthModule "https://github.com/danielchc/eride-server/tree/master/app/auth"
    click ConfigModule "https://github.com/danielchc/eride-server/blob/master/app/config/config.go"
    click DBModule "https://github.com/danielchc/eride-server/blob/master/app/db/db_provider.go"
    click ConstsModule "https://github.com/danielchc/eride-server/blob/master/app/consts/consts.go"
    click SecurityModule "https://github.com/danielchc/eride-server/blob/master/app/security/tls.go"

    classDef external fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef server fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef service fill:#f4a460,stroke:#333,stroke-width:2px;
    classDef proto fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef module fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef db fill:#dda0dd,stroke:#333,stroke-width:2px;
```
