Skip to main content

Shared Pydantic data models for mlclogistica.app

Project description

fluffy-waddle

Shared Pydantic data model for the mlclogistica.app project. All Python workers (CRM sync, and future WMS, TMS, ERP integrations) import from this package.

This package stays intentionally domain-first: it models nested business objects, not database rows. Names track the database entities, but the public API is a graph of related classes with inheritance and aggregate roots.

Sales class diagram

classDiagram
    class CRMModel {
        +string id
        +datetime created_at
        +datetime updated_at
    }
    class CRMNamedModel {
        +string title
    }
    class CRMUser {
        +string full_name
        +string email [0..1]
        +string phone [0..1]
        +CRMTeam team [0..1]
    }
    class CRMCampaign {
        +string description [0..1]
    }
    class CRMLossReason {
        +string reason
    }
    class CRMPipeline {
        +int display_order
    }
    class CRMProduct {
        +Decimal price
        +string description [0..1]
    }
    class CRMIndustry
    class CRMSource {
        +string description [0..1]
    }
    class CRMTeam
    class CRMPipelineStage {
        +string description [0..1]
        +string objective [0..1]
        +int display_order
    }
    class CRMOrganization {
        +string description [0..1]
        +string website [0..1]
        +dict address [0..1]
    }
    class CRMContact {
        +string full_name
        +string job_title [0..1]
        +list emails
        +list phones
        +list social_profiles
    }
    class CRMDeal {
        +Decimal amount [0..1]
        +date expected_close_date [0..1]
        +int rating [0..1]
        +string status
        +datetime closed_at [0..1]
    }
    class CRMTask {
        +string description [0..1]
        +string task_type
        +string status
        +datetime due_date [0..1]
        +datetime completed_at [0..1]
    }

    %% Inheritance
    CRMNamedModel --|> CRMModel
    CRMUser --|> CRMModel
    CRMContact --|> CRMModel
    CRMLossReason --|> CRMModel
    CRMCampaign --|> CRMNamedModel
    CRMPipeline --|> CRMNamedModel
    CRMProduct --|> CRMNamedModel
    CRMIndustry --|> CRMNamedModel
    CRMSource --|> CRMNamedModel
    CRMTeam --|> CRMNamedModel
    CRMPipelineStage --|> CRMNamedModel
    CRMOrganization --|> CRMNamedModel
    CRMDeal --|> CRMNamedModel
    CRMTask --|> CRMNamedModel

    %% Associations
    CRMPipelineStage "0..*" --> "1" CRMPipeline : pipeline
    CRMOrganization "0..*" --> "0..1" CRMUser : owner
    CRMOrganization "0..*" o-- "0..*" CRMIndustry : industries
    CRMOrganization "0..*" o-- "0..*" CRMUser : followers
    CRMOrganization "1" *-- "0..*" CRMContact : contacts
    CRMDeal "0..*" --> "1" CRMPipelineStage : stage
    CRMDeal "0..*" --> "0..1" CRMUser : owner
    CRMDeal "0..*" --> "0..1" CRMSource : source
    CRMDeal "0..*" --> "0..1" CRMCampaign : campaign
    CRMDeal "0..*" --> "0..1" CRMLossReason : loss_reason
    CRMDeal "0..*" --> "0..1" CRMOrganization : organization
    CRMDeal "0..*" o-- "0..*" CRMContact : contacts
    CRMDeal "0..*" o-- "0..*" CRMProduct : products
    CRMDeal "1" *-- "0..*" CRMTask : tasks
    CRMTask "0..*" --> "1" CRMUser : created_by
    CRMTask "0..*" --> "0..1" CRMUser : completed_by
    CRMTask "0..*" o-- "0..*" CRMUser : assignees
    CRMUser "0..*" --> "0..1" CRMTeam : team

CRMDeal is the main aggregate root for the sales graph. Child objects nested under a deal (tasks) intentionally do not carry backreference IDs to the parent deal; workers should navigate outward from the deal graph instead.

Testing

Tests validate the full insert/assemble roundtrip against a live Postgres database seeded with inline fixtures.

Spin up the database and run migrations (uses curly-spoon to apply the full schema):

docker compose up -d

Then run pytest from inside the app container:

pytest tests/

The app service mounts the repo at /root/app and loads .env (Postgres connection vars) automatically.

Test structure

tests/
  inserters.py         # writes domain models to the DB
  db_selectors.py      # reads raw rows back from the DB
  deals_assembler.py   # reassembles domain models from raw rows
  deals_repository.py  # aggregate read/write repository for the deals graph
  deleter.py           # truncates all sales tables between test runs
  test_roundtrip.py    # roundtrip: insert fixtures → fetch → assert equality

CRMDeal is the aggregate root tested here. The roundtrip covers the full sales graph: pipelines, stages, organizations, contacts, products, tasks, teams, users, and all bridge tables.

Scripts

Helper scripts for setting up a development environment on a new machine:

  • scripts/config-helix.sh — configures the Helix editor for this project's stack
  • scripts/install-requirements.sh — installs Python dependencies and the package in editable mode
  • scripts/integrate.sh — sets up a venv, installs all dependencies, and runs the full test suite

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluffy_waddle-1.0.0rc2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluffy_waddle-1.0.0rc2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file fluffy_waddle-1.0.0rc2.tar.gz.

File metadata

  • Download URL: fluffy_waddle-1.0.0rc2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fluffy_waddle-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 e4c5b128630b2b346b7bcfd3bab74d3475ad64be2867b38a472c226560cda3e4
MD5 9096684c76f32c54b81654db3761abf8
BLAKE2b-256 209a42ffcc084aa0a3fd34c74dd5c0af82681ecb87cf4d20f730fa1e9ebce016

See more details on using hashes here.

Provenance

The following attestation bundles were made for fluffy_waddle-1.0.0rc2.tar.gz:

Publisher: deployment.yaml on hcubasd/fluffy-waddle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fluffy_waddle-1.0.0rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for fluffy_waddle-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 e8ae9040bb13ee4dd61c81ae99fcf928bea30f83be493af24f9e662e6ff3d6aa
MD5 c9702136462e6b55b000c38dad6f1832
BLAKE2b-256 d38302b51984f85c42f79a5e430313b1ab00743155a6dbf916b66927a1455114

See more details on using hashes here.

Provenance

The following attestation bundles were made for fluffy_waddle-1.0.0rc2-py3-none-any.whl:

Publisher: deployment.yaml on hcubasd/fluffy-waddle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page