# shaky-ground/earthquake-be architecture

> Architecture diagram of the GitHub repository shaky-ground/earthquake-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shaky-ground/earthquake-be
- Repository: https://github.com/shaky-ground/earthquake-be

## Overview

##### Main Components

a. Client Layer
- Web Browsers/API Clients
- HTTP GET requests to /earthquakes endpoint

b. Application Layer (Spring Boot Application)
- Controllers (EventsResource)
- Services (EventsService)
- Configuration (WebClientConfig)
- DTOs Package (showing data models)

c. External Services
- USGS Earthquake API
- API endpoint integration

##### Component Relationships

- Client → EventsResource → EventsService → WebClient → USGS API
- ↓
- DTO Models

##### Specific Elements

a. Components:
- Use rectangles for main components
- Use rounded rectangles for services

- Blue: Client-facing components (REST controllers)
- Green: Service layer components
- Yellow: Configuration components
- Gray: External services
- Orange: Data models/DTOs

##### Important Details to Highlight

a. Data Flow:
- Request/response cycle
- JSON response format
- 24-hour time window filter

b. Key Classes:
- EarthquakeDto
- FeatureDto
- GeometryDto
- MetaDataDto
- PropertiesDto

##### Technical Specifications

- Java 17
- Spring Boot
- Maven
- WebClient for HTTP calls
- Port 8080 for local deployment

## Diagram (Mermaid)

```mermaid
graph TB
    title[Earthquake API System Architecture]:::title

    subgraph Client
        browser[Web Browsers/API Clients]:::client
    end

    subgraph SpringBootApp[Spring Boot Application]
        entry[EarthquakeBeApplication]:::app
        controller[EventsResource]:::controller
        service[EventsService]:::service
        webclient[WebClientConfig]:::config

        subgraph DTOs[Data Transfer Objects]
            earthquake[EarthquakeDto]:::dto
            feature[FeatureDto]:::dto
            geometry[GeometryDto]:::dto
            metadata[MetaDataDto]:::dto
            properties[PropertiesDto]:::dto
        end

        subgraph Config[Configuration]
            appConfig[application.properties]:::config
            continents[continents.yaml]:::config
        end
    end

    subgraph External
        usgs[USGS Earthquake API]:::external
    end

    %% Relationships
    browser -->|HTTP GET /earthquakes| controller
    controller --> service
    service --> webclient
    webclient -->|HTTP GET| usgs
    service --> DTOs
    Config --> service

    %% Click Events
    click entry "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/EarthquakeBeApplication.java"
    click controller "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/EventsResource.java"
    click service "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/EventsService.java"
    click webclient "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/config/WebClientConfig.java"
    click earthquake "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/entities/EarthquakeDto.java"
    click feature "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/entities/FeatureDto.java"
    click geometry "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/entities/GeometryDto.java"
    click metadata "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/entities/MetaDataDto.java"
    click properties "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/java/org/shakyground/earthquakebe/earthquake/events/entities/PropertiesDto.java"
    click appConfig "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/resources/application.properties"
    click continents "https://github.com/shaky-ground/earthquake-be/blob/main/src/main/resources/continents.yaml"

    %% Styles
    classDef title fill:#f9f,stroke:#333,stroke-width:4px
    classDef client fill:#e9ecef,stroke:#333
    classDef app fill:#d0f4de,stroke:#333
    classDef controller fill:#90e0ef,stroke:#333
    classDef service fill:#98f5e1,stroke:#333
    classDef config fill:#ffd60a,stroke:#333
    classDef dto fill:#ffa07a,stroke:#333
    classDef external fill:#dee2e6,stroke:#333

    %% Legend
    subgraph Legend
        l1[Client]:::client
        l2[Controller]:::controller
        l3[Service]:::service
        l4[Configuration]:::config
        l5[DTOs]:::dto
        l6[External Service]:::external
    end
```
