- Java 17
- Gradle
- Docker
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.
-
Clone the repository:
git clone git@github.com:arun-14feb/api-template.git
-
Navigate to the project directory:
cd api-template/weather-api -
Build and run unit test for the project:
./gradlew build
-
Build the Dockerimage:
docker compose --profile local up -d -
Run the application:
./gradlew :server:runWeatherApp
-
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' -
Stop the application and destory docker containers:
docker compose --profile local down -v
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
The next natural steps would be.
- Implement CI / CD to automate the build and deployment process for this service.
- Authentication of the API and rate-limiting logic to protect api.
- Monitoring the performance and health of the service. Using tools like Grafana and Prometheus etc.
- Better error handling techniques to handle various failure scenarios.
As this is a simple API call, the deployment I can think of AWS services like,
- ECS Fargate—with minimal memory configuration with autoscaling.
- A Elasticache redis cluster micro instance.
- Assuming other basic are already in place like VPC, IAM roles, security groups etc.