This project provides a task management interface designed for desktop usage. It features task creation, real-time sorting by topic, status, and due date, dynamic overdue detection, task editing, and soft-deletion (archiving) with unarchiving capabilities.
---
## Architectural Choices & Key Decisions
1. Next.js App Router (Server Components & Server Actions):
- Server Components execute on Node.js, allowing direct SQLite queries without separate REST API setup.
- Server Actions handle form submissions securely on the server, eliminating client-side API boilerplate.
- Server cache revalidation (`revalidatePath('/')`) keeps UI data in sync instantly after mutations.
2. SQLite via `better-sqlite3` (Local-First):
- Synchronous, file-based database stored directly in `todo.db`.
- Offers low latency and zero network dependencies.
3. Dynamic Overdue State Derivation:
- Overdue status is computed dynamically at read-time by comparing `due_date` against the current date for non-completed tasks.
- Overdue state is intentionally excluded as a database column to prevent stale data.
4. Soft-Deletion (Archiving):
- Tasks are never hard-deleted from SQLite. Archiving sets `is_archived = 1`, preserving historical records while enabling restoration.
---
## System Architecture UML Diagram
```mermaid
sequenceDiagram
autonumber
actor User
participant ClientComp as React Client Component
participant ServerAct as Server Action (actions.ts)
participant DataLayer as Data Access Layer (tasks.ts)
participant SQLite as SQLite DB (todo.db)
participant Page as Server Page (page.tsx)
User->>ClientComp: Submit Task / Action Trigger
ClientComp->>ServerAct: Invoke Server Action (formData)
Note: Next.js defaults to port 3000. If port 3000 is occupied, Next.js automatically selects the next available port (e.g. 3001), or you can specify a custom port using `npm run dev -- -p <PORT_NUMBER>`.
AI assistance was utilized during this project for architectural explanations, troubleshooting SQLite schema initialization, and reviewing TSX component patterns. All code additions were executed under guided pair-programming workflows.