Architecture
Karam Connect is a modular monolith made of a few separately deployed apps, all in the karam_connect repository. Each app has its own folder, toolchain and AGENTS.md. Most share one pnpm workspace and lockfile at the repository root; the docs site has its own.
| Component | Folder | Stack | Domain |
|---|---|---|---|
| Server | server/ | Node.js, Fastify 5, Better Auth, Drizzle ORM, PostgreSQL | api.karamconnect.com |
| Client | client/ | Vue 3, PrimeVue 5 (Apollo template), Pinia, vue-i18n, Tailwind CSS | app.karamconnect.com |
| Admin app | admin-client/ | Vue 3, PrimeVue 5 (started from a copy of the client), English only | admin.karamconnect.com |
| Neighbor portal | portal/ | Vue 3, PrimeVue 5, Pinia Colada, vue-i18n, Tailwind CSS | my.karamconnect.com |
| Community Resources | community-resources/ | Astro public site reading the server's public API, in the root workspace | community.karamconnect.com |
| Marketing site | marketing-site/ | Vue 3, PrimeVue 5, prerendered with vite-ssg | www.karamconnect.com |
| Docs | docs/ | VitePress | docs.karamconnect.com |
Shared code (permissions, the design system, forms, error reporting and more) lives in packages/, as TypeScript sources the apps import from the workspace.
Server
A Fastify 5 API in TypeScript, run natively by Node. Authentication uses Better Auth with session cookies and its organization plugin; fine-grained permissions sit on top of it (roles, permissions and an audit log), and checks are made against permissions, not role names.
Data lives in PostgreSQL through Drizzle ORM. Every organization shares the same tables: each row carries an organization_id, and PostgreSQL row-level security (RLS) keeps one organization's data away from another's as a second line of defence behind the application's own checks. Notes, tags, tasks, contact details and custom field values are shared tables that attach to records through one nullable composite foreign key (organization_id plus the record's id) per kind of record (an exclusive arc), never a generic entity_type and entity_id, so the database enforces every link and keeps it inside the organization. A check limits how many of those keys may be set: exactly one for tags, contact details and custom field values, at most one for notes and tasks, which can also stand alone (an organization-wide note, a personal task).
The internal API serves the client; a separate, versioned external API (api.karamconnect.com/v2) is planned for integrations.
Client
A single-page app built on PrimeTek's Apollo template (PrimeVue 5, Tailwind CSS 4, Vite). It talks to the server through Better Auth's client and the internal API, reads its feature flags from the server (GET /api/flags) and uses Tolgee to manage translations.
Admin app
The platform administration app for Karam Connect's own staff, separate from the staff client so no platform feature is ever served to an organization. Only platform admins sign in (password, an authenticator app, and an emailed code on a new device); they are created from the server's command line. Today it manages organizations; it talks to the server's /api/platform/* routes.
Platform admins never read an organization's records by their role. To look into a problem, they open an organization only under its support grant (#13): an owner or admin grants time-limited, read-only or read-write access with one role's permissions (minus member, role, settings, export, erase, merge and share permissions, and without restricted data unless included), and the platform admin enters as the organization's own Support account through POST /api/auth/support/enter. That account has a membership that is always deactivated; its session is checked against the open grant on every request, lasts at most four hours, shows staff a banner, and leaves its changes in the organization's audit log. Full impersonation of a staff member stays off.
Neighbor portal
A small separate app where neighbors an organization invited sign in with an emailed code, at my.karamconnect.com/<organization slug>. It talks only to the server's /api/portal routes, with its own session cookie, so no staff code ever reaches a neighbor. Today it has the sign-in and a minimal home page.
Community Resources
Public, multilingual resource pages for each organization at community.karamconnect.com/<organization slug>/resources. The server stores them with the rest of the organization's data and serves the published ones from its public read API (/api/public/community). An Astro site renders them on the server with no client-side JavaScript, so they stay fast on cheap phones, and adds each organization's sitemap and llms.txt. The staff editor in the client is still to come (#409).
Hosting
Production runs on DigitalOcean App Platform: the client, admin app, neighbor portal and docs as static sites, the server and the Community Resources site as services, with managed PostgreSQL. Staging is a second set of App Platform apps from the same specs, with its own database on the same cluster. Hostnames and DNS records are in Domains and DNS.