Skip to content

gstvomacedo/expense-splitter

Repository files navigation

📘 Expense Splitter API Documentation

A serverless application to manage and split group expenses.
Built with Node.js, TypeScript, and AWS Lambdas, emulated locally using LocalStack.


🛠️ Requirements

To run this project locally, ensure you have:

  • Node.js v20+
  • npm
  • Docker
  • LocalStack

⚙️ Local Setup

  1. Start the PostgreSQL locally and run the database migration

    docker-compose up -d
  2. Start LocalStack and deploy AWS components

    npm run start:local

✅ Running Tests

To execute all unit tests and generate a coverage report:

npm run test

The coverage report will be generated in lcov format.


📡 API Endpoints

All endpoints are exposed via LocalStack's API Gateway on:

http://localhost:4566/restapis/<generated API ID>/local/_user_request_

1. ➕ Create Expense Group

Endpoint: POST /groups
Description: Create a new group to organize shared expenses.

🧪 Example Request:

curl --location 'http://localhost:4566/restapis/api-id-example/local/_user_request_/groups' --header 'Content-Type: application/json' --data '{
    "name": "Amigos do futebol"
}'

2. 👤 Add Group Member

Endpoint: POST /group-member
Description: Register a member to a group so they can create and split expenses.

🧪 Example Request:

curl --location 'http://localhost:4566/restapis/api-id-example/local/_user_request_/group-member' --header 'Content-Type: application/json' --data-raw '{
    "name": "Gustavo Macedo",
    "email": "gstvo@macedo.com",
    "groupId": "c6184ddc-8c39-4e9f-b8ab-cc8d9476a42c"
}'

3. 💸 Create Expense

Endpoint: POST /expenses
Description: Create a shared expense and assign it to members of a group.

🧪 Example Request:

curl --location 'http://localhost:4566/restapis/api-id-example/local/_user_request_/expenses' --header 'Content-Type: application/json' --data '{
    "name": "Refri 2L",
    "amount": 10.11,
    "groupId": "c6184ddc-8c39-4e9f-b8ab-cc8d9476a42c",
    "splitToMembersIds": ["831665f7-47f4-47b2-8b2b-973a47efd1e8", "7479e4bf-61b4-441d-bd9c-2a529b698d1a"],
    "payerId": "831665f7-47f4-47b2-8b2b-973a47efd1e8"
}'

📦 AWS Services Used (via LocalStack)

  • AWS Lambda (Functions)
  • SNS (Expense notifications)
  • SES (Email notifications)
  • CloudWatch (Logs)
  • CloudFormation (Resource deployment)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors