yoga-academy
This project is a part of the assignment given by FlexMoney for internship. The overall application is build using Reactjs & Spring Boot.
Database Design
Only one table is used in this entire able. It contains all the fields related to the member's details. The autogenerated field id
is the primary key here. The sample table is as shown below :
id | city | contactno | current_batch | date_of_change | dob | doj | gender | first_name | last_name | next_batch | paid_for_month | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Pune | 9309566652 | 5-6PM | 2022-12-11 | 2003-11-14 | 2022-12-10 | digambar@gmail.com | Male | Digambar | Tupurwadi | 7-8AM | DECEMBER |
2 | Pune | 9309566653 | 8-9AM | null |
1988-11-5 | 2022-13-10 | virat@gmail.com | Male | Virat | Kohli | null |
null |
Most of the fields that are used here are easy to understand. But there are few fields who are new & they are:
current_batch
: Specifies the batch timings followed by the member in the current monthnext_batch
: Gives the batch timings which the member wants to follow from next month onwards because he/she can't change the batch timings & follow it in the same month.date_of_change
: It gives the date on which the member changed the batch timings for the next month. It is required in order to update the batch timings as well as to not let the member follow different timings in the same month itself.paid_for_month
: Specifies the recent month for which the member has paid the fees.
APIs
The endpoint prefix common for all the current APIs is http://localhost:8080/api/v1
. The APIs used in the app are as follows:
/register
1. Register new member - This API takes all the details & validates it . Also it checks if any user is already registered with the same contactno
or email
. If yes then it will throw MemberAlreadyRegisteredException
and if provided details are insufficient then it will throw InsufficientDetailsException
. It also checks whether the age of the candidate is between 18-65,if not then it will throw AgeBeyondRangeException
. If all these checks are passed then it make a new entry in the database. The api returns the newly created member object.
/makepayment/{id}
2. Pay the fees - This API simply takes the member id from the path variable & changes the paid_for_month
field to current month. In case if the payment for the current month is already done, then it will throw PaymentDoneAlreadyException
.
/shiftbatch
3. Change the Batch timings - As specified in the requirements, the member can follow only one batch timing in the same month. And in case if he/she wants to change it, then they can change it anytime but follow it from next month onwards. Thus this API changes the batch timings as per requested for that particular member and updates the date_of_change
field which helps to avoid the member from having different timings in the same month.
/getallmembers
4. Get all members - This API returns all the registered members for the yoga-academy.
/getmember/{id}
5. Get member with ID - This API returns the member registered with the given ID. If no registered member is found with the given ID, then it will throw MemberNotFoundException
.