Apex is a modern, high-performance, multi-tenant SaaS platform built with Next.js 16, PostgreSQL, and Clerk Authentication. It features a "Shared Database, Shared Schema" architecture with strict Row-Level Security (RLS) for enterprise-grade data isolation.
- Multi-Tenancy: Subdomain-based routing (
tenant-a.localhost,admin.localhost). - Data Isolation: Secure PostgreSQL RLS ensuring tenants never see each other's data.
- Enterprise Auth: Clerk Organization support mapped to database tenants.
- Real-time Events: Pusher integration for live activity feeds.
- Super Admin Dashboard: Centralized management for provisioning and analytics.
- Premium UI: Glassmorphism, Framer Motion animations, and modern aesthetics.
- Framework: Next.js 16 (App Router)
- Database: PostgreSQL (Dockerized)
- ORM: Drizzle ORM
- Auth: Clerk
- Real-time: Pusher
- Styling: Tailwind CSS v4, Framer Motion
- Testing: Playwright
- Node.js 20+
- Docker & Docker Compose
- Clerk Account
- Pusher Account
Copy .env.example to .env.local (create it if missing) and populate:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
DATABASE_URL=postgres://postgres:password@localhost:5432/apex
NEXT_PUBLIC_PUSHER_KEY=...
NEXT_PUBLIC_PUSHER_CLUSTER=...
pusher_app_id=...
pusher_secret=...
NEXT_PUBLIC_ROOT_DOMAIN=localhost:3000-
Start the database:
docker-compose up -d
-
Install dependencies:
npm install
-
Run migrations:
npm run db:push
-
Start the development server:
npm run dev
Visit http://localhost:3000 to see the public marketing page.
Visit http://tenant-a.localhost:3000 (or any subdomain) to access the isolated tenant environment.
Visit http://admin.localhost:3000 to access the Super Admin Dashboard.
- Manage Tenants (Create, Delete)
- View Global Analytics
See ARCHITECTURE.md for a deep dive into the system design, RLS policies, and request flow.