# nithack/interview-agibank architecture

> Architecture diagram of the GitHub repository nithack/interview-agibank, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nithack/interview-agibank
- Repository: https://github.com/nithack/interview-agibank

## Overview

##### Main Components
- Client Service API: This microservice manages customer data with full CRUD operations.
- Insurance Service API: This microservice handles both the simulation and actual contracting of insurance policies (Bronze, Silver, Gold). It internally interacts with the Client Service API to validate client existence.
- PostgreSQL Database: Serves as the persistent store for client and insurance data.
- Docker & Deployment: Docker Compose, Dockerfiles, and the build script (build.sh) provide the containers and build automation for the distribution of services.
- (Optional) External Interfaces: Swagger for API documentation, and testing tools (JUnit, Mockito) used for unit/integration tests.

##### Relationships and Interactions
- Docker Compose orchestrates the containerized environment, so include a container orchestration element that groups client-service-api, insurance-service-api, and Postgres, along with directional dependencies (e.g., insurance-service-api depends on client-service-api and postgres).

##### Architectural Patterns and Design Principles
- That both services adhere to SOLID principles and Code Clean practices, which are key in maintaining clear separation of concerns.
- How API gateways (Swagger UI access points) might interact externally (via HTTP ports such as 3030 for client and 3031 for insurance).

##### Relevant Technologies, Frameworks, and Tools
- Java 17, Maven, and Spring Boot (implied by Maven and the use of Spring commands in the README).
- Docker, Docker Compose are used to package and deploy.
- PostgreSQL as the database.
- Testing frameworks: JUnit 5 and Mockito.
- Swagger for API documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker & Deployment"
        direction TB
        DS["Docker Orchestrator"]:::docker
    end

    subgraph "Microservices"
        direction TB
        CS["Client Service API (Hexagonal Architecture)"]:::microservice
        IS["Insurance Service API (Hexagonal Architecture)"]:::microservice
    end

    API["API Consumer / Swagger UI"]:::external
    DB["PostgreSQL Database"]:::database

    API -->|"HTTP REST"| CS
    API -->|"HTTP REST"| IS

    IS -->|"REST call for client verification"| CS
    CS -->|"CRUD operations"| DB
    IS -->|"Data Persistence"| DB

    DS -->|"Deploys"| CS
    DS -->|"Deploys"| IS
    DS -->|"Manages"| DB

    click CS "https://github.com/nithack/interview-agibank/tree/master/client-service-api"
    click IS "https://github.com/nithack/interview-agibank/tree/master/insurance-service-api"
    click DB "https://github.com/nithack/interview-agibank/blob/master/.env.example"
    click DS "https://github.com/nithack/interview-agibank/blob/master/docker-compose.yml"
    click DS "https://github.com/nithack/interview-agibank/blob/master/build.sh"

    classDef microservice fill:#b3e5fc,stroke:#039be5,stroke-width:2px;
    classDef external fill:#ffe082,stroke:#ffb300,stroke-width:2px;
    classDef database fill:#c8e6c9,stroke:#43a047,stroke-width:2px;
    classDef docker fill:#d1c4e9,stroke:#7e57c2,stroke-width:2px;
```
