Skip to content

Rendered notebook

Generated from 02_customers_crud.ipynb. Run it yourself with make docs-up — see Run locally.

02 — Customers: domain model walk-through

We read the generated CustomerEntity and exercise its invariants — without booting the database. This shows the pure-domain layer that comes from apogee make:entity.

02_customers_crud.ipynb · cell 1
import sys
sys.path.insert(0, '/srv/apogee/app-tests-docs/globaltrust-bank')

from src.domain.business.banking.customers.entities.customer_entity import CustomerEntity
from src.domain.business.banking.customers.enums.customer_kyc_status_enum import KycStatusEnum

list(KycStatusEnum)
02_customers_crud.ipynb · cell 2
alice = CustomerEntity(
    full_name='Alice Müller',
    email='alice@example.com',
    document_number='DE-1234567',
    country_code='DE',
    preferred_language='en',
)
alice
02_customers_crud.ipynb · cell 3
# Globaltrust customers come from many countries — locale-aware preferences
samples = [
    CustomerEntity(full_name='李明', email='liming@example.cn', document_number='CN-987654', country_code='CN', preferred_language='zh'),
    CustomerEntity(full_name='Carlos da Silva', email='carlos@example.br', document_number='BR-54321', country_code='BR', preferred_language='pt'),
    CustomerEntity(full_name='María García', email='maria@example.es', document_number='ES-11223', country_code='ES', preferred_language='es'),
]
for c in samples:
    print(f"{c.country_code} | {c.full_name:<20} | speaks {c.preferred_language}")

What was generated for free

Because apogee make:entity Customer ... was run, the project also contains:

  • customer_repository.py — port (interface)
  • customer_repository_postgres.py — Postgres implementation (wired in container.py)
  • customer_use_case.py — CRUD use cases (create, read, update, delete, list_paginated)
  • customer_dto.py — Pydantic input/output DTOs
  • customer_controller.py — FastAPI controller
  • customer_router.py — registers /customers/* endpoints
  • A migration in migrations/banking/
  • Unit + integration test stubs

All of that without a single hand-written line of glue code.