ludops-todo/SETUP.md

141 lines
3.5 KiB
Markdown

# Todo App - Setup Guide
## Overview
This is a task management application that helps you track tasks with repeating schedules and priorities.
## Features
- **Timeline View**: Visual timeline showing past (15 days) and future (30 days) tasks
- **Today's Tasks**: Organized by priority (Essential / When I have time)
- **Task Management**: Create, complete, and renew tasks
- **Recurring Tasks**: Support for daily, weekly, monthly, and yearly repetition
- **Priority Levels**: Essential (always visible) and When I have time (collapsible)
## Tech Stack
- **Backend**: Node.js + Fastify + Drizzle ORM
- **Frontend**: React + TypeScript + Vite
- **Database**: PostgreSQL
- **Build**: Turborepo monorepo
## Local Development Setup
### Prerequisites
- Node.js (v18 or higher)
- pnpm (`npm install -g pnpm`)
- Docker Desktop (for local database)
### Steps
1. **Clone the repository**
```bash
git clone <your-repo-url>
cd ludops-todo
```
2. **Install dependencies**
```bash
pnpm install
```
3. **Set up environment**
```bash
cp .env.example .env
```
The .env file should contain:
```
DATABASE_URL=postgres://postgres:postgres@localhost:5432/todo_db
```
4. **Start local database**
```bash
docker compose -f docker-compose.dev.yml up -d
```
5. **Push database schema**
```bash
cd apps/api
pnpm db:push push
```
6. **Start development servers**
In one terminal (backend):
```bash
cd apps/api
pnpm dev
```
In another terminal (frontend):
```bash
cd apps/web
pnpm dev
```
7. **Open the app**
```
Frontend: http://localhost:5173
Backend API: http://localhost:3000
```
## Database Schema
### Tasks Table
| Column | Type | Description |
|--------|------|-------------|
| `id` | serial | Primary key |
| `name` | varchar(60) | Task name (required) |
| `created_on` | timestamp | Creation timestamp |
| `updated_on` | timestamp | Last update timestamp |
| `last_completed_on` | timestamp | Last completion date (nullable) |
| `does_repeat` | boolean | Whether task repeats |
| `repeats_every` | varchar(20) | Format: `X_UNIT` (e.g., `1_WEEKS`, `2_MONTHS`) |
| `priority` | enum | `ESSENTIAL` or `WHEN_I_HAVE_TIME` |
## API Endpoints
- `GET /api/tasks` - Get all tasks
- `POST /api/tasks` - Create a new task
- `PATCH /api/tasks/:id/complete` - Mark task as completed
- `PATCH /api/tasks/:id/renew` - Renew task (reset completion date)
## Task Logic
### Due Date Calculation
- **Non-repeating tasks**: Due immediately if `last_completed_on` is null
- **Repeating tasks**: Due date = `last_completed_on + repeats_every`
- **Today's tasks**: Any task with due date <= today
### Timeline Display
- Tasks are positioned on a 45-day timeline (15 past + 30 future)
- TODAY marker is at 33.33% from the left
- Tasks on the same day are stacked horizontally by priority
- Only shows tasks within the timeline range
## Production Deployment
See the main README.md for CI/CD deployment instructions using Gitea and Docker.
## Troubleshooting
### Database connection issues
- Make sure Docker is running: `docker ps`
- Check database is accessible: `docker exec -it ludops-todo-db-dev psql -U postgres -d todo_db`
### Port conflicts
- Frontend (5173): Change in `apps/web/vite.config.ts`
- Backend (3000): Change in `apps/api/src/index.ts`
- Database (5432): Change in `docker-compose.dev.yml`
### Schema changes
After modifying schema files in `apps/api/src/db/schemas/`, run:
```bash
cd apps/api
pnpm db:push push
```