Directory Tree
Core Directories
/app
The main application package containing all application code.
Key files:
__init__.py: Contains the application factory (create_app()) that initializes Flask, extensions, and blueprintsextensions.py: Initializes Flask extensions (SQLAlchemy, Flask-Migrate, CSRF Protection)exceptions.py: Defines custom exception classes and error handlers
app/__init__.py:8-48:
/app/catalogs
Contains domain-specific catalog modules. Each catalog follows the same structure:
colors/- Color catalog managementroles/- User role managementwood_types/- Wood type catalogunit_of_measures/- Unit of measure catalogfurniture_type/- Furniture type catalog
/app/models
Contains SQLAlchemy model definitions. Each model represents a database table.
Files:
__init__.py- Exports all models for easy importcolor.py- Color modelrole.py- Role modelwood_type.py- Wood type modelunit_of_measure.py- Unit of measure modelfurniture_type.py- Furniture type model
app/models/color.py:6-46
/app/templates
Contains Jinja2 HTML templates organized by module.
Structure:
base.html- Base template with navigation and flash message handling{module}/- Templates for each catalog modulecreate.html- Creation formedit.html- Edit formlist.html- List view
errors/error.html- Generic error page
base.html:
/migrations
Database migration files managed by Flask-Migrate (Alembic).
Structure:
env.py- Alembic environment configurationversions/- Individual migration files with timestamps
5aa5020316c5_create_colors_table.pye57af1e0a8f8_create_roles_table.py6067bf0c7322_add_table_wood_types.py
/docs
Project documentation in Markdown format.
Files:
ARCHITECTURE.md- System architecture and design decisionsCODING_CONVENTIONS.md- Code style and conventions guideGUIDE_MIGRATIONS.md- Database migration workflow and best practices
Configuration Files
config.py
Application configuration class that loads settings from environment variables:
config.py:8-23
.env-template
Template for environment variables. Copy to .env and fill in values:
requirements.txt
Python package dependencies:
run.py
Application entry point:
run.py:1-16
Module Organization Pattern
Each catalog module follows a consistent 4-layer architecture:1. Blueprint (__init__.py)
Defines and exports the Flask Blueprint:
2. Routes (routes.py)
HTTP endpoint handlers (controllers):
3. Services (services.py)
Business logic layer:
4. Forms (forms.py)
WTForms form definitions with validators:
Extensions
Flask extensions are initialized inapp/extensions.py:1-8:
Next Steps
- Learn about Coding Conventions
- Follow the guide for Adding New Modules
- Review Database Migrations