# artemas-muzanenhamo/gov-poc architecture

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

- Interactive diagram: https://gitdiagram.com/artemas-muzanenhamo/gov-poc
- Repository: https://github.com/artemas-muzanenhamo/gov-poc

## Overview

##### Project Type and Purpose
- This is a Spring Boot‐based proof‐of‐concept full‐stack microservice application (no UI in this repo, UI lives in a separate repo).
- It demonstrates a typical Spring Cloud microservice stack: configuration server, service registry (Eureka), API gateway (Zuul), three business microservices, plus MongoDB.
- README confirms purpose: show data flow, service registration/discovery, externalized config, API gateway routing, contract testing with Pact.

##### File Structure Analysis
Top‐level directories correspond to each service/module:
- configuration-server – spring‐cloud‐config server
- discovery-server – Eureka service registry
- gateway – Zuul API gateway
- health-service, identity-service, license-service – three Spring Boot microservices
- mongodb – Dockerfile for MongoDB
- pacts – consumer‐driven contract files
Common patterns:
- Each service has its own build.gradle, Dockerfile, src/main/java, src/main/resources/bootstrap.yml/application.yml, and tests.
- docker-compose.yml orchestrates all containers.

##### Architecture from README
- A centralized Config Server serves config properties to all services.
- Services register with the Discovery Server (Eureka).
- API Gateway (Zuul) routes external traffic to internal services via service names.
- Business services call one another (License calls Identity) through Eureka behind‐the‐scenes.
- MongoDB backs all business services.
- Pact JSONs under pacts/ verify inter‐service contracts between identity ↔ health and identity ↔ license.

a. Main Components
1. Config Server
2. Discovery Server (Eureka)
3. API Gateway (Zuul)
4. Identity Service
5. License Service
6. Health Service
7. MongoDB Database
8. Pact Broker/Contract Files (pacts/) – optional consumer‐driven testing component
9. docker-compose orchestration layer

b. Relationships & Data Flows
- On startup, each microservice (identity, license, health) pulls its config from the Config Server.
- Each service registers its instance and health‐check endpoint with the Discovery Server.
- External client requests → API Gateway → routes (by service name) → Discovery Server resolves instances → forwards to appropriate service.
- License Service invokes Identity Service via service name lookup in Eureka (to validate IDs).
- All services persist/retrieve data from the shared MongoDB instance.
- Pact tests: consumer (health or license) uses pacts/health-service-identity-service.json / pacts/license-service-identity-service.json to validate against provider (identity).

c. Architectural Patterns & Design Principles
- Microservice decomposition: one bounded‐context per service.
- API Gateway pattern (Zuul) for entry point, routing, and edge concerns.
- Service Registry pattern (Eureka) for service discovery and client‐side load balancing.
- Externalized Configuration pattern (Spring Cloud Config).
- Consumer‐Driven Contract Testing (Pact).
- Containerization & orchestration (Docker, docker-compose).

d. Key Technologies & Frameworks
- Spring Boot & Spring Cloud (Config, Netflix Eureka, Zuul)
- MongoDB (NoSQL datastore)
- Docker & Docker Compose
- Pact for CDC testing
- Gradle build system

##### Essential Details to Capture
- Service names and ports (9999 for gateway/discovery, default boot ports).
- Config repo paths (e.g., /shared/*.yml resource files).
- Contract test artifacts under pacts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "docker-compose" 
        class COMPOSE orchestration
        COMPOSE["Docker Compose"] 
        click COMPOSE "https://github.com/artemas-muzanenhamo/gov-poc/blob/develop/docker-compose.yml"

        CLIENT["External Client"]:::external

        subgraph "Infrastructure" 
            CS["Config Server (port 8888)"]:::infra
            DS["Discovery Server (Eureka, port 8761)"]:::infra
            GW["API Gateway (Zuul, port 9999)"]:::infra
        end

        subgraph "Business Services"
            ID["Identity Service"]:::service
            LS["License Service"]:::service
            HS["Health Service"]:::service
        end

        MDB["MongoDB"]:::db
    end

    PACT1["health-service-identity-service.json"]:::pact
    PACT2["license-service-identity-service.json"]:::pact

    CLIENT -->|"HTTP Request"| GW
    GW -->|"Service Lookup"| DS
    GW -->|"Routes Request"| ID
    GW -->|"Routes Request"| LS
    GW -->|"Routes Request"| HS

    ID -->|"register & heartbeat"| DS
    LS -->|"register & heartbeat"| DS
    HS -->|"register & heartbeat"| DS

    ID -->|"fetch config (/config)"| CS
    LS -->|"fetch config (/config)"| CS
    HS -->|"fetch config (/config)"| CS

    LS -->|"validate ID call"| ID
    HS -->|"validate via ID"| ID

    ID -->|"read/write"| MDB
    LS -->|"read/write"| MDB
    HS -->|"read/write"| MDB

    PACT1 -->|"validate provider"| ID
    PACT1 -->|"validate consumer"| HS

    PACT2 -->|"validate provider"| ID
    PACT2 -->|"validate consumer"| LS

    COMPOSE --> CS
    COMPOSE --> DS
    COMPOSE --> GW
    COMPOSE --> ID
    COMPOSE --> LS
    COMPOSE --> HS
    COMPOSE --> MDB

    click CS "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/configuration-server/"
    click DS "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/discovery-server/"
    click GW "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/gateway/"
    click ID "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/identity-service/"
    click LS "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/license-service/"
    click HS "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/health-service/"
    click MDB "https://github.com/artemas-muzanenhamo/gov-poc/tree/develop/mongodb/Dockerfile"
    click PACT1 "https://github.com/artemas-muzanenhamo/gov-poc/blob/develop/pacts/health-service-identity-service.json"
    click PACT2 "https://github.com/artemas-muzanenhamo/gov-poc/blob/develop/pacts/license-service-identity-service.json"

    classDef infra fill:#AED6F1,stroke:#1F618D,color:#1B4F72
    classDef service fill:#A9DFBF,stroke:#196F3D,color:#145A32
    classDef db fill:#F9E79F,stroke:#B7950B,color:#7D6608
    classDef pact fill:#F5B7B1,stroke:#C0392B,color:#922B21
    classDef orchestration fill:#D5DBDB,stroke:#566573,color:#2C3E50
    classDef external fill:#E8DAEF,stroke:#7D3C98,color:#4A235A
```
