Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Hierarchical TodoApp - CS162 Final Project

Video Demonstration: Loom Video

GitHub Repository: https://github.com/Omarhus01/cs162-web-application-assignment

A full-stack hierarchical task management system built with Flask and React, featuring intelligent task completion cascading and 5-level nesting support.


๐Ÿ“‹ Overview

This application allows users to organize complex projects through nested tasks and subtasks. Built with a Flask REST API backend and React frontend, it supports up to 5 levels of task nesting with smart completion logic: checking a parent completes all children, and completing all children auto-completes the parent.

The system uses session-based authentication to keep users' data private, and features a recursive component architecture that dynamically renders the task hierarchy. The dark cyberpunk-themed interface makes it both functional and visually distinctive.


โœจ Key Features

Core Functionality

  • Multi-user Support - Private todo lists with session-based authentication
  • 5-Level Nesting - Organize tasks into deep hierarchies (Extension 1)
  • Smart Completion - Intelligent cascading when checking/unchecking tasks
  • Persistent State - Collapse/expand states saved to database
  • Task Movement - Move tasks between lists with all subtasks
  • Duplicate Prevention - Validates unique names in context

User Experience

  • Cyberpunk UI - Custom dark theme with neon accents
  • Priority System - Color-coded badges (๐Ÿ”ด High, ๐ŸŸก Medium, ๐ŸŸข Low)
  • Inline Editing - Double-click to edit task titles
  • Create & Move - Create new lists directly from move dropdown
  • Task Statistics - Real-time progress tracking

๐Ÿ› ๏ธ Technology Stack

Backend

  • Flask 2.3.3 - REST API framework
  • SQLAlchemy - Database ORM with self-referential relationships
  • SQLite - Embedded database
  • Werkzeug - Password hashing
  • Pytest - Testing framework (52 tests, 86% coverage)

Frontend

  • React 18 - Component-based UI
  • React Router 6 - Client-side routing
  • Axios - HTTP client
  • Bootstrap 5 - Responsive framework
  • Custom CSS - Cyberpunk theme

๐Ÿ“ฆ Installation & Setup

Prerequisites

  • Python 3.11+
  • Node.js 14+
  • npm 6+

Backend Setup

Windows:

cd "TodoApp w\backend"
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt
python app.py

macOS/Linux:

cd "TodoApp w/backend"
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python3 app.py

โœ… Backend runs on http://localhost:5000

Frontend Setup

cd "TodoApp w/frontend"
npm install
npm start

โœ… Frontend runs on http://localhost:3000

The database is created automatically on first run. No manual configuration needed!


๐ŸŽฎ Usage Guide

Getting Started

  1. Register - Create account with username, email, password
  2. Login - Enter credentials to access dashboard
  3. Create List - Click "+ New List" to organize tasks
  4. Add Tasks - Create top-level tasks with title, description, priority
  5. Add Subtasks - Click "โ‹ฎ" โ†’ "โž• Add Subtask" (up to 5 levels deep)

Task Actions

  • Complete - Click checkbox (cascades to all subtasks)
  • Edit - Double-click title or click "โ‹ฎ" โ†’ "โœ๏ธ Edit"
  • Change Priority - Click priority badge โ†’ Select level
  • Move to List - Click "โ‹ฎ" โ†’ "Move to List" โ†’ Select or create list
  • Delete - Click "โ‹ฎ" โ†’ "๐Ÿ—‘๏ธ Delete" (removes all subtasks)
  • Collapse/Expand - Click โ–ถ/โ–ผ button (state persists)

Checkbox Logic

  • Check parent โ†’ All children auto-check
  • Check all children โ†’ Parent auto-checks
  • Uncheck parent โ†’ Children keep their state
  • Uncheck any child โ†’ Parent auto-unchecks

๐Ÿงช Testing

Run Tests

cd "TodoApp w\backend"
.\venv\Scripts\Activate.ps1
pytest tests/ -v

Test Coverage

52 tests, 100% pass rate, 86% coverage

