A modular ERP kernel that starts with freelancer workflows (expenses, invoices, assistant) and scales into restaurant, hotel, and factory packs without forking code.
- Corely — AI-native modular ERP kernel
- A modular kernel built for freelancer workflows (expenses, invoices, assistant) that can layer in full ERP packs (restaurant, hotel, factory) without duplicating the core.
- AI-native by design: contracts define tool schemas, assistant endpoints run through the API with auditable tool executions, retries are idempotent, and every action is logged for traceability.
- Bounded contexts keep each module’s domain model, use cases, and migrations isolated so teams can own vertical packs safely.
- Hexagonal ports/adapters let use cases stay framework-free while adapters live in NestJS, Prisma, Redis, or UI layers.
- Outbox + Worker power reliable automations, and CQRS-lite read models keep dashboards responsive without polluting the write model.
- Idempotency keys, audit trails, and tenant scoping are defaults so even AI or POS retries stay safe.
- Modular monolith with shared contracts (
packages/contracts), pure domain rules (packages/domain), and a kernel of standard use cases. - Packs add UI, migrations, and integrations in their own folders so restaurant/hotel/factory features compose the kernel instead of fork it.
- Clear ownership boundaries remove direct cross-module DB writes; modules talk through contracts, events, and the API surface.
- Outbox pattern and a dedicated worker deliver domain events, retries, and process managers for automations.
- CQRS-lite read services keep dashboards fast while write use cases remain strict and transactional.
- Every write command/tool call carries an idempotency key plus an audit log entry by default.
- Tenant-aware schemata (all tables include
tenantIdchecks) and RBAC/ABAC guards in the API. - Audit log captures critical actions, including AI tool executions and POS commands, with immutable metadata.
- Tool runs surface confidence, provenance, and trace IDs so consumers can safely retry or investigate.
pnpmworkspace orchestrates apps (apps/web,apps/pos,apps/e2e), services (services/api,services/worker,services/mock-server), and shared packages.- Contracts package centralizes schemas, enums, and tool cards so frontend, API, and worker speak the same language.
- Mock server simulates latency, pagination, idempotency, and assistant-tool endpoints, enabling a UI-first workflow before the full stack is ready.
- Prompt definitions and versioning live in
docs/prompt-management.md.
- Core OSS kernel: everything in this repository is AGPL-3.0-only unless a file or folder states otherwise.
- Enterprise Packs / EE: distributed separately under a commercial license; they integrate via ports/interfaces and runtime registration (no direct OSS imports).
- Trademarks: “Corely” name and logos are protected by trademark and brand usage rules.
- Details: see
docs/licensing.md,ee/README.md, andTRADEMARKS.md.
DDD bounded contexts → Hexagonal ports/adapters → Outbox + Worker → CQRS-lite reads + idempotent commands + audit by default.
flowchart LR
subgraph Clients
Web["apps/web (Vite)"]
POS["apps/pos (POS shell)"]
end
subgraph Shared
Contracts["packages/contracts"]
Domain["packages/domain"]
Data["packages/data"]
end
subgraph Backend
API["services/api"]
Worker["services/worker"]
Mock["services/mock-server"]
end
Web --> Contracts
Web --> Domain
POS --> Contracts
POS --> Domain
API --> Contracts
API --> Domain
API --> Data
Worker --> Contracts
Worker --> Domain
Worker --> Data
Mock --> Contracts
apps/web&apps/pos→packages/contracts,packages/domainservices/api,services/worker→packages/contracts,packages/domain,packages/datapackages/domain→packages/contracts- Forbidden:
packages/contractsimporting other workspace code, frontend importing backend internals, backend importing UI assets, or any module writing another module’s tables directly. - Architecture patterns: DDD bounded contexts, Hexagonal ports/adapters, Outbox + Worker for automation, CQRS-lite reads for dashboards, idempotent commands and audit trails as defaults.
apps/
e2e/ # End-to-end suites
pos/ # Offline-first POS shell
web/ # Vite-based admin UI
services/
api/ # NestJS API (RBAC, tools, workflows)
worker/ # NestJS worker (outbox, jobs, integrations)
mock-server/ # Dedicated mock server for UI-first work
packages/
api-client/
auth-client/
config/
contracts/
core/
data/
domain/
email-templates/
kernel/
offline-core/
offline-rn/
offline-web/
pos-core/
testkit/
tooling/
docs/
assets/
docker/
scripts/
- Node.js 22.19+ (LTS recommended)
pnpm10+- Docker (optional: Postgres/Redis via
docker-compose.dev.yml,docker-compose.local.yml, or Alpine scripts)
- Install dependencies and copy env scaffolding:
pnpm install cp .env.example .env
- Set
VITE_API_BASE_URLtohttp://localhost:4000for the mock profile orhttp://localhost:3000for the full stack. - Start the stack you need:
pnpm dev:mock
pnpm dev:webMock server routes live under services/mock-server/src/routes; latency, pagination, and idempotency middleware keep the experience close to the real API.
pnpm dev:api
pnpm dev:worker
pnpm dev:webEnsure Postgres/Redis are reachable (use docker compose -f docker-compose.dev.yml up if needed). When you want everything wired together, pnpm dev builds packages then starts all services.
- Global defaults:
.env.example,.env.dev.example,.env.e2e.example; copy the one that matches your workflow into a.envfile at the repo root. - Services and apps pick values from that
.env(web usesVITE_prefixed keys, API/worker reference connection strings directly).
| Name | Used by | Example | Notes |
|---|---|---|---|
DATABASE_URL |
@corely/api, @corely/worker, @corely/data |
postgresql://corely:corely@postgres:5432/corely?schema=public |
Prisma connection for commands, outbox, and read models. |
REDIS_URL |
@corely/api, @corely/worker |
redis://redis:6379 |
Queues, locks, rate limits, idempotency caches. |
VITE_API_BASE_URL |
apps/web, apps/pos |
http://localhost:4000 |
Switch between mock (4000) and real API (3000). |
LOG_LEVEL |
All services | debug |
Controls structured logging verbosity. |
AI_MODEL_PROVIDER |
@corely/api |
openai |
Selects openai or anthropic for Copilot tool runs. |
OPENAI_API_KEY / ANTHROPIC_API_KEY |
@corely/api |
(redacted) |
Provider credentials for assistant/tool calls; keep secret. |
EMAIL_PROVIDER |
@corely/api |
resend |
Controls transactional email adapter. |
WEB_PORT, API_PORT, MOCK_PORT |
Apps/services | 5173, 3000, 4000 |
Override ports when composing services locally. |
Common scripts include:
pnpm dev– builds shared packages and runs all services/apps in parallel.pnpm dev:web,pnpm dev:mock,pnpm dev:api,pnpm dev:worker,pnpm dev:api:debug– start each surface individually.pnpm build,pnpm build:web,pnpm build:api– compile packages plus apps/services.pnpm typecheck,pnpm lint,pnpm format,pnpm format:check– workspace-wide quality gates.pnpm check–lint+typecheck.pnpm prisma:migrate,pnpm prisma:generate– keep Prisma schema in sync for@corely/data.
- Mock-first / UI-first:
apps/web(andapps/pos) callservices/mock-server. Mock middleware simulates latency/pagination, enforces idempotency, and exposes assistant tool endpoints, so UI work keeps moving before backend features land. - Full backend stack:
services/apiuses NestJS guards, Prisma, the outbox table, and idempotency ports;services/workerpublishes outbox events, retries process managers, and powers integrations.packages/dataowns the Prisma client and repositories.
- Progress lives in docs such as
docs/IMPLEMENTATION_SUMMARY.md,CODE_SHARING_ANALYSIS.md, and the per-domain status notes (ACCOUNTING_CORE_STATUS.md,POS_IMPLEMENTATION_STATUS.md). Watch those for what is happening now. - Contributors can help by picking tasks from the implementation docs, updating the mock server when new contracts arrive, or improving module guides (
docs/MODULE_IMPLEMENTATION_GUIDE.md,docs/MODULE-TEMPLATE.md). - Large changes start with an issue describing the intent; small PRs that include updated tests/docs are most welcome.
- Contracts first: add Zod schemas, enums, and tool definitions inside
packages/contracts/src/<module>so web, POS, API, and worker share the surface. - Backend module: create
services/api/src/modules/<module>folders with domains, use cases, DTOs, and Nest controllers that depend only on ports/adapters. - Data nor cross-writes: add migrations under
packages/data/prisma/schema/and let repositories inpackages/data/srcown DB writes; no other module touches those tables directly. - Frontend module: mirror the module in
apps/web/src/modules/<module>(screens, hooks, routes) and point to the shared contracts plus the HTTP client. - Mock routes: register UI-first routes/seeds in
services/mock-server/src/routesso the mock server stays up to date.
Keep the boundaries: API modules use ports/interfaces, the worker only publishes the module’s events, and clients never import backend internals.
- Open an issue for any larger initiative so maintainers can track scope before code.
- Small, focused PRs that pass
pnpm lint,pnpm typecheck, and relevant tests get reviewed faster. - Update docs or
docs/IMPLEMENTATION_SUMMARY.mdwhen you touch workflows, contracts, or module behavior. - Code style follows the shared configs (
eslint.config.js,prettier.config.js). Runpnpm formatandpnpm lint:fixwhen you add or move files. - See
CONTRIBUTING.mdfor setup, DCO sign-off, and review expectations. Community standards live inCODE_OF_CONDUCT.md.
Please follow SECURITY.md for private reporting and response expectations. Placeholder contact: <SECURITY_EMAIL>.
Subject to change.
- Module registry and pack metadata so teams can enable restaurant/hotel/factory workflows with one settings switch.
- Workflow editor integration that composes use-case graphs for approvals, approvals, and multi-step automations.
- POS offline build-out: queue durability, shift sessions, floor plan workflows, and manager approvals.
- AI Copilot improvements: richer tool cards, assistant run auditing, and more deterministic apply/dismiss flows.
- Vertical pack work: kitchen display flows, room folio billing, manufacturing BOM routing, and pack-specific migrations.
- Observability upgrades: structured logs with trace IDs, read-model telemetry, and outbox monitoring dashboards.
- Marketplace for connectors (webhooks, real-time adapters) that plug into the outbox/worker automation surface.
Corely Community is licensed under AGPL-3.0-only. Enterprise Packs are commercial and distributed separately. Trademarks are governed by TRADEMARKS.md.
See LICENSE and docs/licensing.md for details.
Built on Vite, React, NestJS, Prisma, BullMQ, and XState along with the ideas documented in docs/architect.md and docs/overall-structure.md.