Skip to content

Implemented a mini API version of what I think of the transport for london oyster card system

Notifications You must be signed in to change notification settings

ezemery/tfl_mini_springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transport for London (TfL) Mini API

Overview

This project is a simplified version of the Transport for London (TfL) system, designed to simulate the London Transportation Network. It provides an API to manage transportation cards, track trips, and calculate fares based on stations and zones.

TFL image

Table of Contents

Features

  • Card Management: Manage transportation cards, each linked to a wallet holding the card balance.
  • Trip Recording: Track trips made with the card, including check-in and check-out stations.
  • Station and Zone Management: Handle stations and their corresponding zones.
  • Fare Calculation: Calculate trip fares based on the zones and transportation mode.

Technologies Used

  • Java 17
  • Spring Boot
  • Spring Data JPA
  • H2 Database (for development and testing)
  • JUnit & Mockito (for testing)
  • Maven (for build automation)
  • Swagger (for API documentation)

Database Design

The database design revolves around the following key tables:

  • Card: Stores card details and links to a wallet.
  • Wallet: Holds the balance associated with a card.
  • Trip: Records trips made with a card, including check-in and check-out stations.
  • Station: Represents stations, each linked to a zone.
  • Zone: Stores zone information, used to calculate fares.
  • Fare: Stores fare rates based on zones and transport modes.

API Endpoints

Card API

  • POST /api/v1/card/create - Create a new card.
  • GET /api/v1/card/{id} - Retrieve card details by ID.

Trip API

  • POST /api/v1/trip/checkin - Record a new trip.
  • PUT /api/v1/trip/checkout - Update the check-out station for an existing trip.

Setup and Installation

Prerequisites

  • Java 17
  • Maven

Installation

  1. Clone the repository:

    git clone https://github.com/ezemery/tfl-mini-springboot.git
    cd tfl-mini-api
  2. Build the project:

    mvn clean install
  3. Run the application:

    mvn spring-boot:run

Usage

Once the application is running, you can interact with the API using tools like Postman or cURL. The application runs on http://localhost:8080 by default.

To view the API documentation, visit: http://localhost:8080/swagger-ui/

Testing

To run the tests, use:

mvn test

About

Implemented a mini API version of what I think of the transport for london oyster card system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages