A modern, full-stack task management system built with type-safe APIs, JWT authentication, and role-based access control.
TaskForge demonstrates a complete full-stack architecture with a Hono REST API backend and Next.js frontend. It showcases JWT authentication, role-based authorization (admin/user), task assignment workflows, and type-safe client-server communication using shared RPC types.
π Table of Contents
- π JWT Authentication β Secure token-based auth with 7-day expiry
- π₯ Role-Based Access Control β Separate permissions for admins and users
- β Task Management β Create, view, and track tasks with due dates
- π Type-Safe APIs β End-to-end TypeScript validation via RPC types
- π Password Hashing β Bcrypt-based secure password storage
- β‘ Full-Stack β Integrated frontend + backend in a single repo
βββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js) β
β ββ React Components β
β ββ Hono Typed Client (hc) β
β ββ JWT in localStorage β
ββββββββββββββ¬βββββββββββββββββββββββββββββ
β HTTP + JWT Bearer
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Backend (Hono) β
β ββ API Routes β
β ββ JWT Verification β
β ββ RBAC Middleware β
β ββ Database Logic β
ββββββββββββββ¬βββββββββββββββββββββββββββββ
β Drizzle ORM
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β SQLite Database (Turso) β
β ββ users_table β
β ββ task_table β
βββββββββββββββββββββββββββββββββββββββββββ
Type Safety: Shared RPC types in rpc/appTypes.ts provide compile-time validation for all API calls.
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 15, React, TailwindCSS | UI & Client |
| Backend | Hono, Node.js, TypeScript | REST API |
| Database | SQLite (Turso), Drizzle ORM | Data Layer |
| Auth | JWT, Bcrypt, zod | Security |
| Runtime | Bun | Task running |
- Framework: Hono (TypeScript)
- Database: SQLite via Drizzle ORM
- Auth: JWT tokens (7-day expiry) + bcrypt password hashing
- Port:
8000
| File | Purpose |
|---|---|
backend/src/index.ts |
API routes & middleware |
backend/src/user.ts |
User DB operations |
backend/src/task.ts |
Task DB operations |
backend/src/utils/auth.ts |
JWT generation & verification |
backend/src/utils/password.ts |
Bcrypt hashing & comparison |
- POST
/registerβ Create new user β{ name, email, password } - POST
/loginβ Authenticate user β{ email, password } - GET
/meβ Get current user (requires JWT)
- GET
/usersβ List all users (admin-only)
- GET
/tasksβ Get tasks for current user - GET
/admin/tasksβ Get all tasks (admin-only) - POST
/taskβ Create task (admin-only) β{ title, userId, dueDate }
- Framework: Next.js (app router)
- Client: Hono typed client (
hc) with RPC types - Session: JWT stored in
localStorage - Styling: TailwindCSS
| File | Purpose |
|---|---|
frontend/src/app/page.tsx |
Homepage with role-based UI |
frontend/src/app/login/page.tsx |
Login form |
frontend/src/app/register/page.tsx |
Registration form |
frontend/src/app/tasks/ |
User tasks dashboard |
frontend/src/app/admin/ |
Admin panel |
frontend/src/app/lib/api/ |
Typed API client helpers |
| Route | Purpose |
|---|---|
/ |
Homepage (show login/register or dashboard) |
/register |
Registration form |
/login |
Login form |
/tasks |
User's assigned tasks |
/admin |
Admin dashboard (create tasks, manage users) |
| Frontend Function | Backend Endpoint | Auth |
|---|---|---|
registerUser() |
POST /register |
None |
loginUser() |
POST /login |
None |
getMe() |
GET /me |
JWT |
getAllUsers() |
GET /users |
Admin |
getTasksById() |
GET /tasks |
JWT |
getAllTasks() |
GET /admin/tasks |
Admin |
createTask() |
POST /task |
Admin |
The rpc/appTypes.ts file exports shared TypeScript types that both frontend and backend use. This ensures:
- β Request payloads are validated at compile time
- β Response shapes are type-checked
- β No runtime shape errors
- β Full IDE autocomplete support
- User registers or logs in with email & password
- Backend validates credentials and issues a JWT token
- JWT contains:
{ id, name, email, role, expiresAt } - Frontend stores token in
localStorage - All protected requests include:
Authorization: Bearer <token> - Backend verifies token and checks
rolefor RBAC
- Register & login
- View tasks assigned to them
- Cannot create tasks or manage other users
- Do everything a user can do
- List all users (
GET /users) - List all tasks with assignees (
GET /admin/tasks) - Create tasks for any user (
POST /task) - Promote users to admin (by updating role in DB)
ββββββββββββββββββββββββββββββββββββββββββββ
β π‘οΈ ADMIN ACCOUNT β
ββββββββββββββββββββββββββββββββββββββββββββ€
β Email: [email protected] β
β Password: Password123! β
β Role: admin β
ββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββ
β π€ USER ACCOUNT β
ββββββββββββββββββββββββββββββββββββββββββββ€
β Email: [email protected] β
β Password: Password123! β
β Role: user β
ββββββββββββββββββββββββββββββββββββββββββββ
- Node.js 18+ or Bun
- SQLite or Turso database
cd backend
bun install
bun run devβ
API running at http://localhost:8000
cd frontend
bun install
bun run devβ
UI running at http://localhost:3000
# .env or .env.local
JWT_SECRET=your-super-secret-key-here
BACKEND=http://localhost:8000- backend/README.md β Detailed backend setup & routes
- frontend/README.md β Detailed frontend setup & components
- rpc/appTypes.ts β Shared RPC type definitions
β οΈ Tokens stored inlocalStorageare vulnerable to XSS; use HttpOnly cookies for production- β All authorization is enforced server-side β frontend UI is just for UX
- β Passwords are hashed with bcrypt (12 rounds)
- β JWTs expire after 7 days
Made with β€οΈ by ItPinion