# sugrado/telco-crm-microservices architecture

> Architecture diagram of the GitHub repository sugrado/telco-crm-microservices, 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/sugrado/telco-crm-microservices
- Repository: https://github.com/sugrado/telco-crm-microservices

## Overview

##### High-Level Architecture Components

The system consists of the following microservices:
- Account Service
- Basket Service
- Catalog Service
- Config Server
- Customer Service
- Discovery Server
- Gateway Service
- Identity Service
- Invoice Service
- Order Service
- Search Service

##### Key Architectural Elements

a) Infrastructure Services:
- Config Server: Centralized configuration management
- Discovery Server: Service registry and discovery (Eureka)
- Gateway Service: API Gateway with security controls

b) Core Business Services:
- Identity Service: Authentication and authorization with JWT
- Customer Service: Customer management with individual customer support
- Account Service: Account management
- Catalog Service: Product catalog management
- Order Service: Order processing
- Invoice Service: Invoice generation and management
- Basket Service: Shopping cart functionality
- Search Service: Elasticsearch-based search functionality

##### Integration Patterns

- Kafka message brokers for event-driven communication
- Redis for caching (used in basket and identity services)
- PostgreSQL databases for persistent storage
- REST API communications between services
- Feign clients for service-to-service communication

**┌─ Client Layer**
- External Clients/UI
- Gateway Layer
- API Gateway (Security, Routing)
- Service Layer
- Business Services
- Infrastructure Services
- Integration Layer
- Message Brokers
- Service Discovery
- Data Layer
- PostgreSQL
- Redis
- Elasticsearch

##### Additional Details

Include:
- Service ports and endpoints
- Security boundaries
- Data flow directions
- Event publishing/subscription relationships
- Cache interactions
- Search service indexing flows

##### Specific Implementation Notes

- How the Gateway Service authenticates with Identity Service
- Event flow from Order Service to Invoice Service
- Demonstrate how Search Service maintains indexes from other services
- Basket Service's interaction with Redis
- How Config Server distributes configurations

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef client fill:#FFE5CC,stroke:#000
    classDef gateway fill:#FFB366,stroke:#000
    classDef infrastructure fill:#E6E6E6,stroke:#000
    classDef business fill:#CCE5FF,stroke:#000
    classDef database fill:#C2E0C2,stroke:#000
    classDef cache fill:#FFD9B3,stroke:#000
    classDef search fill:#FFB3B3,stroke:#000
    classDef messaging fill:#FFB366,stroke:#000

    %% Client Layer
    Client["External Clients/UI"]:::client

    %% Gateway Layer
    Gateway["Gateway Service"]:::gateway
    click Gateway "https://github.com/sugrado/telco-crm-microservices/blob/master/gatewayService/src/main/java/com/turkcell/crm/gateway_service/GatewayServiceApplication.java"

    %% Infrastructure Services
    subgraph Infrastructure
        Config["Config Server"]
        Discovery["Discovery Server"]
        click Config "https://github.com/sugrado/telco-crm-microservices/blob/master/configServer/src/main/java/com/turkcell/crm/config_server/ConfigServerApplication.java"
        click Discovery "https://github.com/sugrado/telco-crm-microservices/blob/master/discoveryServer/src/main/java/com/turkcell/crm/discovery_server/DiscoveryServerApplication.java"
    end

    %% Core Business Services
    subgraph BusinessServices
        Identity["Identity Service"]
        Customer["Customer Service"]
        Account["Account Service"]
        Catalog["Catalog Service"]
        Order["Order Service"]
        Invoice["Invoice Service"]
        Basket["Basket Service"]
        Search["Search Service"]
        click Identity "https://github.com/sugrado/telco-crm-microservices/blob/master/identityService/src/main/java/com/turkcell/crm/identity_service/IdentityServiceApplication.java"
        click Customer "https://github.com/sugrado/telco-crm-microservices/blob/master/customerService/src/main/java/com/turkcell/crm/customer_service/CustomerServiceApplication.java"
        click Account "https://github.com/sugrado/telco-crm-microservices/blob/master/accountService/src/main/java/com/turkcell/crm/account_service/AccountServiceApplication.java"
        click Catalog "https://github.com/sugrado/telco-crm-microservices/blob/master/catalogService/src/main/java/com/turkcell/crm/catalog_service/CatalogServiceApplication.java"
        click Order "https://github.com/sugrado/telco-crm-microservices/blob/master/orderService/src/main/java/com/turkcell/crm/order_service/OrderServiceApplication.java"
        click Invoice "https://github.com/sugrado/telco-crm-microservices/blob/master/invoiceService/src/main/java/com/turkcell/crm/invoice_service/InvoiceServiceApplication.java"
        click Basket "https://github.com/sugrado/telco-crm-microservices/blob/master/basketService/src/main/java/com/turkcell/crm/basket_service/BasketServiceApplication.java"
        click Search "https://github.com/sugrado/telco-crm-microservices/blob/master/searchService/src/main/java/com/turkcell/crm/search_service/SearchServiceApplication.java"
    end

    %% Data Layer
    subgraph DataStores
        PostgreSQL[("PostgreSQL")]:::database
        Redis[("Redis Cache")]:::cache
        Elasticsearch[("Elasticsearch")]:::search
        Kafka{"Kafka Message Broker"}:::messaging
    end

    %% Connections
    Client --> Gateway
    Gateway --> Identity
    Gateway --> BusinessServices
    
    BusinessServices --> Discovery
    BusinessServices --> Config
    
    Order -.-> Kafka
    Kafka -.-> Invoice
    Kafka -.-> Search
    
    Basket --> Redis
    Search --> Elasticsearch
    
    Identity --> PostgreSQL
    Customer --> PostgreSQL
    Account --> PostgreSQL
    Catalog --> PostgreSQL
    Order --> PostgreSQL
    Invoice --> PostgreSQL
    
    %% Legend
    subgraph Legend
        L1["Client"]:::client
        L2["Gateway"]:::gateway
        L3["Infrastructure"]:::infrastructure
        L4["Business Service"]:::business
        L5["Database"]:::database
        L6["Cache"]:::cache
        L7["Search Engine"]:::search
        L8["Message Broker"]:::messaging
    end
```
