Skip to content
emaagPublic

About

Full-stack project management dashboard — Next.js, Tailwind CSS, Prisma, NextAuth.js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MiniSaaS Dashboard

A full-stack project management dashboard built with Next.js, Tailwind CSS, Prisma, Supabase, and NextAuth.js.

Next.js Tailwind Prisma Tests

Live demo: minisaas.statichex.dev — login admin@minisaas.com / password123

Status at a glance

Requirement State
List, filter, search, add, edit projects (full CRUD) ✅ Implemented
Project fields: Status, Deadline, Assigned member, Budget ✅ Implemented
React/Next.js + Tailwind CSS (Next.js 16 App Router, Tailwind 4) ✅ Implemented
Responsive table with filtering/search ✅ Implemented
Modal form to add/edit projects ✅ Implemented
Node.js/Next.js API routes ✅ Implemented
PostgreSQL (Supabase) ✅ Implemented
RESTful endpoints (200/201/400/401/404/500) ✅ Implemented
Data seeding from public API (JSONPlaceholder) ✅ Implemented
Authentication (NextAuth.js v5, JWT) ✅ Bonus
GitHub version control ✅ Bonus
README with setup and usage ✅ Bonus
Deployment (live demo) ✅ Bonus
Containerization (Docker) ✅ Bonus
Unit tests (61 via Vitest) ✅ Bonus

Additional features (beyond spec)

  • Column sorting (click any header)
  • Dashboard summary stat cards (total, active, on hold, completed, budget)
  • Budget distribution bar chart by status
  • Toast notifications on CRUD actions
  • CSV export of project data
  • Loading skeleton placeholders
  • Delete confirmation dialog
  • Server actions for secure cookie-based login

Table of Contents

Tech Stack

Layer Technology Rationale
Frontend Next.js 16 (App Router), React 19, Tailwind CSS 4 App Router enables server/client component split for optimal performance; Tailwind provides utility-first styling without custom CSS overhead
Backend Next.js API Routes (RESTful) Co-located with frontend — single deployment unit, shared TypeScript types between client and server
Database PostgreSQL via Supabase + Prisma ORM Managed PostgreSQL with connection pooling; Prisma provides type-safe queries and migrations
Auth NextAuth.js v5, Credentials provider, JWT sessions Stateless JWT avoids session storage complexity; credentials provider keeps the demo self-contained (no OAuth setup)
Testing Vitest, React Testing Library 61 unit tests covering components, types, and API validation
Containerization Docker + Docker Compose Multi-stage build produces a ~100MB production image

Setup Instructions

There are three ways to run the app. Each is fully independent.

Option 1: Local Development

Prerequisites: Node.js 20+, npm 9+, a Supabase account (free tier)

git clone https://github.com/emaag/MiniSaaS.git
cd MiniSaaS
npm install
cp .env.example .env
# Edit .env with your Supabase connection strings (see Environment Variables below)
npx prisma migrate dev --name init
npx prisma db seed
npm run dev

Open http://localhost:3000 and sign in with admin@minisaas.com / password123.

Option 2: Docker

Prerequisites: Docker, Docker Compose, and a Supabase account (free tier)

cp .env.example .env
# Edit .env with your Supabase connection strings (see Environment Variables below)
docker compose up --build

The app starts at http://localhost:3000. If this is your first time running the app and the Supabase database is empty, run the migration and seed:

docker compose exec app npx prisma migrate deploy
docker compose exec app npx tsx prisma/seed.ts

Sign in with admin@minisaas.com / password123.

No local Node.js or npm required — only Docker and a Supabase database connection. The container connects to the same remote PostgreSQL database used in local development.

Note: If you previously ran the app locally on the same port, your browser may still have a valid session cookie and log you in automatically. If you already ran prisma migrate and prisma db seed during local development, the database is already set up and the Docker container will use it as-is.

Option 3: Live Demo

Visit https://minisaas.statichex.dev and log in with admin@minisaas.com / password123.

Environment Variables

