Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Prerequisites

  • Java 17
  • Gradle
  • Docker

Overview

This project uses the following technologies:

  • Kotlin: The primary programming language for the application.
  • Vertx: A framework for building the REST API.
  • Redis: Used for caching weather data to improve performance.
  • Docker: For containerization of the application.
  • Met.no API: The external weather API used to fetch weather data.
  • Test containers: For simulating the Redis environment during testing.
  • KoTest and Mockk: For unit testing the application.
  • AI agent: The AI agent is used to generate some codes for the application.

Build and Run

  1. Clone the repository:

    git clone git@github.com:arun-14feb/api-template.git
    
  2. Navigate to the project directory:

    cd api-template/weather-api
  3. Build and run unit test for the project:

     ./gradlew build
  4. Build the Dockerimage:

    docker compose --profile local up -d
  5. Run the application:

    ./gradlew :server:runWeatherApp
    
  6. Access the API:

    curl --request GET 'http://localhost:8080/v1/weather/123432432/forecast?lat=59.92396543823618&lon=10.72502319830305&startUtc=2025-08-07T12:00:00Z&endUtc=2025-08-07T13:00:00Z'
    
  7. Stop the application and destory docker containers:

    docker compose --profile local down -v

Architecture Overview

Simple overview of the data flow:

sequenceDiagram
    participant Spond
    participant WeatherAPI
    participant Redis
    participant MetAPI as api.met.no

    Spond->>WeatherAPI: Request weather for event
    WeatherAPI->>Redis: Check cache for forecast
    alt Cache hit
        Redis-->>WeatherAPI: Return cached forecast
        WeatherAPI-->>Spond: Return cached forecast
    else Cache miss
        WeatherAPI->>MetAPI: Call external forecast API
        MetAPI-->>WeatherAPI: Return forecast data
        WeatherAPI->>Redis: Save forecast to cache
        WeatherAPI-->>Spond: Return new forecast
    end
Loading

Next steps

The next natural steps would be.

  1. Implement CI / CD to automate the build and deployment process for this service.
  2. Authentication of the API and rate-limiting logic to protect api.
  3. Monitoring the performance and health of the service. Using tools like Grafana and Prometheus etc.
  4. Better error handling techniques to handle various failure scenarios.

Deployment plan

As this is a simple API call, the deployment I can think of AWS services like,

  1. ECS Fargate—with minimal memory configuration with autoscaling.
  2. A Elasticache redis cluster micro instance.
  3. Assuming other basic are already in place like VPC, IAM roles, security groups etc.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages