This is the backend repository for the "Pile Up" React Native Android app.
The app helps users manage money they have lent to others and split expenses during group activities (e.g., trips, events).
- User authentication using OTP.
- Manage contacts and transactions between users.
- Create transactions (request/payback money).
- Handle multiple transactions between users.
- Manage user profile and set names.
- Delete contacts and transactions.
- Node.js
- Fastify.js
- MongoDB
- Mongoose
- JWT Authentication
- dotenv for environment variables
-
POST /request-otp
Request an OTP for user authentication. -
POST /verify-otp
Verify the OTP and authenticate the user.
-
POST /set-name
Set the name of the authenticated user. -
GET /contacts
Get all contacts of the authenticated user. -
DELETE /contacts/:contactId
Delete a contact from the authenticated user's contact list. -
GET /contacts/transactions/:contactId/:transactionId?
Get transactions for a specific contact. If atransactionId
is provided, get the new transactions since the last transaction with that contact.
-
POST /
Create a new transaction (either request or payback). -
DELETE /:transactionId
Delete an existing transaction.
name
: Name of the user.number
: User's phone number.otp
: OTP code for authentication.netBalance
: User's current net balance.contacts
: A list of the user's contacts with contact IDs, balances, and transactions.transactions
: User's list of transactions (not directly linked but handled via contacts).
senderId
: ID of the user sending the money.recieverId
: ID of the user receiving the money.amount
: Amount of money involved in the transaction.date
: Date of transaction.description
: Description of the transaction.transactionType
: Type of transaction ('request' or 'payback').isApproved
: Boolean indicating whether the transaction has been approved.
- Handles user authentication using JWT.
- Verifies the
sessionToken
in the request headers. - Adds authenticated user to
req.user
.
-
Clone the repository:
git clone https://github.com/Ciphrox/pile-up-backend
-
Navigate to the project directory:
cd pile-up-backend
-
Install dependencies:
npm install
-
Create a
.env
file in the root of the project and add the following environment variables:-
JWT_SECRET
: Secret key for JWT token generation. You can generate a secret key using the following bash command:openssl rand -base64 32
-
MONGO_URI
: MongoDB connection URI.
-
-
Start the backend server:
npm start
- The backend API can be used by the React Native mobile app to handle all transactions and user management features.
- Authentication is handled via OTP, and users can interact with their contacts and manage payments and requests through the API.
Feel free to contribute to the project by opening an issue or submitting a pull request.
This project is licensed under the MIT License.
- MongoDB for the database.
- Fastify.js for the web framework.
- JWT for authentication and security.
If you have any questions or issues, feel free to contact the maintainers or open an issue in the repository.