"""
Base Pydantic class for all Phase 1+ schemas.

Automatically translates between:
- snake_case (Python internal, PEP 8)  →  used in code
- camelCase (frontend API)              →  used in JSON over the wire

Behavior:
- Accepts BOTH snake_case and camelCase on input (populate_by_name=True)
- Always serializes to camelCase on output when model_dump_json(by_alias=True)
"""
from pydantic import BaseModel, ConfigDict
from pydantic.alias_generators import to_camel


class CamelCaseModel(BaseModel):
    """
    Base class for all schemas exposed to or received from the React Native frontend.

    Usage:
        class ProfileOut(CamelCaseModel):
            first_name: str
            phone: str

        # Input JSON {"firstName": "Hassan", "phone": "+212..."} works
        # Output JSON via .model_dump_json(by_alias=True) produces {"firstName": ..., "phone": ...}
    """
    model_config = ConfigDict(
        alias_generator=to_camel,
        populate_by_name=True,
    )
