The problem
Agencies need one system to run multiple client organizations with isolated data, fine-grained permissions, a sales pipeline, and outbound email, instead of stitching together separate tools.
The approach
Built a public marketing site and an admin dashboard over a single Postgres schema. Modeled organizations, branches, departments, teams, and members with a full role and permission system, plus a CRM and an email marketing engine with campaigns and drip sequences.
Architecture
Next.js App Router for both the public client and the admin dashboard. Prisma over Postgres (Neon serverless adapter), Better Auth for sessions and accounts, Resend for transactional and campaign email, TanStack Table, react-hook-form, and Zod. Granular RBAC via Role, Permission, RolePermission, and per-user overrides, with audit logging.
Key features
- Multi-tenant organizations with branches, departments, teams, and members
- Granular role and permission system with per-user overrides and audit logs
- CRM with companies, contacts, tags, pipelines, stages, leads, and lead activity
- Email marketing with campaigns, recipients, events, and multi-step drip sequences
- Suppression list and email delivery logging
- Invitations and email verification via Resend
Tech stack
The result
A single platform runs multiple agency organizations with isolated data, fine-grained access control, a CRM pipeline, and automated email sequences.