Skip to main content

What are Catalogs?

Catalogs are reference tables that store fundamental business data used throughout the Muebles Roble system. They provide standardized options for colors, wood types, user roles, and measurement units.

Active Catalogs

These catalogs are currently registered and accessible in the application:

Colors

Manage color options for furniture finishes

Wood Types

Define types of wood used in production

Roles

Manage user roles and permissions

Units of Measure

Define measurement units for materials and products

Unregistered Catalog

Furniture Types

Code exists but blueprint not registered - requires manual activation

Common Features

All catalog modules share a consistent architecture and functionality:

CRUD Operations

Every catalog supports:
  • Create: Add new entries with validation
  • Read: List all active entries and view details
  • Update: Modify existing entries
  • Delete: Soft delete (logical deletion) that preserves data

Soft Delete Pattern

Catalogs use logical deletion rather than physical deletion:
def delete(id: int) -> None:
    entity = Service.get_by_id(id)
    entity.active = False
    entity.deleted_at = func.current_timestamp()
    db.session.commit()
This approach:
  • Preserves historical data
  • Maintains referential integrity
  • Supports data recovery
  • Enables audit trails

Data Validation

All catalogs enforce business rules:
1

Required Fields

Forms validate that required fields are not empty
2

Length Constraints

Field length is validated (e.g., names limited to 50 characters)
3

Uniqueness

Names must be unique within each catalog
4

Conflict Detection

Duplicate entries are prevented with clear error messages

Exception Handling

The system uses custom exceptions for clear error handling:
ExceptionUsage
ValidationErrorEmpty or invalid input data
ConflictErrorDuplicate names or constraint violations
NotFoundErrorEntity not found by ID

Architecture Pattern

All catalogs follow a consistent three-layer architecture:
┌─────────────────────────────────────┐
│  routes.py (Presentation Layer)     │
│  Handles HTTP requests & responses  │
├─────────────────────────────────────┤
│  services.py (Business Logic)       │
│  Validation & business rules        │
├─────────────────────────────────────┤
│  models/ (Data Layer)               │
│  SQLAlchemy ORM entities            │
└─────────────────────────────────────┘

File Organization

Each catalog module contains:
app/catalogs/{catalog_name}/
├── __init__.py      # Blueprint registration
├── routes.py        # Route handlers (GET/POST)
├── services.py      # Business logic layer
└── forms.py         # WTForms definitions

Common Model Structure

All catalog models inherit standard fields:
class CatalogEntity(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False, unique=True)
    active = db.Column(db.Boolean, nullable=False, default=True)
    
    # Audit fields
    created_at = db.Column(db.TIMESTAMP, server_default=func.current_timestamp())
    updated_at = db.Column(db.TIMESTAMP, server_onupdate=func.current_timestamp())
    deleted_at = db.Column(db.TIMESTAMP, nullable=True)
    
    created_by = db.Column(db.String(100), nullable=True)
    updated_by = db.Column(db.String(100), nullable=True)
    deleted_by = db.Column(db.String(100), nullable=True)
Audit fields (created_by, updated_by, deleted_by) are currently optional and ready for future authentication integration.

Next Steps

Explore individual catalog modules:

Build docs developers (and LLMs) love