Category Tests Coverage
Authentication 5 tests Register, login, sessions
Todo Lists 10 tests CRUD + duplicate validation
Tasks 15 tests CRUD, toggle, collapse, move
Business Logic 13 tests Cascading, nesting, depth limits
Duplicates 8 tests Name validation across contexts
# With coverage report
pytest tests/ --cov=app --cov=models --cov-report=html

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     React Frontend (localhost:3000)         โ”‚
โ”‚  Components: Login, Dashboard, ListView,    โ”‚
โ”‚  TaskItem (recursive), AuthContext          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚ HTTP/JSON REST API
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      Flask Backend (localhost:5000)         โ”‚
โ”‚  Routes: /api/auth/*, /api/lists/*,         โ”‚
โ”‚  /api/tasks/* (15 endpoints)                โ”‚
โ”‚  Middleware: CORS, Sessions, Auth           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚ SQLAlchemy ORM
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        SQLite Database (todoapp.db)         โ”‚
โ”‚  Tables: users, todo_lists, tasks           โ”‚
โ”‚  Relationships: Userโ†’Lists(1:N),            โ”‚
โ”‚  Listโ†’Tasks(1:N), Taskโ†’Subtasks(1:N)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Design Patterns

  • Self-referential Tasks - parent_id foreign key enables unlimited nesting
  • Recursive Components - TaskItem renders itself for subtask trees
  • Cascade Logic - Helper functions traverse tree up/down on completion
  • Session Auth - HTTP-only cookies with server-side validation
  • React Portals - Dropdowns render outside hierarchy for proper z-index

๐Ÿ“‹ Assignment Requirements

MVP Requirements โœ…

Requirement Status Implementation
Multi-user support โœ… Session auth with user isolation
User authentication โœ… Register/login with password hashing
Task completion โœ… Toggle with smart cascading
Hierarchical tasks โœ… Enhanced 5 levels (Extension 1) vs MVP's 3
Collapse/expand โœ… Persistent state in database
Move tasks โœ… Top-level tasks with all descendants
Persistent storage โœ… SQLite with SQLAlchemy ORM

Extensions Implemented

โœ… Extension 1: Enhanced Hierarchy

  • 5 levels of nesting instead of MVP's 3 levels
  • get_depth() method enforces limit
  • Color-coded borders for visual hierarchy
  • Backend validation prevents Level 6+

โœ… Extension 3: Unit Testing

  • 52 tests with 100% pass rate
  • 86% code coverage (models: 96%, app: 83%)
  • Fixtures for test isolation
  • Comprehensive edge case validation

๐Ÿ”’ Security

  • Password Hashing - Werkzeug pbkdf2:sha256 with 260k iterations
  • Session Management - HTTP-only cookies with secret key signing
  • SQL Injection Prevention - SQLAlchemy ORM with parameterized queries
  • XSS Prevention - React auto-escapes all user content
  • Authorization - Every endpoint verifies user ownership
  • CORS - Restricted to localhost:3000 in development

๐Ÿ› Troubleshooting

Port 5000 in use:

# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F

Module not found:

cd backend
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt

Database locked:

# Stop Flask, delete instance/todoapp.db, restart Flask

Cannot connect to backend:

  • Verify Flask running on http://localhost:5000
  • Check axios.defaults.withCredentials = true in api.js
  • Confirm CORS enabled in app.py

๐Ÿ“ Project Structure

TodoApp w/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py                    # Flask API (763 lines, 15 routes)
โ”‚   โ”œโ”€โ”€ models.py                 # Database models (298 lines)
โ”‚   โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”‚   โ”œโ”€โ”€ tests/                    # 52 unit tests
โ”‚   โ”‚   โ”œโ”€โ”€ test_auth.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_lists.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_tasks.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_business_logic.py
โ”‚   โ”‚   โ””โ”€โ”€ test_duplicates.py
โ”‚   โ”œโ”€โ”€ instance/                 # Database (auto-created)
โ”‚   โ”‚   โ””โ”€โ”€ .gitkeep              # Ensures folder exists in git
โ”‚   โ””โ”€โ”€ venv/                     # Python virtual env (gitignored)
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Auth/             # Login & Register
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Dashboard/        # Lists overview
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ TodoList/         # ListView component
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Task/             # TaskItem (recursive, 919 lines)
โ”‚   โ”‚   โ”œโ”€โ”€ context/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ AuthContext.jsx   # Global auth state
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js            # Axios API client
โ”‚   โ”‚   โ”œโ”€โ”€ App.js                # React Router setup
โ”‚   โ”‚   โ””โ”€โ”€ index.css             # Cyberpunk theme (1100+ lines)
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ node_modules/             # Node packages (gitignored)
โ”‚
โ”œโ”€โ”€ README.md                     # This file
โ””โ”€โ”€ SETUP.md                      # Quick start guide

๐Ÿ’ก Development Process

This project was built iteratively over several phases:

  1. Backend Foundation - Flask API with authentication and database models
  2. Frontend Setup - React components with routing and state management
  3. Core Features - Task CRUD, nesting, completion logic
  4. Smart Cascading - Upward and downward completion propagation
  5. UI Polish - Cyberpunk theme, inline editing, React Portals
  6. Testing - Comprehensive pytest suite with 86% coverage
  7. Refinements - Duplicate validation, "Create & Move" feature, bug fixes

AI Statement

I used AI assistance (GitHub Copilot, specifically Claude sonnet 4 and 4.5 alternatively) as a collaborative tool while maintaining full understanding of the code. I made sure I know what is being done, not just sendign the assignment and askign for it to be made. I also made sure that I can have the features that if I'm offered a TODO list as a user, I'd be happy to have these. I asked for it to be dark themed as it's much better forr my eyes than ligh versions. I made sure to cover all edge cases, there might be more but I made sure that whatever I can think of is handled in a good way.


๐Ÿ“š Resources


๐ŸŽ‰ Thank you for checking out this project!

About

Hierarchical TodoApp with React and Flask

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages