Sharing is caring
- Team Members
- Functional Requirement
- Scope
- Design Diagram
- REST endpoints
- Build And Run
- Test Data
- Possible Improvements
- "Hemant Yadav" <github# hyadav5>
Below are the functional requirement expected from the application:
- Ability to add user
- Ability to add group
- Ability to add expense
- Ability to add group expense
- Run settlement
Application support all the above mentioned functional requirement. The current design is limited with the below scopes:
- All the resources like User, Group, Expense have ID field, but it is not used. This ID field can be used once we have database or front end in place.
- Exhustive error handling is not done on the http layer. As it was out of scope.
- Endpoints are not REST compliant.
- REST endpoints are exposed by the application just to ease the job of end user to make requests through curl/Postman.
- Split is only limited to EQUAL division.
/adduser = Add a user
Body: { "Name": "sundar", "Contact": "700097246", "Email": "sundar@gmail.com" }
/addgroup = Add a group
{ "Name": "mandli", "Users": ["hemant", "shyam", "pandey"] }
/users = Show all users
/addexpense = Add an expense
{ "Type": "EQUAL", "Amount": 50000, "PaidBy": "pandey", "Among": ["hemant", "shyam"] }
/addgroupexpense = Add a group expense
Body: { "Amount": 5000, "PaidBy": "pandey", "GroupName": "flatmates" }
/runsettlements = Run settlement
Available make commands:
make clean
make build
make test
Default:
make
Run:
The generated binary can be run simply like a script. It will open a REST serving port at 8080.
./splitwise
Once the application run, its is loaded with the below test data.
- Add 4 users: hemant, kd, pandey, shyam
- Add a group with the name: "flatmates"
- Add an expense of 1000 paid by "hemant" and distributed among above 4 equally.
- Add an expense of 1000 paid by "kd" and distributed among above 4 equally.
- Add a group expense of 2000 paid by "hemant" and distributed among group member.
- Run settlement detailing the pending amount among them.
In the interest of time, following design consideration are ignored:
- We can use Swagger UI and REST endpoints, this will ease our http request and response handling.
- A middleware should have been added before the APIs to take care of request validation, authentication and authorization.
- Different split types can be added like with exact amount, percentage, shares etc.
- A ledger can be added to keep track of active expenses and archived expenses history.