Production-ready REST API for task and project management, built with Next.js 15, TypeScript, Supabase (PostgreSQL), JWT authentication, and Zod validation. Includes an interactive API documentation page at the root route.
- JWT authentication with register, login, and protected routes
- Project management with full CRUD and ownership control
- Task management with filters by status, priority, assignee, and full-text search
- Comments on tasks
- Role-based access control
- Global middleware for route protection and CORS headers
- Zod validation on all inputs with descriptive error responses
- Interactive API documentation built-in at
/
| Layer | Technology |
|---|---|
| Framework | Next.js 15 (App Router) |
| Language | TypeScript |
| Database | Supabase (PostgreSQL) |
| Auth | JWT (jose + bcryptjs) |
| Validation | Zod |
| Deploy | Vercel |
- Node.js 18+
- Supabase project (free tier works)
git clone https://github.com/leamartinez07/taskflow-api.git
cd taskflow-api
npm install- Create a project at supabase.com
- Open the SQL Editor and run the contents of
supabase/schema.sql - Go to Settings → API and copy your keys
Create a .env.local file in the root directory:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
JWT_SECRET=your-secret-min-32-chars
JWT_EXPIRES_IN=7d
NEXT_PUBLIC_APP_URL=http://localhost:3000npm run devOpen http://localhost:3000 to view the API documentation.
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register |
No | Register a new user |
| POST | /api/auth/login |
No | Login, returns JWT token |
| GET | /api/auth/me |
Yes | Get current user profile |
| PATCH | /api/auth/me |
Yes | Update name or avatar |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /api/projects |
Yes | List projects (paginated) |
| POST | /api/projects |
Yes | Create a project |
| GET | /api/projects/:id |
Yes | Get project details and tasks |
| PATCH | /api/projects/:id |
Yes | Update project |
| DELETE | /api/projects/:id |
Yes | Delete project |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /api/tasks |
Yes | List tasks with filters |
| POST | /api/tasks |
Yes | Create a task |
| GET | /api/tasks/:id |
Yes | Get task details and comments |
| PATCH | /api/tasks/:id |
Yes | Update task |
| DELETE | /api/tasks/:id |
Yes | Delete task |
| POST | /api/tasks/:id/comments |
Yes | Add a comment |
GET /api/tasks?project_id=uuid&status=todo&priority=high&search=text&page=1&limit=20
Available values for status: todo, in_progress, done, cancelled
Available values for priority: low, medium, high, urgent
src/
app/
api/
auth/ # register, login, me
projects/ # CRUD + nested tasks
tasks/ # CRUD + nested comments
health/ # status check
page.tsx # Interactive API docs
lib/
auth.ts # JWT sign/verify
supabase.ts # Supabase client
schemas.ts # Zod schemas
response.ts # Response helpers
types/
index.ts
middleware.ts # JWT route protection
supabase/
schema.sql # Database tables and indexes
MIT