# pratikvmarathe/centralized-logging-api architecture

> Architecture diagram of the GitHub repository pratikvmarathe/centralized-logging-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pratikvmarathe/centralized-logging-api
- Repository: https://github.com/pratikvmarathe/centralized-logging-api

## Overview

##### Project type and purpose
- This is a Java‐based reactive microservices application implementing a centralized logging system.
- Purpose: Clients generate log events periodically; a Collector service ingests and enriches them; a Server service stores them in MongoDB and exposes a query API.

##### File structure
- Top-level pom.xml defines four Maven modules:
- common: shared LogEntry model
- client: log‐generator microservice
- collector: TCP/UDP listener, blacklist check, forwarder
- server: Spring WebFlux API, reactive MongoDB persistence
- docker-compose.yml orchestrates MongoDB and all three services in separate Docker containers.
- server/Dockerfile and server/src/main/resources/application.yml configure containerization and service ports.

##### README for architectural insights
- Client services emit logs every 1–2 seconds.
- Collector listens on TCP port 9000, enriches logs, forwards to server.
- Server runs on port 8080, stores into MongoDB at mongo:27017/logdb, and provides HTTP endpoints (/ingest, /logs).

##### Main components
a. Log Generator Clients
- One or many instances of the client microservice (LogClient)
b. Collector Microservice
- CollectorServer: TCP/UDP listener, blacklist check, forward logic
c. Central Logging Server
- Spring WebFlux app (LogController, LogService, LogRepository)
d. Database
- MongoDB container
e. External API consumers
- curl/Postman or any HTTP client querying the /logs endpoint

##### Relationships and data flows
- Optional: Docker Compose orchestrates and links all containers over a common network

##### Architectural patterns and key technologies
- Microservices: each moduleDeploys as its own Docker container
- Reactive / Non‐blocking I/O: Spring WebFlux on server, Reactor on client/collector
- Shared domain: common.LogEntry ensures schema consistency
- Event‐driven: Collector acts as a filter/enricher between producer and consumer
- Persistence: Reactive MongoDB repository (spring-data-mongodb)

##### Capturing essential architectural elements
- Do not omit the common module—even if it’s not a running service, it represents the shared schema.
- Call out the reactive/nonblocking I/O pattern on the server and collector.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker Compose Orchestrator (docker-compose.yml)" 
        direction TB
        style DockerCompose stroke-dasharray: 5 5
        DockerCompose["Docker Compose"]:::orchestrator
    end

    subgraph "Services Network" 
        direction TB
        Common["Shared Domain Model\n(common.LogEntry)"]:::common
        Client["Client Microservice\n(LogClient)\nTCP Stream"]:::service
        Collector["Collector Service\n(CollectorServer)\n- blacklist check"]:::service
        Server["Log API Server\n(Spring WebFlux)\nHTTP:8080"]:::service
        MongoDB[(MongoDB\nmongo:27017/logdb)]:::database
        APIClient["External API Client\n(curl/Postman)"]:::external
    end

    DockerCompose --> Common
    DockerCompose --> Client
    DockerCompose --> Collector
    DockerCompose --> Server
    DockerCompose --> MongoDB

    Client -->|"sendLog() over TCP:9000"| Collector
    Collector -->|"POST /ingest"| Server
    Server -->|"save(LogEntry)"| MongoDB
    APIClient -->|"GET /logs"| Server

    click Common "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/common/src/main/java/com/centralizedlogging/common/LogEntry.java"
    click Client "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/client/src/main/java/com/centralizedlogging/client/LogClient.java"
    click Client "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/client/src/main/java/org/client/App.java"
    click Collector "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/collector/src/main/java/com/centralizedlogging/collector/CollectorServer.java"
    click Collector "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/collector/src/main/java/org/collector/App.java"
    click Server "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/server/src/main/java/com/centralizedlogging/server/ServerApplication.java"
    click Server "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/server/src/main/java/com/centralizedlogging/server/controller/LogController.java"
    click Server "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/server/src/main/java/com/centralizedlogging/server/service/LogService.java"
    click Server "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/server/src/main/java/com/centralizedlogging/server/repository/LogRepository.java"
    click Server "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/server/src/main/java/com/centralizedlogging/server/model/LogDocument.java"
    click Server "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/server/resources/application.yml"
    click DockerCompose "https://github.com/pratikvmarathe/centralized-logging-api/blob/main/docker-compose.yml"

    classDef service fill:#D6E9FF,stroke:#004085,color:#004085;
    classDef common fill:#E8E8E8,stroke:#383838,color:#383838;
    classDef database fill:#C1FFC1,stroke:#387038,color:#387038;
    classDef external fill:#FFD6D6,stroke:#843534,color:#843534;
    classDef orchestrator fill:none,stroke:#6c757d,color:#6c757d,stroke-dasharray: 5 5;
```
