A full-stack Payment application built with Node.js, Express.js, MongoDB, and React.js which allows users to sign up 🆕, sign in 🔒, view their account balance 💰, and transfer money to other registered users.
- Clone the repository:
git clone https://github.com/gupta-soham/payments-app.git
- Optionally you can checkout the
local
branch:git checkout local
and run the server using the localhost literals.
- Optionally you can checkout the
-
Backend Setup:
- Navigate to the
backend
directory. - Run
npm install
to install the dependencies. - Create a
.env
file and add the following environment variables:DB_URI
: The connection string for your MongoDB database.JWT_SECRET
: A secret key used for signing and verifying JWT tokens.PORT
: The port number for the backend server (e.g.,3000
)
For simplicity, I have also provided an example
.env
file which can be renamed and replaced with the actual variable values.- Run
npm run prod
to start the server.
- Navigate to the
-
Frontend Setup:
- Navigate to the
frontend
directory. - Run
npm install
to install the dependencies. - Create a
.env
file and add the following environment variable:VITE_BE_API
: The URL of your backend API (e.g.,http://localhost:3000/api/v1
).
- Run
npm run dev
to start the development server. - Open your web browser and visit
http://localhost:5173
(or the URL provided by the frontend development server)
- Navigate to the
Note if you are on the
main
branch the you have to create another.env
file in thefrontend
directory and provideVITE_BE_API
as the link to access the backend API calls. This step can be skipped if you are on thelocal
branch.
The Payments App provides the following features:
-
User Authentication:
- Users can sign up 🆕 and create a new account.
- Users can sign in 🔒 with their credentials and receive a JWT token for authentication.
-
Account Management:
- Users can view their account balance 💰.
- Users can transfer money to other registered users.
-
User Search:
- Users can search for other registered users by their first or last name.
- Users can initiate a money transfer to any other user.
The backend of the application is built with Node.js and Express.js, and it uses MongoDB as the database. The backend code is located in the backend
directory.
The following dependencies are used in the backend:
cors
: For handling Cross-Origin Resource Sharing (CORS)express
: A web application framework for Node.jsjsonwebtoken
: For generating and verifying JSON Web Tokens (JWT)mongoose
: An Object Data Modeling (ODM) library for MongoDBzod
: For data validation and parsing
POST /api/v1/user/signup
: Creates a new user accountPOST /api/v1/user/signin
: Authenticates a user and returns a JWT tokenGET /api/v1/user/me
: Returns the authenticated user's details (requires authentication)PUT /api/v1/user/
: Updates the authenticated user's profile (requires authentication)GET /api/v1/user/bulk
: Returns a list of users based on a search filter
GET /api/v1/account/balance
: Returns the authenticated user's account balance (requires authentication)POST /api/v1/account/transfer
: Transfers money from the authenticated user's account to another user's account (requires authentication)
The frontend of the application is built with React.js and is located in the frontend
directory.
The following dependencies are used in the frontend:
axios
: For making HTTP requestsreact
: The React libraryreact-dom
: Provides DOM-specific methods for Reactreact-router-dom
: For handling client-side routing in React applications
To deploy the application, you'll need to build the frontend and serve the backend and frontend separately. Here are the steps:
- Build the frontend:
cd frontend && npm run build
🏗️ - Deploy the backend server to your hosting platform
- Deploy the
dist
folder (generated by the frontend build process) to a separate hosting platform or a static file server - Also, remember to add the necessary environment variables for your application. 🔑
Note that the specific deployment process may vary depending on your hosting platform and infrastructure setup.
This project is licensed under the MIT License 📜