Variable Description Example
DATABASE_URL Supabase pooled connection string (port 6543) postgresql://postgres.[ref]:[pw]@aws-0-[region].pooler.supabase.com:6543/postgres?pgbouncer=true
DIRECT_URL Supabase session mode connection (port 5432, used for migrations) postgresql://postgres.[ref]:[pw]@aws-0-[region].pooler.supabase.com:5432/postgres
NEXTAUTH_SECRET Secret for JWT signing (use a random string in production) —
NEXTAUTH_URL Base URL of the application http://localhost:3000

To get your Supabase connection strings: create a project at supabase.com, then go to Connect and find the connection URI. See .env.example for a ready-to-copy template.

Architectural Decisions

Browser ──> Next.js Server Component (auth check) ──> Client Component (interactivity)
                    │
                    ├── /api/projects ──> Prisma ORM ──> PostgreSQL (Supabase)
                    ├── /api/users    ──> Prisma ORM ──> PostgreSQL (Supabase)
                    └── /api/auth/*   ──> NextAuth.js (JWT)
  • Server/Client Component Split — the dashboard page is a server component that checks auth and redirects if needed, then renders a client component for interactive state (search, modals, table). This avoids client-side auth flicker and keeps the auth check server-side.
  • Server Actions for Login — login uses a Next.js server action instead of client-side signIn() from next-auth/react. This handles cookies natively server-side, avoiding CSRF and cross-origin issues.
  • Per-Route Auth — each API route independently checks auth() rather than relying on middleware, providing explicit security at the route level.
  • Prisma Singleton — a global Prisma client instance prevents connection exhaustion during Next.js hot reloads in development.

Technical Tradeoffs

Database: PostgreSQL (Supabase) vs SQLite on the live site

The spec calls for PostgreSQL, which is used for local development and Docker via Supabase. However, the shared hosting provider (Namecheap) blocks outbound connections on PostgreSQL ports (5432 and 6543), making it impossible to reach Supabase from the live server.

Decision: the live demo at minisaas.statichex.dev uses SQLite as a drop-in replacement. Prisma's database abstraction makes this seamless — the application code is identical across all environments. Only the datasource provider (postgresql vs sqlite) and connection string in .env differ.

Why not switch everything to SQLite? PostgreSQL is the better choice for production — it handles concurrent writes, has richer query capabilities (e.g., native ILIKE for case-insensitive search), and Supabase provides managed backups, connection pooling, and a dashboard. SQLite is fine for a single-user demo but wouldn't scale to a real multi-user SaaS.

NextAuth v5 (beta) on shared hosting

NextAuth v5 is the latest Auth.js integration for Next.js App Router, but it's still in beta. On shared hosting with Phusion Passenger, the auth URL parsing breaks when the app runs under a subpath (e.g., /minisaas). The solution was to deploy under a subdomain (minisaas.statichex.dev) where the app runs at root — no subpath parsing issues.

Standalone build vs full deployment

Next.js output: "standalone" produces a minimal self-contained build for Docker. On the shared hosting, the CloudLinux Node.js selector manages dependencies through a virtual environment, so the live site uses the venv's next package with the standalone build's .next output — a hybrid approach that satisfies both the hosting infrastructure and the build optimization.

API Endpoints

All endpoints require authentication (JWT session cookie).

Method Endpoint Description Status Codes
GET /api/projects List projects (?search= and ?status= query params) 200, 401, 500
POST /api/projects Create a new project 201, 400, 401, 500
GET /api/projects/:id Get a single project 200, 401, 404, 500
PUT /api/projects/:id Update a project (supports partial updates) 200, 401, 500
DELETE /api/projects/:id Delete a project 200, 401, 500
GET /api/users List all team members (for assignment dropdown) 200, 401, 500

Testing Instructions

npm test            # Run all 61 tests
npm run test:watch  # Watch mode for development

Tests cover:

  • Components: StatusBadge, StatsBar, ProjectTable, SearchFilter, DeleteConfirm, Toast
  • Types: Runtime validation of TypeScript interface shapes
  • API Validation: Input validation rules, budget parsing, date handling

Project Structure

src/
├── app/
│   ├── api/                    # RESTful API routes
│   │   ├── auth/[...nextauth]/ # NextAuth.js catch-all handler
│   │   ├── projects/           # Project CRUD (route.ts + [id]/route.ts)
│   │   └── users/              # User list endpoint
│   ├── dashboard/
│   │   ├── page.tsx            # Server component — auth gate
│   │   └── dashboard-client.tsx # Client component — interactive UI
│   ├── login/
│   │   ├── page.tsx            # Login form (client component)
│   │   └── actions.ts          # Server action for authentication
│   ├── layout.tsx              # Root layout with Tailwind globals
│   └── page.tsx                # Entry redirect (/ → /dashboard or /login)
├── __tests__/                  # Unit tests (Vitest + React Testing Library)
├── components/
│   ├── BudgetChart.tsx         # Budget distribution bar chart by status
│   ├── DeleteConfirm.tsx       # Destructive action confirmation dialog
│   ├── ExportCSV.tsx           # CSV download for current project list
│   ├── Navbar.tsx              # App header with user email and sign out
│   ├── ProjectModal.tsx        # Dual-purpose add/edit form modal
│   ├── ProjectTable.tsx        # Sortable, responsive data table with actions
│   ├── SearchFilter.tsx        # Search input + status dropdown + add button
│   ├── StatsBar.tsx            # Dashboard summary stat cards
│   ├── StatusBadge.tsx         # Color-coded status pill (green/yellow/blue)
│   ├── TableSkeleton.tsx       # Loading skeleton placeholder for table
│   └── Toast.tsx               # Auto-dismissing notification toast
├── lib/
│   ├── auth.ts                 # NextAuth.js config (providers, callbacks, JWT)
│   └── prisma.ts               # Prisma client singleton (hot-reload safe)
└── types/
    └── index.ts                # Shared TypeScript interfaces

Database Schema

Model Fields Notes
User id (CUID), name, email (unique), password (bcrypt), createdAt Serves as both auth subject and project assignee
Project id (CUID), name, description, status, deadline, budget, assignedToId (FK), createdAt, updatedAt Status is a string enum: active, on_hold, completed

Available Scripts

Command Description
npm run dev Start development server
npm run build Build for production
npm run start Start production server
npm test Run unit tests (61 tests)
npm run test:watch Run tests in watch mode
npm run db:generate Generate Prisma client
npm run db:migrate Run database migrations
npm run db:seed Seed the database
npm run db:reset Reset and re-seed database

Known Limitations

  • Live site uses SQLite — the shared hosting blocks outbound PostgreSQL connections (see Technical Tradeoffs above).
  • Supabase free tier — limited to 500MB storage and 2 concurrent connections. Sufficient for demo/review purposes.
  • No pagination — the project list loads all records. Fine for the demo dataset (12 projects) but would need cursor-based pagination for larger datasets.
  • No password reset — the auth system supports login only. A production system would add password reset, email verification, and account management.

Closing Thoughts

This project was built as a full-stack developer task to demonstrate competence across the entire stack — from database design and API architecture to responsive UI and deployment infrastructure.

A few things worth highlighting about the approach:

  • Prisma as the abstraction layer turned out to be one of the best decisions. It made it possible to develop locally against Supabase PostgreSQL, deploy to shared hosting with SQLite, and run Docker against the same Supabase instance — all without changing a single line of application code. The schema is the contract, and the provider is just configuration.
  • Next.js App Router with the server/client component split gave auth protection "for free" — the dashboard page checks the session server-side before any client code runs, which means there's no flash of unauthenticated content and no client-side auth race conditions.
  • The deployment story was the hardest part. Shared hosting with CloudLinux Passenger doesn't play nicely with Next.js or NextAuth under a subpath. Moving to a subdomain solved the auth routing issue, and falling back to SQLite solved the blocked outbound PostgreSQL ports. The lesson: know your hosting constraints early and design around them.

If there were more time, next up would be pagination with cursor-based navigation, role-based access control (admin vs viewer), and real-time updates via WebSocket or Server-Sent Events. But for a dashboard that needs to list, filter, search, and CRUD projects — this covers the brief and then some.

About

Full-stack project management dashboard — Next.js, Tailwind CSS, Prisma, NextAuth.js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages