Skip to content

krsendev/taskflow-restful-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โœ… TaskFlow

A Fullstack Task Management Application built with React, Express.js, Supabase PostgreSQL, and JWT Authentication.

TaskFlow follows RESTful API principles and provides secure authentication, authorization, and complete CRUD operations for task management. The project demonstrates frontend-backend integration using modern web development technologies.


โœจ Features

Authentication & Authorization

  • User Registration with name, email, and password
  • User Login with JWT token generation
  • JWT-based Authentication on protected endpoints
  • Protected Routes on the frontend (React Router)
  • User-Based Resource Authorization (users can only access their own tasks)

Task Management

  • Create Task with title and optional description
  • View All Tasks (sorted by newest first)
  • View Task Details by ID
  • Update Task (title, description, completed status)
  • Delete Task
  • Mark / Unmark Task as Completed

API Documentation

  • Interactive Swagger UI at /docs
  • OpenAPI 3.0 specification at /docs.json
  • Try-it-out functionality with JWT authentication

Frontend Design

  • Minimalist UI with blue, white, and black color palette
  • Glassmorphism login & register cards
  • Responsive layout for desktop and mobile
  • Smooth micro-animations and hover effects
  • Custom-styled checkboxes and task cards
  • Google Fonts (Inter) typography

๐Ÿ› ๏ธ Tech Stack

Frontend

Technology Purpose
React 19 UI library
Vite 8 Build tool & dev server
React Router DOM Client-side routing
Axios HTTP client
Vanilla CSS Styling & animations

Backend

Technology Purpose
Node.js Runtime environment
Express.js 5 Web framework
JSON Web Token (JWT) Authentication
bcryptjs Password hashing
Joi Request validation
swagger-jsdoc OpenAPI spec generation
swagger-ui-express API documentation UI

Database

Technology Purpose
Supabase PostgreSQL Cloud-hosted database

๐Ÿ“ Project Structure

TaskFlow/
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ supabase.js          # Supabase client configuration
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ swagger.js           # Swagger/OpenAPI specification
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.controller.js   # Register, login, me handlers
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ task.controller.js   # CRUD task handlers
โ”‚   โ”‚   โ”œโ”€โ”€ middlewares/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.middleware.js    # JWT verification middleware
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ validate.middleware.js # Joi validation middleware
โ”‚   โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.routes.js       # Auth endpoint routes
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ task.route.js        # Task endpoint routes
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.service.js      # User database operations
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ task.service.js      # Task database operations
โ”‚   โ”‚   โ”œโ”€โ”€ utils/                   # Utility functions (hash, token)
โ”‚   โ”‚   โ”œโ”€โ”€ validations/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.validation.js   # Register & login schemas
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ task.validation.js   # Create & update task schemas
โ”‚   โ”‚   โ””โ”€โ”€ app.js                   # Express app setup & middleware
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ .env.example
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ server.js                    # Server entry point
โ”‚
โ””โ”€โ”€ frontend/
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ api/                     # Axios instance configuration
    โ”‚   โ”œโ”€โ”€ context/
    โ”‚   โ”‚   โ””โ”€โ”€ AuthContext.jsx       # JWT token state management
    โ”‚   โ”œโ”€โ”€ pages/
    โ”‚   โ”‚   โ”œโ”€โ”€ Login.jsx             # Login page with form
    โ”‚   โ”‚   โ”œโ”€โ”€ Register.jsx          # Register page with form
    โ”‚   โ”‚   โ””โ”€โ”€ Dashboard.jsx         # Task management dashboard
    โ”‚   โ”œโ”€โ”€ routes/
    โ”‚   โ”‚   โ”œโ”€โ”€ AppRoutes.jsx         # Route definitions
    โ”‚   โ”‚   โ””โ”€โ”€ ProtectedRoute.jsx    # Auth guard component
    โ”‚   โ”œโ”€โ”€ services/
    โ”‚   โ”‚   โ”œโ”€โ”€ auth.service.js       # Auth API calls
    โ”‚   โ”‚   โ””โ”€โ”€ task.service.js       # Task API calls
    โ”‚   โ”œโ”€โ”€ styles/
    โ”‚   โ”‚   โ””โ”€โ”€ global.css            # Design system & all styles
    โ”‚   โ””โ”€โ”€ main.jsx                  # App entry point
    โ”‚
    โ”œโ”€โ”€ index.html
    โ””โ”€โ”€ package.json

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Frontend    โ”‚
โ”‚  (Vite Dev Server)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ HTTP Requests
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Axios HTTP Client  โ”‚
โ”‚  (Bearer Token)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Express REST API   โ”‚
โ”‚  (Port 5000)        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  JWT Auth Middleware โ”‚
โ”‚  Joi Validation     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Swagger UI (/docs) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Supabase PostgreSQL โ”‚
โ”‚  (Cloud Database)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”Œ RESTful API Endpoints

