Skip to content

restful api implementation

windula_k edited this page Nov 3, 2023 · 5 revisions

RESTful API implementation

About the Application

This is a simple web application that exposes a REST API. This application uses Maven as the build tool and the current LTS version of Kotlin 1.7. I hope to add more functionality to this application in the future but for now this project uses the following dependencies:

  • Spring Web
  • Spring JPA/Hibernate
  • Mysql Database
  • Junit

Running the application

You can run this application from your IDE or by running the following command:

./mvnw spring-boot:run

Testing the application

This application uses Junit 5 unit tests and Tescontainers.

Building for Production

If you want to build an artifact that can be used in production you have 2 options. This application uses JAR as the packaging type.

./mvnw clean package

Functionalities

  • KPI Data Retrieval: Users can retrieve key performance indicators for weather data within specified time frames.
  • Custom Time Range Queries: Supports querying data based on custom date ranges provided by the user.
  • Summary and Precipitation Type Analysis: Allows analysis based on weather summary and precipitation types.
  • Browsable API UI: Integrated Swagger UI for easy navigation and testing of the API endpoints.

Known Issues

  • CORS Policy Restrictions: Some users may encounter CORS policy issues when accessing the API from different origins.

  • Error Handling: Exception handling needs to be more robust to cover a wider range of potential failures and provide more informative error messages.

Potential Future Plans

Given more time and resources, the following enhancements are planned:

  • SSM Database Credential Fetching: Implement AWS Systems Manager (SSM) to securely fetch database credentials, avoiding hard-coded sensitive information.
  • Arrow Integration: Utilize the Arrow library to bring more idiomatic functional programming constructs to the Kotlin codebase, enhancing readability and maintainability.
  • Inline Functions: Leverage Kotlin's inline functions for higher-order functions to reduce overhead and improve performance.
  • PIA Security: Implement Privacy Impact Assessment (PIA) compliant security measures to ensure user data is handled with the highest standards of privacy and security.
  • API Rate Limiting: Introduce rate limiting to prevent abuse and ensure fair usage of the API resources.

Integration Testing

Purpose

Verify the interactions between different parts of the application, such as service layers, databases, and other APIs.

Tools

  • Spring Boot Test
  • Testcontainers for testing with real databases
  • RestAssured for testing REST APIs

Strategy

  • Test the integration between different layers of the application.
  • Use Testcontainers to test against a real database in a Docker container.
  • Test REST endpoints with RestAssured to ensure they are working as expected.

End-to-End Testing

Purpose

Verify the system as a whole and ensure that the flow of the application from start to finish works as expected.

Tools

  • Selenium, Cypress for web UI
  • Postman/Newman for API flows

Strategy

  • Automate user interactions with the front end and ensure the backend processes these as expected.
  • Use Postman/Newman to simulate API sequences that mimic real-world use cases.

Performance Testing

Purpose

Ensure the application performs well under expected and peak load conditions.

Tools

  • JMeter
  • Gatling

Strategy

  • Simulate multiple users accessing the application to test its load capacity.
  • Analyze response times, throughput, and resource utilization.

Clone this wiki locally