Skip to main content

Prerequisites

Before starting development, ensure you have the following installed:

Python 3.10.11

Required Python version for this project

MySQL Database

Relational database for data persistence

pip

Python package manager

Git

Version control system

Verify Python Installation

Check your Python version:
python --version
You should see:
Python 3.10.11

Initial Setup

1. Clone the Repository

git clone <REPOSITORY_URL>
cd muebles-roble-diseno-app

2. Create Virtual Environment

Create an isolated Python environment:
python -m venv venv

3. Activate Virtual Environment

venv\Scripts\activate
When activated successfully, you’ll see (venv) at the beginning of your terminal prompt.

4. Install Dependencies

Install all required Python packages:
pip install -r requirements.txt
  • Flask 3.1.2 - Web framework
  • Flask-SQLAlchemy 3.1.1 - ORM for database operations
  • Flask-Migrate 4.1.0 - Database migrations
  • Flask-WTF 1.2.2 - Form handling and CSRF protection
  • WTForms 3.2.1 - Form validation
  • PyMySQL 1.1.2 - MySQL database driver
  • Black 26.1.0 - Code formatter
  • python-dotenv 1.2.1 - Environment variable management

Environment Configuration

Create Environment File

  1. Copy the template file:
cp .env-template .env
  1. Edit .env with your configuration:
.env
FLASK_APP=app.py
FLASK_ENV=development

DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_HOST=localhost
DB_PORT=3306
DB_NAME=your_database_name

SECRET_KEY=your-secret-key-here
Never commit the .env file to version control. It’s already included in .gitignore.

Database Setup

Create your MySQL database:
CREATE DATABASE your_database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Run Database Migrations

Apply the database schema:
flask db upgrade

Running the Application

Development Server

Start the Flask development server:
flask run
The application will be available at:
http://127.0.0.1:5000

Verify Installation

The run.py script includes a database connection test. You should see:
Database connection successful!
 * Running on http://127.0.0.1:5000
If you see “Database connection successful!” your setup is complete!

Development Tools

Code Formatting with Black

The project uses Black for consistent code formatting:
# Format all code
black .

# Check formatting without making changes
black --check .

Type Checking with mypy

Run type checking:
mypy app/

Troubleshooting

  • Verify MySQL is running
  • Check credentials in .env file
  • Ensure database exists
  • Check firewall settings for port 3306
  • Ensure virtual environment is activated
  • Reinstall dependencies: pip install -r requirements.txt
  • Check Python version matches 3.10.11
The application requires a SECRET_KEY environment variable in production. Generate a secure key:
import secrets
print(secrets.token_hex(32))

Next Steps

Project Structure

Learn about the application architecture

Coding Conventions

Follow the project’s coding standards

Templates Guide

Work with Jinja2 templates

Forms Guide

Create and validate forms

Build docs developers (and LLMs) love