Prerequisites
Before you begin, ensure you have the following installed:Python 3.10.11
The exact Python version required for this project
MySQL 8.0+
Relational database for storing application data
pip
Python package manager (included with Python)
Git
Version control system for cloning the repository
Verify Python Installation
Check that you have the correct Python version installed:Installing Python 3.10.11
If you don’t have Python 3.10.11 installed:- Windows
- macOS
- Linux
- Download Python 3.10.11 from python.org
- Run the installer
- Check “Add Python to PATH”
- Click “Install Now”
- Verify installation:
python --version
MySQL Installation
The Furniture Store Backend uses MySQL as its database system.- Windows
- macOS
- Linux
- Download MySQL Community Server from mysql.com
- Run the installer and choose “Developer Default”
- Set a root password during installation
- Complete the installation wizard
- Verify: Open MySQL Workbench or run
mysql --version
Make note of your MySQL root password - you’ll need it for database configuration.
Installation Steps
1. Clone the Repository
Clone the project from your version control system:2. Create Virtual Environment
A virtual environment isolates project dependencies from your system Python installation.venv directory containing an isolated Python environment.
3. Activate Virtual Environment
When successfully activated, your terminal prompt will show
(venv) at the beginning.4. Install Dependencies
With the virtual environment activated, install all required packages:requirements.txt
View all dependencies
View all dependencies
The complete list includes:
- Flask (3.1.2) - Web framework
- Flask-SQLAlchemy (3.1.1) - ORM integration
- Flask-Migrate (4.1.0) - Database migrations
- Flask-WTF (1.2.2) - Form handling and CSRF protection
- PyMySQL (1.1.2) - MySQL database driver
- SQLAlchemy (2.0.46) - SQL toolkit and ORM
- WTForms (3.2.1) - Form validation
- python-dotenv (1.2.1) - Environment variable management
- alembic (1.18.4) - Database migration tool
- black (26.1.0) - Code formatter
- mypy (1.19.1) - Static type checker
5. Environment Configuration
Create your environment configuration file:.env file with your specific configuration:
.env
Understanding the Configuration
The application uses these environment variables inconfig.py:
config.py
6. Database Initialization
Create the Database
Connect to MySQL and create the application database:Run Migrations
Initialize the database schema using Flask-Migrate:What tables are created?
What tables are created?
The migrations create the following tables:
- colors - Color catalog (Natural, White, Black, etc.)
- wood_types - Wood type catalog (Pine, Cedar, Oak, etc.)
- furniture_types - Furniture catalog (Tables, Chairs, Closets, etc.)
- roles - User roles and permissions
- unit_of_measures - Units of measurement (kg, m, pieces, etc.)
- Primary key (
id_*) - Timestamps (
created_at,updated_at,deleted_at) - Audit fields (
created_by,updated_by,deleted_by) - Soft delete support (
activeboolean)
7. Verify Installation
Start the development server:The application automatically tests the database connection on startup (see
run.py:6-13).Test the Application
Open your browser and navigate to:Run a Test Request
Create a test color using curl:Project Structure
After installation, your project structure will look like this:Next Steps
Quickstart Guide
Make your first API request in 5 minutes
Architecture Overview
Understand the MVC layered architecture
API Reference
Explore available endpoints and their usage
Development Guide
Learn coding conventions and best practices
Troubleshooting
Python version mismatch
Python version mismatch
If you have multiple Python versions installed, specify the version explicitly:Or use pyenv to manage Python versions:
MySQL connection errors
MySQL connection errors
Common issues:
- Authentication failed: Verify username and password in
.env - Cannot connect: Ensure MySQL service is running
- Database doesn’t exist: Create the database first (see step 6)
pip install fails
pip install fails
If you encounter errors during
pip install:-
Upgrade pip:
-
Install build dependencies (Linux):
-
Install packages individually to identify the problem:
Migration errors
Migration errors
If
flask db upgrade fails:-
Check database connection:
- Verify the database exists and is accessible
-
Check migration history:
-
If needed, recreate the database:
Port 5000 already in use
Port 5000 already in use
If port 5000 is occupied, specify a different port:Or set it in
.env:Import errors
Import errors
Ensure you’re in the correct directory and virtual environment is activated:
Additional Resources
Flask Documentation
Official Flask documentation
SQLAlchemy
Learn about the ORM
MySQL Docs
MySQL reference manual