Giter VIP home page Giter VIP logo

ev-chargingstationapi's Introduction

EV-Charging Station โ€“ API

This project implements a RESTful interface for the storage and retrieval of charging station data. It is built using the Spring Framework and Java, with MySQL as the database.

Prerequisites

Before running the project, ensure you have the following installed on your system:

  • Java Development Kit (JDK) version 17 or later
  • Gradle
  • MySQL Server
  • Git (optional, if you want to clone the repository)

Running the Project

Follow these steps to run the EV-Charging Station API:

  1. Clone the Repository (Optional)

    If you haven't already, you can clone the repository using Git:

    git clone https://github.com/santush87/EV-ChargingStationAPI.git

    Alternatively, you can download the source code as a ZIP archive and extract it to your desired location.

  2. Set Up MySQL Database

    • Create a MySQL database for the project.
    • Configure the database connection in the application.yml file located in the src/main/resources directory. Replace the placeholder values with your MySQL database credentials.
  3. Build and Run the Project

    Navigate to the project directory and build the project using Gradle:

    cd EV-ChargingStationAPI
    gradlew build -x test

    This will compile the source code, and package the application into a JAR file located in the build/libs directory.

    Once the build is successful, you can run the application using the following command:

    java -jar build/libs/EV-ChargingStationAPI.jar -Dspring.config.location=file:/app/application.yml

    This will start the Spring Boot application, and it will be accessible at http://localhost:8080.

Running the tests

Currently, the tests need a working MySQL database, that is required due to the dependency of geospatial data types and indexes. We can use in memory MariaDB implementation, but for the purpose of this project we use a mysql database via docker.

docker compose up mysql_test
gradlew test

Running the Project with Docker

Prerequisites

  • JDK 17 or higher installed
  • Docker installed

Instructions

  1. Create a custom network:

    docker network create ev_network
    
  2. Run the Docker containers:

    docker compose up
    
  3. After running the Docker containers, you can optionally run the test suite:

    • Start the database container for tests:
      docker compose up mysql_test
      
    • For Windows:
      .\gradlew.bat test
      
    • For Linux:
      gradlew test
      

Postman Collection

To test the functionalities of the API, import the provided Postman collection file located in the doc folder: /docs/Charging Stations API.postman_collection.json.

Note

  • Ensure that ports specified in the Docker configuration are available and not in use by any other application.
  • The provided Postman collection contains examples of API requests to try out the functionalities.

API Endpoints

Each charging station in this API is characterized by a unique ID, Geo-Coordinates (latitude, longitude), and zipcode/postcode. Internally the search by distance is done using the MySQL geospatial functionality. The query speed could be improved by adding spatial index to the point column as a future improvement.

The EV-Charging Station API provides the following endpoints:

  • GET /api/all: Returns a list of all charging stations.
  • GET /api/charging-station/{unique_id}: Returns the charging station with the given ID.
  • GET /api/charging-station?zipcode={zipcode}: Returns the charging station(s) with the given zipcode.
  • GET /api/near-stations?lat={lat}&lon={lon}&distanceInMeters={distanceInMeters}: Returns a list of charging stations within a specified distance from the given latitude and longitude.
  • POST /api/create: Creates a new charging station.
  • DELETE /api/charging-station/delete?uniqueId={unique_id}: Deletes the charging station with the given ID.

Postman collection

You can find postman collection here

Testing

Unit tests have been included in the project with a coverage of 80%. You can run the tests using Gradle:

gradle test

Additional Notes

  • Make sure to configure the application.yml file to set up your database connection and other configurations as required.
  • This README assumes default configurations. Modify port numbers or any other configurations if you have made changes in the application.

Support

If you encounter any issues or have questions regarding the EV-Charging Station API, please feel free to contact [email protected].

Enjoy using the EV-Charging Station API!

ev-chargingstationapi's People

Contributors

santush87 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.