Skip to main content

Backend Architecture

The backend (backend/) is a NestJS application organized into feature modules under backend/src/modules/. Each module typically owns its own controller, service, and DTOs, and most services inject the webhook dispatcher to emit events on state changes (see Webhook system).

Modules

ModulePurpose
api-keysCRUD and verification of API keys; stores a hash and tracks last-used time.
auth-extendedExtends the auth library with password management, e.g. letting OIDC-only users set a local password.
clientsManages customer records.
companyManages the organization profile, PDF branding (colors, fonts), and email templates.
cronScheduled background tasks.
dangerSensitive operations requiring OTP verification (e.g. account deletion).
dashboardAggregates KPIs: invoice totals, revenue trends, quote statuses, client counts.
directoryRestricted filesystem browser used for plugin/config file selection.
invitationsCreates and validates invitation codes for multi-user signup.
invoicesCore invoice CRUD, PDF/XML generation, payment tracking, line items.
loggerServer-sent event stream of real-time logs, filterable by category/level/user.
payment-methodsStores and toggles payment methods, attached to invoices/quotes.
pluginsRegistry and loader for built-in and external plugins. See Plugin system.
quotesQuote CRUD, PDF generation, signing workflow, expiry tracking.
receiptsReceipt generation from invoices, PDFs, email dispatch.
recurring-invoicesScheduled invoice generation on a recurring basis.
signaturesBridges the quote-signing workflow for anonymous signers.
statsMonthly/yearly financial statistics.
webhooksUser-defined webhook subscriptions and event dispatch to external endpoints.

Data layer

The backend uses Prisma as its ORM, with the schema defined in backend/prisma/schema.prisma. SQLite is the default database for local/Docker setups; PostgreSQL is supported via DATABASE_URL.

API documentation

The backend exposes a live Swagger/OpenAPI UI at /api/docs (JSON spec at /api/docs-json), generated from @nestjs/swagger decorators on each controller. See the API Reference page.