# ryansilva2004/cricstatlk architecture

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

- Interactive diagram: https://gitdiagram.com/ryansilva2004/cricstatlk
- Repository: https://github.com/ryansilva2004/cricstatlk

## Overview

##### Main Components
- API Gateway – Acts as the single entry point for client requests and aggregates responses from various microservices.
- Microservices – Each is dedicated to a specific domain:
- Player Service: Handles player details.
- Match Service: Manages match information.
- Team Service: Manages team data.
- Performance Service: Records performances.
- Statistics Service: Aggregates and computes statistics.
- Frontend – Implements the user interface using Next.js, consuming the API Gateway’s endpoints.
- (Optional) Shared Infrastructure – Although not explicitly shown in the repository, consider representing common concerns like a database layer for each service or any shared message broker if used.

##### Relationships and Interactions
- The Frontend sends requests to the API Gateway.
- The API Gateway routes these requests to the appropriate microservice(s) based on the domain (players, matches, teams, etc.).
- Microservices might interact with their own databases (each project contains its configuration under src/main/resources with properties files).

##### Architectural Patterns and Design Principles
- Microservices Architecture: Each service is decoupled and focused on a single business capability.
- API Gateway Pattern: All external requests are funneled through one entry point.
- Modular Design: Spring Boot is used for individual domain services, ensuring scalability and maintainability.
- Separation of Concerns: Frontend (Next.js) is separated from backend operations (Spring Boot microservices).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F["cricstatlk-frontend (Next.js)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        G["API Gateway (Spring Boot)"]:::gateway

        subgraph "Microservices"
            PS["Player Service"]:::microservice
            MS["Match Service"]:::microservice
            TS["Team Service"]:::microservice
            PFS["Performance Service"]:::microservice
            SS["Statistics Service"]:::microservice
        end
    end

    %% Request Flows
    F -->|"REST_Request"| G
    G -->|"Routes_to_players"| PS
    G -->|"Routes_to_matches"| MS
    G -->|"Routes_to_teams"| TS
    G -->|"Routes_to_performances"| PFS
    G -->|"Routes_to_statistics"| SS

    %% Click Events
    click F "https://github.com/ryansilva2004/cricstatlk/tree/main/cricstatlk-frontend"
    click G "https://github.com/ryansilva2004/cricstatlk/blob/main/api-gateway/src/main/java/lk/cricstat/api_gateway/ApiGatewayApplication.java"
    click G "https://github.com/ryansilva2004/cricstatlk/blob/main/api-gateway/src/main/java/lk/cricstat/api_gateway/Config/GatewayConfig.java"
    click PS "https://github.com/ryansilva2004/cricstatlk/blob/main/players/src/main/java/lk/crickstat/players/Controller/PlayersController.java"
    click MS "https://github.com/ryansilva2004/cricstatlk/blob/main/matches/src/main/java/lk/crickstat/matches/Controller/MatchesController.java"
    click TS "https://github.com/ryansilva2004/cricstatlk/blob/main/teams/src/main/java/lk/cricstat/teams/Controller/TeamsController.java"
    click PFS "https://github.com/ryansilva2004/cricstatlk/blob/main/performances/src/main/java/lk/crickstat/performances/Controller/PerformancesController.java"
    click SS "https://github.com/ryansilva2004/cricstatlk/blob/main/statistics/src/main/java/lk/crickstat/statistics/Controller/StatisticsController.java"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef gateway fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef microservice fill:#fff3cd,stroke:#333,stroke-width:2px;
```