Authentication

Method Endpoint Auth Description
POST /api/auth/register โŒ Register a new user
POST /api/auth/login โŒ Login and receive JWT token
GET /api/auth/me โœ… Get current authenticated user

Tasks

Method Endpoint Auth Description
GET /api/tasks โœ… Get all user's tasks
GET /api/tasks/:id โœ… Get a single task
POST /api/tasks โœ… Create a new task
PATCH /api/tasks/:id โœ… Update a task
DELETE /api/tasks/:id โœ… Delete a task

Documentation

Method Endpoint Description
GET /docs Swagger UI interactive docs
GET /docs.json Raw OpenAPI 3.0 JSON spec

๐Ÿš€ Installation

1. Clone the Repository

git clone <repository-url>
cd TaskFlow

2. Backend Setup

Navigate to the backend directory:

cd backend

Install dependencies:

npm install

Create a .env file based on .env.example:

PORT=5000

SUPABASE_URL=your_supabase_url

SUPABASE_KEY=your_supabase_key

JWT_SECRET=your_jwt_secret

Start the backend server:

npm run dev

The backend server will be available at:

http://localhost:5000

Swagger API Documentation:

http://localhost:5000/docs

3. Frontend Setup

Open a new terminal and navigate to the frontend directory:

cd frontend

Install dependencies:

npm install

Start the frontend development server:

npm run dev

The frontend application will be available at:

http://localhost:5173

๐Ÿ—„๏ธ Database Schema

Users Table

Column Type Description
id uuid (PK) Auto-generated UUID
name text User's display name
email text User's email address
password text Bcrypt hashed
created_at timestamptz Auto-generated

Tasks Table

Column Type Description
id uuid (PK) Auto-generated UUID
title text Task title (required)
description text Task description
completed boolean Completion status
user_id uuid (FK) References users.id
created_at timestamptz Auto-generated

Relationship

users (1) โ”€โ”€โ”€โ”€โ”€โ”€ (*) tasks

Each task belongs to a single user. Users can only access, modify, and delete their own tasks.


๐Ÿ“– API Documentation

Interactive API documentation is available through Swagger UI:

http://localhost:5000/docs

Swagger provides:

  • Complete endpoint documentation with descriptions
  • Request body schemas with examples
  • Response schemas for all status codes (200, 201, 400, 401, 403, 404, 500)
  • JWT Bearer authentication testing via the Authorize button
  • Interactive "Try it out" functionality for all endpoints

The raw OpenAPI 3.0 JSON specification is also available at:

http://localhost:5000/docs.json

๐Ÿ“ธ Screenshots

Login Page

Login Page

Register Page

Register Page

Dashboard

Dashboard

Swagger API Documentation

Swagger API Documentation


๐Ÿ“š Learning Objectives

This project demonstrates the implementation of:

  • RESTful API Design with proper HTTP methods and status codes
  • JWT Authentication and token-based authorization
  • Authorization Middleware for resource-level access control
  • CRUD Operations with Supabase PostgreSQL
  • React State Management with Context API
  • Protected Routes on both frontend and backend
  • Frontendโ€“Backend Integration via Axios HTTP client
  • Request Validation using Joi schemas
  • API Documentation with Swagger / OpenAPI 3.0
  • Modern CSS Design with glassmorphism and micro-animations

๐Ÿ”ฎ Future Improvements

  • Search & filter tasks
  • Pagination for task lists
  • User profile management
  • Dark mode toggle
  • Task categories / labels
  • Due dates and reminders
  • Automated testing (Jest / Vitest)
  • Docker deployment

๐Ÿ‘ค Author

Krisna Guntur Pamungkas | 241080200051

TaskFlow was developed as a Fullstack RESTful API project for learning modern web application development using React, Express.js, JWT Authentication, and Supabase PostgreSQL.

About

Tugas Mata Kuliah PABW

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors