This is a Flask-based web application designed to track user habits and logs, providing an XP system based on activity frequency.
- Project Overview
- Tech Stack
- Installation
- Running the Application
- Database Setup
- API Endpoints
- License
The Adonis Project is a habit-tracking app built with Flask and MySQL, featuring user authentication, habit logging, and an XP-based system to reward consistency. This project includes a dashboard where users can monitor their progress, view logs, and manage habits.
- Backend: Flask (Python)
- Database: MySQL
- Frontend: HTML, CSS (with possible JS)
- Deployment: Gunicorn (for production) and Flask's development server
Ensure you have the following installed:
- Python 3.x
- MySQL
pipfor installing Python packages
-
Clone the repository:
git clone https://github.com/ScottShadow/Adonis-Project.git cd Adonis-Project -
Set up virtual environment (optional, but recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the dependencies from
requirements.txt:pip install -r requirements.txt
-
Update your package index:
sudo apt update
-
Install MySQL:
sudo apt install mysql-server
-
Secure your MySQL installation:
sudo mysql_secure_installation
Follow the on-screen instructions to set a root password and remove any insecure default settings.
-
Install MySQL via Homebrew:
brew install mysql
-
Start the MySQL service:
brew services start mysql
-
Set up the root user (you'll be prompted to create a root password):
mysql_secure_installation
- Download the MySQL Installer for Windows.
- Run the installer and choose MySQL Server during setup.
- Follow the prompts to set up a root password.
- Make sure MySQL is added to your system PATH during installation.
Once MySQL is installed, follow these steps to create the database and user that your app will use:
-
Log in to the MySQL server:
sudo mysql -u root -p
You'll be prompted to enter the root password you set during installation.
-
Create a new MySQL database:
CREATE DATABASE adonis_project;
-
Create a new MySQL user (in this case,
rootis already used, but you can add a different user if necessary):CREATE USER 'root'@'localhost' IDENTIFIED BY '56213';
You can replace
'root'with a new username, and'56213'with your preferred password if you don't want to use the root user directly.-
Grant all privileges on the database to the user:
GRANT ALL PRIVILEGES ON adonis_project.* TO 'root'@'localhost';
-
Flush privileges to apply changes:
FLUSH PRIVILEGES;
-
Exit the MySQL shell:
exit;
Your app uses the following environment variable for the database:
inside the `/api/v2/app.py` file DATABASE_URL = os.getenv("DATABASE_URL", "mysql://root:56213@localhost/adonis_project")
If you're using
SQLAlchemy, Flask will automatically pick this up and connect to the MySQL database using the provided credentials.-
Run your Flask app with the configured MySQL database:
python -m api.v2.app
-
Check if the app connects successfully to the MySQL database and runs without issues.
-
Connection Issues: If MySQL is refusing connections, check if the MySQL service is running:
sudo service mysql status
On macOS, use:
brew services start mysql
-
Ports: Make sure MySQL is running on the correct port (default is
3306). You can check the port in yourmy.cnffile.
-
-
Configure the environment variables:
Create a
.envfile or update your environment with your Flask configuration and MySQL connection details:FLASK_APP=api.v2.app FLASK_ENV=development SQLALCHEMY_DATABASE_URI=mysql+pymysql://username:password@localhost/dbname SECRET_KEY=your_secret_key
-
Run the app:
You can start the app using:
python -m api.v2.app
The application should now be running at
http://127.0.0.1:5000/. -
Run in Production:
gunicorn -w 4 api.v2.app:app or waitress-serve --port=5000 api.v2.app:app
- POST
/login- Log in a user - POST
/signup- Sign up a new user - POST
/logout- Log out the current user
- GET
/logs- Retrieve all logs for the current user - POST
/logs- Create a new log entry - PUT
/logs/<log_id>- Update a log entry - DELETE
/logs/<log_id>- Delete a log entry
- GET
/profile- View user profile data - PUT
/profile- Update profile information
This project is licensed under the MIT License - see the LICENSE file for details.