Skip to content
ItsPinionPublic

About

A full-stack task management app with a Hono backend and Next.js frontend. It features JWT auth, role-based admin/user access, task assignment, and type-safe API calls using shared RPC TypeScript types to ensure safer frontend/backend integration and modern protected workflows for teams!

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Node TypeScript License Status

⚑ TaskForge

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

✨ Features

  • πŸ” 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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  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.


βš™οΈ Tech Stack

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

πŸ“ Backend

Overview

  • Framework: Hono (TypeScript)
  • Database: SQLite via Drizzle ORM
  • Auth: JWT tokens (7-day expiry) + bcrypt password hashing
  • Port: 8000

Key Files

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

API Endpoints

Authentication

  • POST /register β€” Create new user β†’ { name, email, password }
  • POST /login β€” Authenticate user β†’ { email, password }
  • GET /me β€” Get current user (requires JWT)

User Management (Admin Only)

  • GET /users β€” List all users (admin-only)

Task Management

  • GET /tasks β€” Get tasks for current user
  • GET /admin/tasks β€” Get all tasks (admin-only)
  • POST /task β€” Create task (admin-only) β†’ { title, userId, dueDate }

🎨 Frontend

Overview

  • Framework: Next.js (app router)
  • Client: Hono typed client (hc) with RPC types
  • Session: JWT stored in localStorage
  • Styling: TailwindCSS

Key Files

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

Pages & Routes

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)

πŸ”— Integration: Frontend ↔ Backend

Client Functions β†’ Backend Routes

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

Type Safety

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

πŸ” Auth & Roles

Authentication Flow

  1. User registers or logs in with email & password
  2. Backend validates credentials and issues a JWT token
  3. JWT contains: { id, name, email, role, expiresAt }
  4. Frontend stores token in localStorage
  5. All protected requests include: Authorization: Bearer <token>
  6. Backend verifies token and checks role for RBAC

User Roles

πŸ‘€ User (Default)

  • Register & login
  • View tasks assigned to them
  • Cannot create tasks or manage other users

πŸ›‘οΈ Admin

  • 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)

πŸ’Ό Demo Accounts

Quick Demo Credentials

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          πŸ›‘οΈ  ADMIN ACCOUNT               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Email:    [email protected]             β”‚
β”‚  Password: Password123!                  β”‚
β”‚  Role:     admin                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          πŸ‘€ USER ACCOUNT                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Email:    [email protected]              β”‚
β”‚  Password: Password123!                  β”‚
β”‚  Role:     user                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ or Bun
  • SQLite or Turso database

Backend Setup

cd backend
bun install
bun run dev

βœ… API running at http://localhost:8000

Frontend Setup

cd frontend
bun install
bun run dev

βœ… UI running at http://localhost:3000

Environment Variables (Backend)

# .env or .env.local
JWT_SECRET=your-super-secret-key-here
BACKEND=http://localhost:8000

πŸ“š Documentation


πŸ”’ Security Notes

  • ⚠️ Tokens stored in localStorage are 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

↑ back to top

Made with ❀️ by ItPinion

About

A full-stack task management app with a Hono backend and Next.js frontend. It features JWT auth, role-based admin/user access, task assignment, and type-safe API calls using shared RPC TypeScript types to ensure safer frontend/backend integration and modern protected workflows for teams!

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages