Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
description: "Boundaries between crates and layers, and how handlers and APIs are shaped." paths: - "crates//*.rs" - "services//.rs" - "tooling/**/.rs" globs: "crates//*.rs,services//.rs,tooling/**/.rs" alwaysApply: false
Rust architecture and API design
Boundaries between crates and layers in the Rust backend.
- CS-23 Do not grow
macro_db_client— new domain logic gets a new crate; the catch-all crates must shrink, not accumulate. - CS-25
mod.rsdeclares submodules; it doesn't host logic — prefer thefoo.rs+foo/file-and-directory style for modules with logic. Enforced by ast-greprust-mod-rs-declarations-only, error. - CS-27 Shared domain tables are only touched by their owning crate — e.g.
entity_accessmutations go throughentity_access/entity_access_db_utils, never raw SQL elsewhere. - CS-30 Axum handlers take shared services via
State, notExtension. Enforced by ast-greprust-no-axum-extension-param, warning. - CS-31 Attach cross-cutting services to the owning domain service, not ad
hoc at the router/handler layer — e.g.
EntityAccessManagementServicehangs off the email/document service itself, the way the documents crate does. - CS-51 Domain modules reference no infrastructure or transport: no AWS
SDKs, redis, reqwest, opensearch, kafka, axum, or http types under
src/domain/**— wrap clients in outbound adapters behind ports; response mapping lives in inbound. Enforced by ast-greprust-no-infra-in-domainwarning,rust-no-transport-in-domainerror. - CS-52 Dependencies point inward:
src/domain/**never importscrate::inbound/crate::outbound, andsrc/outbound/**never importscrate::inbound— define a port in domain and implement it in the adapter. Enforced by ast-greprust-domain-no-adapter-importswarning,rust-outbound-no-inbound-importserror. - CS-53 Inbound adapters run no database queries — handlers, tools, and
listeners call a domain service backed by an outbound repository, never sqlx
directly. Enforced by ast-grep
rust-no-sqlx-in-inbound, warning.