# egorvasilev1/iot-cloud architecture

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

- Interactive diagram: https://gitdiagram.com/egorvasilev1/iot-cloud
- Repository: https://github.com/egorvasilev1/iot-cloud

## Overview

##### Main Components Identification
The system consists of several key microservices and components:

a. Core Services:
- API Gateway (Spring Cloud Gateway)
- Auth Service (Quarkus-based)
- Eureka Server (Service Discovery)
- Redis (for caching)

b. Supporting Infrastructure:
- PostgreSQL Database (for Auth Service)
- Docker containers
- GitHub Actions CI/CD pipeline

##### Component Relationships

**Client → API Gateway → Services**
- ↕
- Eureka Server
- ↕
- Auth Service ← → Database
- ↕
- Email Service

##### Specific Flow Representations

a. Authentication Flow:
**Client → API Gateway → Auth Service → Email Service**
- ↓
- Redis Cache

b. Device Verification Flow:
**Client → API Gateway → Auth Service → Device Hash Verification**

##### Additional Details

- Service ports and communication protocols
- Security boundaries
- Cache interaction points
- Service discovery connections
- Database relationships

##### Technical Specifications to Note

- Java-based microservices
- Gradle build system
- Docker containerization
- Spring Cloud & Quarkus frameworks
- JWT-based authentication
- Email-based verification

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        C1[Mobile Client]
        C2[Web Client]
    end

    subgraph Gateway["Gateway Layer"]
        AG["API Gateway"]:::gateway
        JF["JWT Filter"]:::security
        CC["Cache Config"]:::config
        GC["Gateway Config"]:::config
    end

    subgraph Discovery["Service Discovery Layer"]
        ES["Eureka Server"]:::discovery
    end

    subgraph Services["Service Layer"]
        AS["Auth Service"]:::service
        TS["Token Service"]:::security
        UM["User Management"]:::service
        DV["Device Verification"]:::security
        EM["Email Service"]:::external
    end

    subgraph Data["Data Layer"]
        DB[(PostgreSQL)]:::database
        RC[(Redis Cache)]:::cache
    end

    subgraph Infrastructure["Infrastructure"]
        DC["Docker Containers"]:::infra
        CI["GitHub Actions CI/CD"]:::infra
    end

    %% Relationships
    C1 & C2 --> AG
    AG --> JF
    AG --> CC
    AG --> GC
    AG <--> ES
    AG --> AS
    AS <--> ES
    AS --> TS
    AS --> UM
    AS --> DV
    AS --> EM
    AS --> DB
    AG --> RC

    %% Click Events
    click AG "https://github.com/EgorVasilev1/IoT-Cloud/tree/main/microservices-java/api-gateway/"
    click AS "https://github.com/EgorVasilev1/IoT-Cloud/tree/main/microservices-java/auth-service/"
    click ES "https://github.com/EgorVasilev1/IoT-Cloud/tree/main/microservices-java/eureka-server/"
    click JF "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/api-gateway/src/main/java/ru/iot_cloud/apigateway/security/JwtAuthenticationFilter.java"
    click TS "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/auth-service/src/main/java/ru/iot_cloud/security/TokenService.java"
    click DV "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/auth-service/src/main/java/ru/iot_cloud/user/UserDeviceHash.java"
    click EM "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/auth-service/src/main/java/ru/iot_cloud/user/EmailService.java"
    click CC "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/api-gateway/src/main/java/ru/iot_cloud/apigateway/config/CacheConfig.java"
    click GC "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/api-gateway/src/main/java/ru/iot_cloud/apigateway/config/GatewayConfig.java"
    click UM "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/microservices-java/auth-service/src/main/java/ru/iot_cloud/user/UserResource.java"
    click DC "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/docker-compose.yml"
    click CI "https://github.com/EgorVasilev1/IoT-Cloud/blob/main/.github/workflows/CloudDeploy.yml"

    %% Styling
    classDef gateway fill:#3498db
    classDef security fill:#e74c3c
    classDef service fill:#2ecc71
    classDef discovery fill:#f1c40f
    classDef database fill:#95a5a6
    classDef cache fill:#e67e22
    classDef external fill:#9b59b6
    classDef config fill:#1abc9c
    classDef infra fill:#34495e

    %% Legend
    subgraph Legend
        L1[Gateway Component]:::gateway
        L2[Security Component]:::security
        L3[Service Component]:::service
        L4[Discovery Component]:::discovery
        L5[(Database)]:::database
        L6[(Cache)]:::cache
        L7[External Service]:::external
        L8[Configuration]:::config
        L9[Infrastructure]:::infra
    end
```
