Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9ea39de
build(deps): add deps for data scheme
PhilippTheServer Mar 4, 2026
31a4423
feat(data-models): add customer pydantic and data scheme
PhilippTheServer Mar 4, 2026
ff6874d
feat(data-models): add inventory pydantic and data scheme
PhilippTheServer Mar 4, 2026
eeff063
feat(data-models): add orders pydantic and data scheme
PhilippTheServer Mar 4, 2026
319e8ed
feat(data-models): add payments pydantic and data scheme
PhilippTheServer Mar 4, 2026
90bdbaf
feat(data-models): add shipments pydantic and data scheme
PhilippTheServer Mar 4, 2026
3c4d6cd
feat(data-models): add webhooks pydantic and data scheme
PhilippTheServer Mar 4, 2026
e404e11
feat(data-models): parse db setup create_all to initiator
PhilippTheServer Mar 4, 2026
01308e0
refactor(crud_item_store): rename files to avoid confusion
PhilippTheServer Mar 4, 2026
b19572b
fix(data-models): run linter
PhilippTheServer Mar 4, 2026
e7194b6
refactor(data-models): rename files to avoid confusion
PhilippTheServer Mar 4, 2026
b9dfedb
refactor(data-models): fix create db call
PhilippTheServer Mar 4, 2026
667f35f
refactor(data-models): remove any redundant db functions - implement …
PhilippTheServer Mar 5, 2026
86889c0
fix(crud_item_store): fix validation_error responses
PhilippTheServer Mar 5, 2026
9c0df89
refactor(crud_item_store): implement dynamic responses
PhilippTheServer Mar 5, 2026
ffe198c
test(crud_item_store): fix syntax error
PhilippTheServer Mar 5, 2026
09b528e
fix(data-models): run linter
PhilippTheServer Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"asyncpg>=0.31.0",
"authlib>=1.6.5",
"cryptography>=46.0.3",
"email-validator>=2.2.0",
"fastapi>=0.124.0",
"pydantic-settings>=2.12.0",
"pydantic>=2.12.5",
Expand Down
1 change: 1 addition & 0 deletions src/app/chore/lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from fastapi import FastAPI

import app.db_models # noqa: F401 — registers all ORM models with Base.metadata
from app.shared.database.base import Base
from app.shared.database.engine import close_database, get_engine, init_database

Expand Down
37 changes: 37 additions & 0 deletions src/app/db_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
Database Model Registry

Imports ALL SQLAlchemy ORM models so that Base.metadata knows about every
table. This module must be imported before calling Base.metadata.create_all().

Why this file exists:
SQLAlchemy's Base.metadata only knows about a table after its ORM class
has been imported. If a model is never imported, its table is never created.
Centralising all imports here means you only need to import this one module
to guarantee that create_all() sees the full schema.

Usage:
import app.db_models # noqa: F401 — side-effect import
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
"""

# Item store (partner service)
from app.services.crud_item_store.models.item_db_models import ItemDB # noqa: F401

# Customers
from app.services.customers.models.customers_db_models import AddressDB, CustomerDB # noqa: F401

# Inventory

# Orders
from app.services.orders.models.orders_db_models import OrderDB, OrderItemDB # noqa: F401

# Payments
from app.services.payments.models.payments_db_models import PaymentDB # noqa: F401

# Webhooks
from app.services.webhooks.models.webhooks_db_models import WebhookEventDB # noqa: F401

# Shipments
from app.services.shipments.models.shipments_db_models import ShipmentDB # noqa: F401
4 changes: 2 additions & 2 deletions src/app/services/crud_item_store/crud_item_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from fastapi import APIRouter

# Import routers
from .routers import items
from .routers import items_router

# Create the main router for this service
router = APIRouter(
Expand All @@ -28,6 +28,6 @@
)

# Include sub-routers
router.include_router(items.router)
router.include_router(items_router.router)

__all__ = ["router"]
4 changes: 2 additions & 2 deletions src/app/services/crud_item_store/functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Business logic and transformation functions for items.
"""

from .transformations import db_to_response, prepare_item_update_data
from .validation import check_duplicate_field, validate_update_conflicts
from .item_transformations import db_to_response, prepare_item_update_data
from .item_validation import check_duplicate_field, validate_update_conflicts

__all__ = [
"db_to_response",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
from uuid import UUID

from app.shared.exceptions import duplicate_entry
from app.shared.logger import get_logger
from ..models import ItemDB
from ..services import ItemRepository

logger = get_logger(__name__)


async def check_duplicate_field(
repo: ItemRepository,
Expand Down Expand Up @@ -44,6 +47,13 @@ async def check_duplicate_field(
>>> # Can check any field on the model
>>> await check_duplicate_field(repo, "name", "Test Product")
"""
logger.debug(
"Checking for duplicate field value",
extra={
"field_name": field_name,
"exclude_uuid": str(exclude_uuid) if exclude_uuid else None,
},
)
# Use the repository's generic field_exists method
# This will raise ValueError if field doesn't exist on the model
exists = await repo.field_exists(field_name, field_value, exclude_uuid=exclude_uuid)
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/crud_item_store/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Response models are in the responses/ directory.
"""

from .database import ItemDB
from .item import (
from .item_db_models import ItemDB
from .item_models import (
DimensionUnit,
DimensionsModel,
IdentifiersModel,
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/crud_item_store/responses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Combines shared response structures with feature-specific models.
"""

from .items import ItemResponse
from .items_response_models import ItemResponse

__all__ = [
"ItemResponse",
Expand Down
Loading
Loading