Welcome to the My Next Gym API! This Flask-based backend API provides functionality for managing gym-related information and user interactions. This README will guide you through setting up and using the API.
- Getting Started
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- API Endpoints
- Database Models
- Frontend Project
- DEMO
These instructions will help you set up and run the backend application on your local machine.
My Next Gym API offers the following features:
- User registration and authentication
- Gym place creation, retrieval, updating, and deletion
- Workout history tracking
- User-specific gym place and workout history management
Before you begin, ensure you have the following installed on your machine:
- Python (version 3.7 or higher)
- pip (Python package manager)
- Clone this repository to your local machine:
git clone <repository-url>- Change to the project directory:
cd <project-directory>- Activate the virtual environment:
-
On Windows:
venv\Scripts\activate
-
On macOS and Linux:
source venv/bin/activate
- Install the required packages:
pip install -r requirements.txtBefore running the application, make sure to set up your environment variables. Create a .env file in the project directory and add the following variables:
SECRET_KEY: A secret key for Flask's session management.SQLALCHEMY_DATABASE_URI: The URI for your PostgreSQL database.SQLALCHEMY_TEST_DATABASE_URI: The URI for your test database (if applicable).
By default, the application will run on http://localhost:5000.
To get started with the API, follow the installation instructions above. Once the API is up and running, you can use tools like Postman or curl to interact with the routes and enjoy the features provided by this project.
Here are the available API endpoints:
-
Register a New User
-
POST
/user -
Register a new user account.
-
Log in with a Registered User
-
POST
/user/<username> -
Log in with a registered user account.
-
Get All Users
-
GET
/user -
Retrieve information for all users.
-
Delete a User
-
DELETE
/user/<user_id> -
Delete a user account.
-
Create a New Gym Place
-
POST
/places -
Create a new gym place associated with a user.
-
Get All Gym Places of a User
-
GET
/user/<user_id>/places -
Get all gym places associated with a user.
-
Delete Gym Place
-
DELETE
/places -
Delete a gym place by its place ID.
-
Create a New Workout History Entry
-
POST
/histories -
Create a new workout history entry associated with a user.
-
Delete Workout History Entry
-
DELETE
/histories -
Delete a workout history entry by its history ID.
The application uses SQLAlchemy to interact with the database. Here are the relevant database models:
- User: Represents a user with username, password, first name, and last name fields.
- Place: Represents a gym place with location details and user association.
- History: Represents a workout history entry with date, time spent, mood, and comments fields.
You can find the frontend project for My Next Gym on GitHub. The frontend repository contains the user interface and client-side code for interacting with this API.