A self-hosted database management tool for teams. Connect to PostgreSQL and ClickHouse servers, browse tables, run queries, create branches, and manage access — all from a clean, modern interface.
Built for developers who want a Neon-like experience on their own infrastructure.
- Multi-database support — PostgreSQL and ClickHouse via a unified adapter
- Server connections — manage multiple servers with environment tagging (dev/staging/prod)
- Database browser — list databases with sizes, create new ones, export full backups
- Table browser — search tables, view row counts and sizes, recent table history
- Paginated data grid — sort, filter, and paginate through table data
- Inline editing — double-click cells to edit with type-aware inputs (text, number, boolean, JSON, date, enum)
- Row operations — insert, delete, and modify rows with undo support
- Foreign key previews — hover over FK columns to see a mini-table preview of the referenced row
- Copy cell values — click to copy any cell
- CodeMirror editor — syntax highlighting, autocomplete, and keyboard shortcuts
- Query history — persistent per-user history with favorites and tags
- Results table — sortable, scrollable results with execution time and row count
- Execute with Cmd+Enter
- Create branches — clone databases for development or testing
- Full or schema-only mode with per-table row limits
- Branch tracking — metadata, creator, status, connection strings
- One-click connection strings — copy direct, PgBouncer, or dev URLs
- GitHub OAuth — sign in with GitHub, no passwords
- Role-based access — Admin, Developer, Viewer roles per connection
- User approval flow — first user becomes admin, others require approval
- Audit logging — every action tracked with user, timestamp, and metadata
- AES-256-GCM encryption for stored database passwords
- Parameterized queries throughout — no SQL injection vectors
- JWT sessions with 30-day expiration
- Permission checks on every API route
- SSL/TLS support for database connections
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript 5 |
| UI | Tailwind CSS 4, shadcn/ui, Radix UI |
| Data Grid | TanStack Table |
| SQL Editor | CodeMirror 6 |
| ORM | Prisma 6 |
| Auth | NextAuth.js 5 (GitHub OAuth) |
| PostgreSQL | node-postgres (pg) |
| ClickHouse | @clickhouse/client |
| State | React hooks, Zustand |
| Notifications | Sonner |
- Node.js 18+
- PostgreSQL (for the application's own database)
- GitHub OAuth App credentials
git clone <repository-url>
cd db-masterclass
npm install- Go to GitHub Developer Settings
- Click New OAuth App
- Set the callback URL to
http://localhost:3000/api/auth/callback/github - Save the Client ID and Client Secret
cp .env.example .envFill in your .env:
# App
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET= # openssl rand -base64 32
AUTH_TRUST_HOST=true
# GitHub OAuth
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# Application database (Prisma)
DATABASE_URL=postgresql://user:password@localhost:5432/dbmaster
# Encryption key for stored passwords
ENCRYPTION_KEY= # openssl rand -base64 32createdb dbmaster
npx prisma migrate devnpm run devOpen http://localhost:3000. The first user to sign in becomes the admin.
| Role | Capabilities |
|---|---|
| Admin | Full access — manage users, connections, databases, run any query |
| Developer | Read/write on assigned connections, create branches, run queries |
| Viewer | Read-only access, SELECT queries only |
Roles are assigned per connection, so a user can be a Developer on staging and a Viewer on production.
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npx prisma generate
RUN npm run build
FROM node:18-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
EXPOSE 3000
CMD ["node", "server.js"]- Create a new service and connect the repository
- Set the environment variables
- Deploy — migrations run automatically on start
npm run dev # Start dev server (runs migrations first)
npm run build # Production build
npm run start # Start production server (runs migrations first)
npm run lint # ESLint
npm run db:migrate # Run Prisma migrations
npm run db:studio # Open Prisma Studiosrc/
app/
(dashboard)/ # Authenticated routes
[connectionId]/ # Server view — database browser
db/[database]/ # Database view — tables, query runner
tables/[tableName] # Table view — data grid, schema, editor
admin/ # User management
api/ # API routes (connections, queries, branches, etc.)
auth/ # Sign in, pending, rejected pages
components/
ui/ # shadcn/ui primitives
layout/ # Header, navigation
sql-editor/ # CodeMirror wrapper
lib/
db.ts # PostgreSQL pool management
clickhouse.ts # ClickHouse client management
db-adapter.ts # Unified database adapter interface
encryption.ts # AES-256-GCM password encryption
auth.ts # NextAuth configuration
prisma.ts # Prisma client singleton
prisma/
schema.prisma # Data models
migrations/ # Database migrations
This project is licensed under the Commons Clause License (MIT base).
You are free to use, modify, and self-host this software. You may not sell it or offer it as a paid hosted service. See LICENSE.md for details.