# rahulkumar035/workhub-microconnect architecture

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

- Interactive diagram: https://gitdiagram.com/rahulkumar035/workhub-microconnect
- Repository: https://github.com/rahulkumar035/workhub-microconnect

## Overview

##### Main Components
- API Gateway: Acts as the entry point for client requests. It handles JWT authentication and forwards requests to appropriate downstream services.
- Eureka Server: Serves as a service registry for service discovery, allowing microservices to register and communicate seamlessly.
- Microservices – Employee, Project, Team: Each service encapsulates its own domains (e.g., EmployeeController, ProjectController, TeamController), business logic, and data entities. The Employee service also has Kafka-related configuration hinting at asynchronous event processing.
- Infrastructure Services:
– Redis Cache: Used for caching, reducing the strike against the database for read-heavy operations.
– MySQL Database: Likely used as the primary persistence store across services.
– Apache Kafka: Supports event streaming between services, enabling asynchronicity for high throughput.
– Docker: Containerizes services to facilitate deployment.
– Distributed Tracing & Monitoring: Zipkin for distributed tracing and Prometheus for monitoring system health.

##### Relationships and Interactions
- Clients (web or mobile) interact with the API Gateway.
- The API Gateway, after validating JWT security, routes the requests to the appropriate microservice based on service discovery provided by Eureka.
- Microservices communicate with the MySQL database (and possibly their own dedicated schemas) and leverage Redis for caching.
- Event streaming via Apache Kafka connects services for asynchronous processing (for instance, events published by Employee service).
- Docker runs and manages the deployment of these containerized services.

