server.js
Entry point: initializes Express app, middleware, routes, and starts HTTP server
config/db.js
PostgreSQL connection pool setup using pg library with Neon connection string
config/env.js
Validates and exports environment variables (DATABASE_URL, JWT_SECRET, PORT)
middleware/auth.js
JWT verification middleware that attaches decoded user payload to req.user
middleware/roles.js
Role-based access control middleware factory: requireRole('admin') etc.
middleware/errorHandler.js
Global error handling middleware that formats and returns consistent error responses
routes/auth.js
POST /auth/register and POST /auth/login endpoints for user registration and JWT issuance
routes/projects.js
CRUD endpoints for projects: GET, POST, PUT, DELETE /projects and /projects/:id
routes/tasks.js
CRUD endpoints for tasks nested under projects: /projects/:projectId/tasks and /tasks/:id
routes/users.js
Admin-only user management endpoints: list users, update roles, delete users
controllers/authController.js
Business logic for register and login: password hashing, JWT signing, user creation
controllers/projectController.js
Business logic for project CRUD with ownership checks and member validation
controllers/taskController.js
Business logic for task CRUD including due date handling and completion toggling
controllers/userController.js
Business logic for admin user management operations
models/userModel.js
SQL query functions for users table: findById, findByEmail, create, updateRole, delete
models/projectModel.js
SQL query functions for projects table: findAll (by owner), findById, create, update, delete
models/taskModel.js
SQL query functions for tasks table: findByProject, findById, create, update, markComplete, delete
db/migrations/001_create_users.sql
Creates users table with id, email, password_hash, role, created_at columns
db/migrations/002_create_projects.sql
Creates projects table with id, name, description, owner_id (FK), created_at columns
db/migrations/003_create_tasks.sql
Creates tasks table with id, project_id (FK), title, description, due_date, completed, created_at columns
db/seed.js
Optional seed script to insert a default admin user and sample project/tasks for testing
utils/jwt.js
Helper functions for signing and verifying JWTs with configurable expiry
utils/validate.js
Input validation helpers using simple checks or a lightweight schema validator
.env.example
Template for required environment variables: DATABASE_URL, JWT_SECRET, PORT, NODE_ENV
package.json
Project metadata, npm scripts (start, dev, migrate, seed), and dependencies
README.md
API documentation with endpoint list, auth flow, setup instructions, and example requests