The Fitness Backend API is a simple authentication system built using Node.js, Express, and MongoDB. This backend handles user registration and login functionality, which will eventually serve as the foundation for managing workouts, exercises, and fitness tracking in the future.
Currently, it provides user authentication using JWT (JSON Web Tokens). Additional features such as workout management, progress tracking, and more are open for contributions.
- User Registration: Allows users to register with their details.
- User Login: Users can log in to receive a JWT token for authenticated access.
- JWT Authentication: Securely handles access to protected routes.
- Node.js: JavaScript runtime for server-side logic.
- Express.js: Minimal web framework for building the API.
- MongoDB: NoSQL database to store user data.
- Mongoose: MongoDB object data modeling (ODM) for Node.js.
- JWT: Used for secure token-based authentication.
Ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/zaid-commits/Fitness-Backend.git cd Fitness-Backend
-
Install dependencies:
npm install
-
Create a
.env
file with the following environment variables:PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret
-
Run the server:
npm start
The server will start at
http://localhost:5000
.
Here are the available API endpoints for authentication:
- POST
/api/auth/register
: Register a new user. - POST
/api/auth/login
: Log in a user.
Example of a response on successful login:
{
"token": "your_jwt_token"
}
Protected routes can be accessed using this token for future functionalities.
Currently, this project only handles user authentication. Here are some features that can be added:
- Workouts: CRUD operations for workout tracking.
- Exercises: Manage exercises related to the user's fitness goals.
- Progress Tracking: Visualize user progress over time.
- Goal Setting: Allow users to set and track fitness goals.
Feel free to contribute by implementing any of the above features!
Contributions are welcome! If you would like to enhance this project with additional features, please follow these steps:
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -m 'Add feature X'
). - Push to the branch (
git push origin feature/new-feature
). - Open a pull request for review.
This project is licensed under the MIT License. See the LICENSE file for more details.