Challenge Overview

Childhood Dream

This is the EASY LEVEL Level Competition

As a new employee, he needs to complete the onboarding process which involves familiarizing himself with the list of trains & services being provided - Steve is required to quickly go through the list of available trains/ services and their details.

Your task in this challenge is to create an initial application using Java, Spring & PostgreSQL. You are given a starter application and in this task, you have to modify and extend that starter application to create the Restful API to help Steve manage the trains.

Solving this problem you learn:
  • How to configure Spring Data, JPA, Hibernate to work with PostgreSQL Database
  • How to define Data Models and Repository interfaces
  • Way to create Spring Rest Controller to process HTTP requests
  • Way to use Spring Data JPA to interact with PostgreSQL Database
  • Use sql to load initial database table and content
  • Create new endpoint to retrieve all trains data
Learning Resource:

What do you need to do?

  • Follow the exact base API endpoint, automated testers will check the exact same address: http://localhost:8080/api/trains
  • Match the exact code status & wording (lowercase) for the returned message.
  • Match the exact data model and type

Technology Stack
  • Java 8
  • Spring Boot 2 (with Spring Web MVC, Spring Data JPA)
  • PostgreSQL
  • Maven

Project Structure:
  • Train data model class corresponds to entity and table tutorials.
  • TrainRepository is an interface that extends JpaRepository for CRUD methods and custom finder methods. It will be autowired in TrainController.
  • TrainController is a RestController which has request mapping methods for RESTful requests.
  • Configuration for Spring Datasource, JPA & Hibernate in
  • pom.xml contains dependencies for Spring Boot and PostgreSQL.

Data Model for Train
  • id: long
  • name: String
  • description: String
  • distance-between-stop: String
  • max-speed: String
  • sharing-tracks: Boolean
  • grade-crossing: Boolean
  • train-frequency: String
  • amenities: String


1. Fix data init on db/sql
  • Copy and move data of all 5 trains from this JSON to SQL format inside /db folder on sample submission:

2. Create new endpoint to view all train
  • Method : GET
  • Url : /api/trains/
  • Response:
    • Success:
      • Need return 200 code and
      • Need load all with trains with all keys and values
    • Error:
      • When use other endpoint need return 405 code and
      • {message: "invalid endpoint"}
3. Create new endpoint to view train detail by id
  • Method : GET
  • Url : /api/trains/:id
  • Response:
    • Success:
      • Need return 200 code and
      • Return details of selected train details by id
    • Error:
      • When view train that id not exist
        • need return 404 code and
        • {message: “train not found”}

Sample Submission:

Final Submission Guidelines

Topcoder Skill Builder | Java + Springboot + PostgreSQL Levels

Host Challenge & Submission Guideline | Challenge Link:
Easy | Challenge Link:
Medium | Challenge Link:
Hard |  Challenge Link:


2021 Topcoder(R) Open

Review style

Final Review

Community Review Board


User Sign-Off

ID: 30168991