Flasknotes is a simple web-based note taking application built with Flask and MySQL. It features role based authentication, CRUD operations, and favorite notes. It is fully mobile responsive and can be used on any device with an active internet connection
- Role based authentication with Flask-Login which can be edited on
rbac.py
- MySQL database connection with mysqlclient
- ORM support with Flask-SQLAlchemy
- .env file support with python-dotenv
- Powerful template engine Jinja2
- Database migration support with Flask-Migrate
- Password hashing and checking with bcrypt
- Flask-WTF forms with CSRF protection
- Python 3.6 or above
- MySQL 5.7 or above
- IDE of your choice
-
Clone this repository using git clone
git clone https://github.com/ghandylan/flask-notes
-
Unzip the folder and open it in your favorite IDE like PyCharm, VSCode, etc.
-
Open the terminal and create a virtual environment using
python -m venv flask_notes
-
Activate the virtual environment using
<env_name>\Scripts\activate
on Windows orsource flask_notes/bin/activate
on Linux/MacOS. -
Run
pip install -r requirements.txt
to install all the dependencies. -
Create a .env file and add the following variables:
SECRET_KEY
- A secret key for your application.SQLALCHEMY_DATABASE_URI
- The URI for your MySQL database.- Example:
mysql://<username>:<password>@localhost:3306/<db_name>
- Example:
SQLALCHEMY_TRACK_MODIFICATIONS
- Set it toFalse
.
-
Make sure your MySQL server is running and create a database with the name you specified in the .env file.
-
Run the following commands to perform database migrations with Flask-Migrate:
flask db init
flask db migrate
flask db upgrade
Should you encounter any errors with database migrations, run
flask db stamp head
and then run the above excluding theflask db init
command. -
Run
python app.py
to start the server.
app.py
- The main file which contains the Flask application.config.py
- Contains the configuration for the Flask application. Make sure to use environment variables for sensitive information.models.py
- Contains the database models. Feel free to edit it as per your requirements.- By default, it contains a User model which can be used for authentication.
- User's primary key is a
UUIDv4
string to enforce data integrity.
rbac.py
- Contains the role based access control logic.forms.py
- Contains the forms for the application. Feel free to edit it as per your requirements.
templates
contains the HTML templates for the application. Inside that folder, thebase.html
file contains the base template which is extended by all other templates. Bootstrap 4 is used for styling the templates.static
contains the static files like CSS, JS, images, etc.migrations
contains the database migration files generated by Flask-Migrate.venv
contains the virtual environment for the project.blueprints
contains the blueprints for the application. Use it to organize your application to user/admin views.