##### Architectural Patterns and Technologies
- Microservices Architecture: Each service is modular and independently deployable.
- API Gateway Pattern: Centralized entry point that abstracts the underlying services.
- Service Discovery: Utilized via the Eureka Server.
- Event-Driven Communication: Implemented through Apache Kafka.
- Caching Layer: Redis is prominently used to reduce database load.
- Security: JWT tokens are used at the API gateway to enforce role-based access controls.
- Containerization: Docker is used for packaging and deployment.
- Monitoring & Tracing: Zipkin and Prometheus ensure observability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    Client["Client Application"]:::external

    API_Gateway["API Gateway<br/>(JWT Security)"]:::gateway
    Eureka["Eureka Server"]:::discovery

    %% Employee Microservice
    subgraph "Employee Microservice"
        Employee_App["EmployeeApplication"]:::microservice
        Employee_Controller["EmployeeController"]:::microservice
        Employee_Service["Employee Service"]:::microservice
        Employee_Entity["Employee Entity"]:::microservice
        Kafka_Config["KafkaConfig"]:::microservice
    end

    %% Project Microservice
    subgraph "Project Microservice"
        Project_App["ProjectApplication"]:::microservice
        Project_Controller["ProjectController"]:::microservice
        Project_Service["Project Service"]:::microservice
        Project_Entity["Project"]:::microservice
    end

    %% Team Microservice
    subgraph "Team Microservice"
        Team_App["TeamApplication"]:::microservice
        Team_Controller["TeamController"]:::microservice
        Team_Service["Team Service"]:::microservice
        Team_Entity["Team"]:::microservice
    end

    %% Infrastructure Components
    subgraph "Infrastructure"
        MySQL["MySQL Database"]:::database
        Redis["Redis Cache"]:::cache
        Kafka["Apache Kafka"]:::event
        Docker["Docker Containers"]:::container
        Zipkin["Zipkin Tracing"]:::monitoring
        Prometheus["Prometheus Metrics"]:::monitoring
    end

    %% Connections: Client to API Gateway
    Client -->|"sendsRequest"| API_Gateway

    %% API Gateway to Eureka Server
    API_Gateway -->|"routesThrough"| Eureka

    %% Eureka discovers Microservices
    Eureka -->|"discovers"| Employee_App
    Eureka -->|"discovers"| Project_App
    Eureka -->|"discovers"| Team_App

    %% Internal flow in Employee Microservice
    Employee_App -->|"initializes"| Employee_Controller
    Employee_App -->|"calls"| Employee_Service
    Employee_Controller -->|"delegatesTo"| Employee_Service
    Employee_Service -->|"uses"| Employee_Entity
    Employee_Service -->|"publishesEvent"| Kafka_Config
    Kafka_Config -->|"streamsTo"| Kafka

    %% Internal flow in Project Microservice
    Project_App -->|"initializes"| Project_Controller
    Project_App -->|"calls"| Project_Service
    Project_Controller -->|"delegatesTo"| Project_Service
    Project_Service -->|"operatesOn"| Project_Entity

    %% Internal flow in Team Microservice
    Team_App -->|"initializes"| Team_Controller
    Team_App -->|"calls"| Team_Service
    Team_Controller -->|"delegatesTo"| Team_Service
    Team_Service -->|"operatesOn"| Team_Entity

    %% Microservices Database and Cache Interactions
    Employee_Service -->|"dbAccess"| MySQL
    Employee_Service -->|"cacheLookup"| Redis
    Project_Service -->|"dbAccess"| MySQL
    Project_Service -->|"cacheLookup"| Redis
    Team_Service -->|"dbAccess"| MySQL
    Team_Service -->|"cacheLookup"| Redis

    %% Monitoring and Tracing Connections
    API_Gateway -->|"traces"| Zipkin
    API_Gateway -->|"monitors"| Prometheus
    Eureka -->|"traces"| Zipkin
    Eureka -->|"monitors"| Prometheus
    Employee_App -->|"traces"| Zipkin
    Employee_App -->|"monitors"| Prometheus
    Project_App -->|"traces"| Zipkin
    Project_App -->|"monitors"| Prometheus
    Team_App -->|"traces"| Zipkin
    Team_App -->|"monitors"| Prometheus

    %% Docker containerization arrows
    Docker -->|"hosts"| API_Gateway
    Docker -->|"hosts"| Eureka
    Docker -->|"hosts"| Employee_App
    Docker -->|"hosts"| Project_App
    Docker -->|"hosts"| Team_App

    %% Click Events for API Gateway
    click API_Gateway "https://github.com/rahulkumar035/workhub-microconnect/tree/main/api-gateway/src/main/java/com/example/apigateway"
    
    %% Click Events for Eureka Server
    click Eureka "https://github.com/rahulkumar035/workhub-microconnect/blob/main/eureka-server/src/main/java/com/example/eurekaserver/EurekaServerApplication.java"
    
    %% Click Events for Employee Microservice
    click Employee_App "https://github.com/rahulkumar035/workhub-microconnect/blob/main/employee/src/main/java/com/example/employee/EmployeeApplication.java"
    click Employee_Controller "https://github.com/rahulkumar035/workhub-microconnect/blob/main/employee/src/main/java/com/example/employee/controller/EmployeeController.java"
    click Employee_Entity "https://github.com/rahulkumar035/workhub-microconnect/tree/main/employee/src/main/java/com/example/employee/entity/"
    click Employee_Service "https://github.com/rahulkumar035/workhub-microconnect/tree/main/employee/src/main/java/com/example/employee/service/"
    click Kafka_Config "https://github.com/rahulkumar035/workhub-microconnect/blob/main/employee/src/main/java/com/example/employee/kafka/KafkaConfig.java"

    %% Click Events for Project Microservice
    click Project_App "https://github.com/rahulkumar035/workhub-microconnect/blob/main/project/src/main/java/com/example/project/ProjectApplication.java"
    click Project_Controller "https://github.com/rahulkumar035/workhub-microconnect/blob/main/project/src/main/java/com/example/project/controller/ProjectController.java"
    click Project_Entity "https://github.com/rahulkumar035/workhub-microconnect/blob/main/project/src/main/java/com/example/project/entity/Project.java"
    click Project_Service "https://github.com/rahulkumar035/workhub-microconnect/tree/main/project/src/main/java/com/example/project/service/"

    %% Click Events for Team Microservice
    click Team_App "https://github.com/rahulkumar035/workhub-microconnect/blob/main/team/src/main/java/com/example/team/TeamApplication.java"
    click Team_Controller "https://github.com/rahulkumar035/workhub-microconnect/blob/main/team/src/main/java/com/example/team/controller/TeamController.java"
    click Team_Entity "https://github.com/rahulkumar035/workhub-microconnect/blob/main/team/src/main/java/com/example/team/entity/Team.java"
    click Team_Service "https://github.com/rahulkumar035/workhub-microconnect/tree/main/team/src/main/java/com/example/team/service/"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef gateway fill:#bbf,stroke:#333,stroke-width:2px;
    classDef discovery fill:#afa,stroke:#333,stroke-width:2px;
    classDef microservice fill:#fcf,stroke:#333,stroke-width:2px;
    classDef database fill:#ff9,stroke:#333,stroke-width:2px;
    classDef cache fill:#9ff,stroke:#333,stroke-width:2px;
    classDef event fill:#f99,stroke:#333,stroke-width:2px;
    classDef container fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef monitoring fill:#ccf,stroke:#333,stroke-width:2px;
```
