Skip to content

Mario-659/FormulaOneApi

Repository files navigation


Logo

F1 API

API for DMS2 & SE application project
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

About The Project

Database API used by application for Formula 1 team.

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

To run API make sure you have Java SE 17 installed. Application requires PostgreSQL Database Management System for data storage for this purpose you can use local DMS installation or Docker service.

Installation

Windows

  1. Clone the repo
git clone https://github.com/Mario-659/FormulaOneApi.git && cd FormulaOneApi
  1. Make sure Docker daemon is up and running
  2. Set environment variables needed for container set up or modify Intelij configuration options:
set POSTGRES_USER=admin
set POSTGRES_PASSWORD=admin
set POSTGRES_DB=f1api
--------------------------
set WORKING_DIR=<path>  # optional parameter used for postgres data storage (without every time initialization)
  1. Run database on Docker container in detached mode
docker-compose up -d
  1. Set up environment variables needed for API-Docker connection.
set POSTGRES_URL=jdbc:postgresql://localhost:5432/f1api
set POSTGRES_USERNAME=postgres  # has to match with POSTGRES_USER
  1. Build an run project using Gradle tasks (or use Intelij)
gradlew build && gradlew bootRun
  1. Application should create connection and initialize database from predefined import.sql file
  2. Once app is running without any errors, do not close program. API is running and waiting for requests.
  3. Test API with simple request like http://localhost:8080/api/v1/drivers/23 output should looks like this:
// http://localhost:8080/api/v1/drivers/23

{
  "number": 23,
  "firstName": "Alexander",
  "lastName": "Albon",
  "nationality": "Thai",
  "team": {
    "name": "Williams Racing"
  },
  "dateOfBirth": "1996-03-23"
}

Linux

  1. Clone the repo
git clone https://github.com/Mario-659/FormulaOneApi.git && cd FormulaOneApi
  1. Make sure Docker daemon is up and running
  2. Export environment variables needed for container set up or modify Intelij configuration options:
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=admin
export POSTGRES_DB=f1api
--------------------------
export WORKING_DIR  # optional parameter used for postgres data storage (without every time initialization)
  1. Run database on Docker container in detached mode
docker-compose up -d
  1. Set up environment variables needed for API-Docker connection.
export POSTGRES_URL=jdbc:postgresql://localhost:5432/{POSTGRES_DB}
export POSTGRES_USERNAME=postgres  # has to match with POSTGRES_USER
  1. Build an run project using Gradle tasks (Intelij)
gradlew build && gradlew bootRun
  1. Application should create connection and initialize database from predefined import.sql file
  2. Once app is running without any errors, do not close program. API is running and waiting for requests.
  3. Test API with simple request like http://localhost:8080/api/v1/drivers/23 output should looks like this:
// http://localhost:8080/api/v1/drivers/23

{
  "number": 23,
  "firstName": "Alexander",
  "lastName": "Albon",
  "nationality": "Thai",
  "team": {
    "name": "Williams Racing"
  },
  "dateOfBirth": "1996-03-23"
}

Demo

2023-01-15.21-24-51.mp4

Endpoint Documentations

To see swagger endpoint documentation run the spring boot application and go to http://localhost:8080/api/v1/swagger-ui/index.html#/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages