This is a simple authentication system for a FinTech application, implemented using Node.js, Express.js, and MongoDB. The application supports user registration, login functionalities, and includes robust error handling mechanisms.
- Setup Instructions
- How to Run the Application
- How to Import and Use the Postman Collection
- Assumptions and Decisions
-
Clone the Repository
git clone https://github.com/Priyang1310/Fintech-Authentication-API.git
-
Install Dependencies Ensure you have Node.js and MongoDB installed. Then, run:
npm install
-
Create a
.envFile Create a.envfile in the root directory and add the following environment variables:PORT=5000 MONGODB_URI=mongodb://localhost:27017/fintech-auth JWT_SECRET=your_jwt_secret_keyReplace
your_jwt_secret_keywith a secure key of your choice.
-
Run the Application In the terminal, navigate to your project directory and run:
npm start
The server will start on the specified port (default is
5000). -
Access the API You can access the API at
http://localhost:5000/api.
-
Download the Postman Collection The Postman collection is included in this repository as
FintechAuth.postman_collection.json. -
Import the Collection into Postman
- Open Postman.
- Click on
Importin the top left corner. - Select the
Filetab and dragFinTechAuth.postman_collection.jsoninto the window or clickChoose Filesand select the file.
-
Set Up Environment Variables in Postman
- Go to the Environments tab.
- Create a new environment and add a variable named
TOKEN. - Use this variable to store your JWT token when logging in.
-
Testing the API
- Use the collection to test all available endpoints, including registration, login, and profile retrieval.
- Review the expected responses for successful and erroneous requests as documented in the collection.
- User Passwords: Passwords are hashed using
bcryptbefore storage to ensure security. - JWT Authentication: JSON Web Tokens are used for user authentication, ensuring secure and stateless sessions.
- Error Handling: Appropriate HTTP status codes and error messages are returned for different error scenarios to enhance user experience.
- Data Validation: Input validation checks are implemented for registration and login to ensure data integrity and prevent injection attacks.
- Testing: The API has been thoroughly tested using Postman, covering various scenarios, including valid and invalid inputs.