# prateek2468/interview-interview-tech-challenge-solution architecture

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

- Interactive diagram: https://gitdiagram.com/prateek2468/interview-interview-tech-challenge-solution
- Repository: https://github.com/prateek2468/interview-interview-tech-challenge-solution

## Overview

##### Project type and purpose
- This is a standalone, backend‐only, event-driven microservice written in Java using the Vert.x toolkit.
- It exposes HTTP endpoints to aggregate and serve weather and air-pollution data by calling the OpenWeather external API.

##### High-level file structure analysis
- pom.xml: Maven build and dependency management.
- src/main/java/org/lotlinx/interview
- MainVerticle.java: Bootstraps the Vert.x event loop and HTTP server on port 8080.
- Constants.java: Shared constants (port numbers, URI paths).
- handlers/interfaces/openWeatherHandler.java: Defines the contract for weather data retrieval.
- handlers/impl/OpenWeatherHandlerImpl.java: Concrete implementation that calls out to the OpenWeather API.
- handlers/impl/MainVerticleHandler.java: Orchestrates incoming HTTP requests, delegates to the appropriate handler.
- util/WebClientHelper.java: Wraps Vert.x WebClient setup for external HTTP calls.
- src/test: A minimal JUnit test (HelloTest) validates the “/hello” endpoint.

##### Key insights from README
- Vert.x event loop architecture.
- Endpoints: /hello (health), /getCurrentAirPollution, /weather/current.
- Aggregation style: accepts comma-separated or repeated “cities” params.
- No persistent storage; fully stateless.

##### Main components
a. Client(s)
- REST clients (curl, UI, other services)
b. HTTP Server (Vert.x MainVerticle)
- Listens on port 8080
c. Routing & Handlers
- MainVerticleHandler: maps incoming requests to service operations
- OpenWeatherHandlerImpl: executes business logic for weather/air-pollution calls
d. WebClientHelper + Vert.x WebClient
- Asynchronous HTTP client for external calls
e. External Service
- OpenWeather API (weather data provider)

##### Relationships and interactions (data flow)
1. Client sends HTTP request →
2. Vert.x MainVerticle receives on eventloop →
3. Routes to MainVerticleHandler →
4. MainVerticleHandler invokes OpenWeatherHandlerImpl →
5. OpenWeatherHandlerImpl uses WebClientHelper →
6. WebClient issues asynchronous HTTP call to OpenWeather API →
7. OpenWeather returns JSON →
8. OpenWeatherHandlerImpl processes & transforms to response format (CSV or JSON) →
9. Response written back via MainVerticle on HTTP response.

##### Architectural patterns & principles
- Event-driven, non-blocking I/O (Vert.x event loop).
- Clear separation of concerns:
- Verticle orchestration vs. handler interfaces vs. external-API implementation
- Dependency injection by interface (openWeatherHandler).
- Stateless design—easy to scale horizontally.

##### Final checklist
- Notation for asynchronous vs. synchronous calls.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client<br/>(curl/UI)"]:::client
    MainVerticle["HTTP Server<br/>(Vert.x MainVerticle)<br/>port 8080"]:::server
    Router["Router & MainVerticleHandler"]:::handler
    Interface["openWeatherHandler<br/>(interface)"]:::interface
    Impl["OpenWeatherHandlerImpl"]:::impl
    WebClient["WebClientHelper & Vert.x WebClient"]:::clientlib
    External["OpenWeather API"]:::external
    POM["pom.xml"]:::build
    Constants["Constants.java"]:::config
    HelloTest["HelloTest<br/>(/hello)"]:::test

    Client -->|"HTTP GET 8080"| MainVerticle
    MainVerticle -->|"routes via Constants"| Router
    Router -->|"calls handleRequest()"| Interface
    Interface -->|"implemented by"| Impl
    Impl -->|"async HTTP call"| WebClient
    WebClient -->|"HTTP GET JSON"| External
    External -->|"JSON response"| WebClient
    WebClient -->|"passes JSON"| Impl
    Impl -->|"transforms to CSV/JSON"| Router
    Router -->|"HTTP response"| MainVerticle
    MainVerticle -->|"HTTP 200"| Client

    POM -.->|builds| MainVerticle
    Constants -.->|provides URIs/ports| MainVerticle
    HelloTest -.->|validates /hello| MainVerticle

    click MainVerticle "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/main/java/org/lotlinx/interview/MainVerticle.java"
    click Constants "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/main/java/org/lotlinx/interview/Constants.java"
    click Interface "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/main/java/org/lotlinx/interview/handlers/interfaces/openWeatherHandler.java"
    click Impl "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/main/java/org/lotlinx/interview/handlers/impl/OpenWeatherHandlerImpl.java"
    click Router "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/main/java/org/lotlinx/interview/handlers/impl/MainVerticleHandler.java"
    click WebClient "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/main/java/org/lotlinx/interview/util/WebClientHelper.java"
    click POM "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/pom.xml"
    click HelloTest "https://github.com/prateek2468/interview-interview-tech-challenge-solution/blob/main/src/test/java/org/lotlinx/interview/HelloTest.java"

    classDef client fill:#AEDFF7,stroke:#036; 
    classDef server fill:#9ED9CC,stroke:#036; 
    classDef handler fill:#B0C4DE,stroke:#036; 
    classDef interface fill:#E3E4FA,stroke-dasharray:5 5,stroke:#036; 
    classDef impl fill:#ADD8E6,stroke:#036; 
    classDef clientlib fill:#B4EEB4,stroke:#036; 
    classDef external fill:#F3E79B,stroke:#036; 
    classDef config fill:#FFE4B5,stroke:#036; 
    classDef build fill:#DCDCDC,stroke:#036; 
    classDef test fill:#F5C6AA,stroke:#036;
```
