| title | Sunbeam CRM | |||
|---|---|---|---|---|
| description | Internal CRM generated from the Microsoft Common Data Model — Rust workspace, GraphQL API, Postgres. | |||
| category | overview | |||
| nav_order | 0 | |||
| status | published | |||
| related |
|
An internal CRM whose entire data layer — entities, repositories, SQL
migrations, GraphQL API, dataloaders, and typed client — is generated from
the Microsoft Common Data Model (the cdm/
submodule) by the crm-codegen crate.
flowchart LR
CDM["Microsoft CDM<br/>+ entity_map.md"] --> GEN["crm-codegen"]
GEN --> PG[("Postgres<br/>283 tables")]
GEN --> API["GraphQL API<br/>283 entities x 5 ops<br/>+ relations + unions"]
GEN --> CLI["typed Rust clients"]
API --> PG
Rule zero: all output is codegen. The only hand-written code is the generator itself (
crates/crm-codegen), thin server wiring, and the integration test suite.
| Crate | Contents |
|---|---|
crm-codegen |
The generator: ingest → analyze → validate → transform → emit |
crm-core |
core domain entities (57) + shared runtime |
crm-product |
product domain (9) |
crm-sales |
sales domain (33) |
crm-service |
service domain (19) |
crm-sustainability |
sustainability domain (85) |
crm-nonprofit |
nonprofit domain (80) |
crm-server |
Merged GraphQL schema, g2v auth, axum HTTP server, integration tests |
crm-client-<domain> |
Per-domain typed GraphQL clients (scalar ops), validated against the SDL; crm-client-scalars shared scalars; crm-client-<domain>-deep deep ops (opt-in builds) |
Only the 298 approved entities in docs/entity_map.md are emitted (283
resolve to CDM files). Emitting the full 4,000+ entity CDM surface is
available via cargo run -p crm-codegen -- --all but is not the default —
it produces a single crate that needs ~42 GB of RAM to compile.
# Regenerate everything (entities, dataloaders, GraphQL roots, server glue)
cargo run -p crm-codegen
# Apply the schema to Postgres (sqlx-migrate series, applied in order)
DATABASE_URL=postgres://localhost/crm cargo run -p crm-server -- --migrate
# Serve GraphQL at http://127.0.0.1:8000/graphql (GraphiQL on GET)
# Auth is fail-closed: set CRM_AUTH_DISABLED=1 for local play, or configure
# CRM_SSO_INTROSPECTION_URL + CRM_SSO_CLIENT_ID/CRM_SSO_CLIENT_SECRET
DATABASE_URL=postgres://localhost/crm cargo run -p crm-server
# Regenerate the typed client after schema changes
cargo run -p crm-server -- --print-sdl > crates/crm-client-core/graphql/schema.graphql
cargo run -p crm-codegen -- --emit-client- Architecture — how the pieces fit together
- Codegen pipeline — the five phases and every emitter
- GraphQL API — query/mutation shape, relations, unions, dataloaders
- Database & migrations — cycle analysis, deferred FKs
- Client — using the typed client
- Testing — integration harness, fixtures, crossing queries
- Postgres operations — pooling, tuning, monitoring
- Ledger design — the general-ledger RFC + PT compliance mapping
- Workflows design — business processes via embedded wfe (draft RFC)
Tags (v*) build a multi-arch ghcr.io/sunbeamdotpt/crm image via
.github/workflows/release.yml. Nothing is published to crates.io.