This project was created as part of Bright Network Tech Academy, composing key layers of web app backend.
To understand the thought process of this project, please go through the comments in commit history.
The JPA branch and main branch are completely separate. JPA branch uses Spring Data JPA to initialise database, recommended using the JPA branch over main for the ease of database setup.
This is open source code for learning purposes only, all rights reserved by the code owner
Bootcamp is a web app that contains a collection of all live courses: users can register, add courses to wishlist and submit feedback to courses. Each course has an average rating which is calculated from all submitted feedback for the course.
GET /courses
Returns a list of courses with their predefined properties.
Optional query parameters:
- sort by properties of the courses (e.g. price, rating), default is course id
GET /courses/[insert course id]
Retrieve detailed information about a course.
POST /courses
Allows you to add a new course.
The request body needs to be in JSON format.
Example
{
"name": "How to be a part-time youtuber",
"description": "super cool",
"category": "YOUTUBE",
"deadline": "2022-01-05",
"cost": 3000,
"location": "ONLINE",
"place": "Slack",
"spacesAvailable": 50,
"signUpThrough": "{{$randomCompanyName}}"
}
GET /users
Returns a list of users with their encryted password, resgiter and last updated profile date time
Optional query parameters:
- sort by properties of the user (e.g. name, created_at date), deafault is id
POST /users
Allows you to add a new user.
The request body needs to be in JSON format and include the following properties:
name
- String, requiredemail
- String requiredpassword
- String, required
Example
{
"name" "Jack N"
"email": "prince@gmail.com",
"password":"pass"
}
POST /users/login
Allows the registerd user to login, requires the following parameters
name
- string, requiredpassword
- string, required
Throws an authorized error if password incorrect. To change the password, send PUT request to \users
To logout, send DELETE request to the endpoint
POST /wishlist/[insert user id]?courseID=[insert course id]
GET /wishlist/[insert user id]
POST /feedback
Allows you to submit a feedback for a course, requires following parameters
courseId
- int, requireduserId
- int, requiredcourseRating
- double, requiredcomment
- string, optional
Example
{
"courseId": 1,
"userId": 10,
"courseRating": 5.0,
"comment": "loving it"
}
All four main endpoints, users
, courses
, wishlist
, feedback
have all the core CRUD functionalities
(except Wishlist
, only has GET, POST, DELETE, and only need query parameters).
Everytime user add a feedback, the rating property of course will be automically calculated.
Project is created with:
- IntelliJ IDEA (Spring Boot)
- PostgreSQL
- Postman
To start the application, run BootcampBackendApplication
, test the endpoints with Postman
Please refer to the ERD to setup your database
Any question about the project, please feel free to get in touch :)