Skip to content

About

Later, Probably tracks the gap between predicted and actual task outcomes to surface procrastination patterns. Built with Express, PostgreSQL, Prisma, and JWT auth. Gemini powers freeform task extraction, pgvector-based semantic search, and weekly insights generated from pre-aggregated stats. React + Recharts frontend.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Later, Probably

A personal task and time-estimation tracker that measures the gap between what you predicted and what actually happened. It is built around a single observation: most productivity tools help you plan better, but none of them tell you how wrong you consistently are about your own time, or which kinds of tasks you reliably avoid. This project attempts to surface those patterns through data rather than guesswork.


The core mechanic

When you add a task, you record a predicted duration and a predicted start time. You also tag it with one or more "avoidance tags" — short phrases that describe why you might procrastinate on it: boring, too big, unclear how to start, fear of doing it badly. When you complete the task, you log the actual duration, actual start time, and a subjective difficulty score (1–5).

That gap between prediction and reality is the data.

Worked example

You add a task: "Write Q2 progress report"

  • Predicted duration: 60 minutes
  • Predicted start: Monday 9:00 AM
  • Avoidance tags: too big, fear of doing it badly

You actually start it at 9:45 AM and finish after 95 minutes.

The system computes two figures:

Overrun % = ((actual - predicted) / predicted) × 100 = ((95 - 60) / 60) × 100 = +58%

Lag = actualStart - predictedStart = 45 minutes late

On the calibration dashboard, this task appears as a point on a scatter plot where the x-axis is predicted duration and the y-axis is actual duration. Points above the diagonal y = x line took longer than predicted; points below finished faster. The per-category table aggregates these overrun percentages across all your completed Work tasks, so you can see that you underestimate Work tasks by 45% on average but are accurate on Health tasks.

On the lag chart, the 45-minute delay is averaged together with all other tasks tagged too big and fear of doing it badly, producing a per-tag average lag figure. If fear of doing it badly consistently shows a 60-minute average lag across 12 tasks, that is a measurable pattern worth knowing about.


Architecture

┌─────────────────────┐         ┌──────────────────────────────────────┐
│   React (Vite)      │  HTTPS  │  Express 5 API                       │
│                     │ ──────► │                                      │
│  - React Router 6   │         │  Routes:                             │
│  - Axios            │ ◄────── │  /api/auth        /api/tasks         │
│  - Recharts         │  JSON   │  /api/categories  /api/dashboard     │
│  - Tailwind CSS     │         │  /api/tags        /api/insights      │
└─────────────────────┘         └───────────┬──────────────────────────┘
                                            │
                          ┌─────────────────┼─────────────────┐
                          │                 │                 │
                          ▼                 ▼                 ▼
              ┌──────────────────┐  ┌──────────────┐  ┌─────────────────┐
              │  PostgreSQL      │  │  Gemini API  │  │  Gemini API     │
              │  (Supabase)      │  │  gemini-     │  │  gemini-        │
              │                  │  │  2.5-flash   │  │  embedding-001  │
              │  pgvector ext.   │  │              │  │                 │
              │  vector(1536)    │  │  • Task parse│  │  • Embeddings   │
              │  HNSW index      │  │  • Insights  │  │    (async,      │
              └──────────────────┘  └──────────────┘  │    1536 dims)   │
                                                       └─────────────────┘

Where each AI call happens:

  • POST /api/tasks/parse — synchronous call to gemini-2.5-flash with the user's raw text; result returned to frontend for review before saving
  • POST /api/tasks and PATCH /api/tasks/:id — after the response is sent, a non-blocking background call to gemini-embedding-001 updates the embedding column on the Task row
  • GET /api/tasks/:id/similar — no AI call; reads the stored embedding and runs a raw SQL cosine distance query (<=>) against the pgvector HNSW index
  • POST /api/insights/generate — server aggregates stats from the DB, then makes a synchronous call to gemini-2.5-flash with structured numbers only

Tech stack

Backend: Node.js ≥20, Express 5.2, pg 8.22, bcrypt 6.0, jsonwebtoken 9.0, zod 4.4, cors 2.8, dotenv 17.4, @google/generative-ai 0.24, Prisma 7.9 (schema management only — all runtime queries are raw SQL via pg)

Frontend: React 18.3, Vite 6.0, React Router 6.28, Axios 1.7, Recharts 3.10, Tailwind CSS 3.4

Database: PostgreSQL via Supabase, pgvector extension, vector(1536) column on Task with an HNSW cosine index


Database design rationale

Why avoidance tags are many-to-many with tasks

A task can carry multiple avoidance reasons simultaneously. "Write the quarterly report" is both too big and fear of doing it badly. If tags were a single foreign key on Task, you would lose that granularity and could not meaningfully aggregate lag by tag across the dataset. The TaskAvoidanceTag join table (@@id([taskId, tagId])) allows a task to contribute to multiple tag groups in the lag analysis, which is the whole point of the feature.

Why the embedding column lives on the Task table

The embedding has a strict 1:1 relationship with a task and is always queried together with task fields in the similarity search (SELECT id, title, status, ... FROM "Task" WHERE ... ORDER BY embedding <=> $1). A separate table would require a join on every similarity query with no normalization benefit — there is no reuse of embeddings across tasks. Keeping the column on Task directly lets the pgvector HNSW index operate on a single table scan. The tradeoff is a wide row (1536 floats ≈ 6KB per row), which is acceptable at this scale.

Why insights are cached in the Insight table

Generating an insight involves fetching completed tasks, aggregating statistics, and making a Gemini API call. Running that on every dashboard load would be slow and expensive. Instead, insights are generated on demand and stored with a weekStart timestamp. The dashboard reads the cached result via GET /api/insights/latest. The user can regenerate the current week's insight at any time, which overwrites the stored row for that weekStart.


AI design decisions

Freeform task extraction

POST /api/tasks/parse takes a raw text string and sends it to gemini-2.5-flash with a system prompt that constrains the output to a strict JSON shape:

{
  "title": "string",
  "estimatedDurationMin": number,
  "category": "string",
  "avoidanceTags": ["string"]
}

The prompt explicitly forbids markdown formatting, code fences, and explanation. The server attempts JSON.parse on the response; if it fails, it retries once with a stricter instruction appended. If the second attempt also fails, the route returns 422 and the frontend falls back to the manual form. The user reviews and edits the extracted fields before anything is written to the database — the parse endpoint never saves data.

Semantic similarity search

When a task is created or its title is updated, the server generates a 1536-dimension embedding using gemini-embedding-001 with outputDimensionality: 1536 and taskType: "RETRIEVAL_DOCUMENT". This happens after the HTTP response is sent, so embedding failures never block the user. The vector is stored in a vector(1536) column on the Task table and indexed with pgvector's HNSW algorithm using cosine distance.

GET /api/tasks/:id/similar retrieves the target task's stored embedding and runs:

SELECT id, title, status, "actualDurationMin", "predictedDurationMin"
FROM "Task"
WHERE "userId" = $1 AND id != $2 AND embedding IS NOT NULL
ORDER BY embedding <=> $3::vector
LIMIT 3

This beats keyword search because it captures semantic meaning rather than literal word overlap. "Write the quarterly report" and "monthly expense summary" share no words but are close in embedding space because both describe financial documentation tasks.

Weekly insight generation — data minimization

POST /api/insights/generate does all aggregation on the server before touching the LLM. What gets sent to Gemini is a structured JSON object containing computed statistics:

{
  "totalCompleted": 10,
  "totalExceededPrediction": 7,
  "overrunByCategory": [
    { "category": "Work", "avgOverrunPercent": 52, "taskCount": 4 }
  ],
  "lagByTag": [
    { "tag": "fear of doing it badly", "avgLagMin": 68, "taskCount": 3 }
  ]
}

Raw task titles, descriptions, and personal content are never sent to the LLM. This is both a practical cost decision (fewer tokens) and a data-minimization decision: the model receives only what it needs to identify numerical patterns, not the contents of your task list. The prompt instructs the model to reference specific numbers in every sentence and to avoid generic advice.

If fewer than 3 completed tasks exist in the last 7 days, the endpoint returns { "insufficient": true } immediately and the Gemini call is skipped entirely.


Known limitations

Authentication is minimal by design. There are no refresh tokens, no email verification, and no password reset flow. The JWT is stored in localStorage (XSS-accessible). These are deliberate scoping decisions for a portfolio project — building a complete auth system would have been a distraction from the features the project is actually demonstrating.

Insight generation requires a minimum threshold. If a user has fewer than 3 completed tasks with prediction data in the last 7 days, the /api/insights/generate endpoint returns early with a message and makes no LLM call. This prevents the model from producing meaningless insights from a single data point.

Embedding generation is fire-and-forget. The embedding update is dispatched after the HTTP response is sent, with errors caught and logged but not surfaced to the user. If the Gemini embedding call fails (rate limit, network error), the task saves correctly but its embedding column remains null. GET /api/tasks/:id/similar returns an empty array for tasks without an embedding. The next title update triggers a retry.

Categories and avoidance tags are create-only. There are no update or delete routes for either resource. A user who creates a typo in a tag name cannot fix it through the API. This is a known gap.

Duplicate detection is case-insensitive but there is no merge or rename flow. The duplicate check on POST /api/categories and POST /api/tags uses lower(name) = lower($2), so Work and work are treated as the same. But if a user has both boring and Boring as separate tags (created before the check was in place), there is no way to merge them.


Running locally

Prerequisites

  • Node.js ≥ 20
  • A PostgreSQL instance with the pgvector extension enabled (Supabase free tier works)
  • A Gemini API key from Google AI Studio

1. Clone and install

git clone <repo-url>
cd "later,probably"

cd backend && npm install
cd ../frontend && npm install

2. Environment variables

Backend — copy backend/.env.example to backend/.env:

DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/DATABASE"
JWT_SECRET="generate with: openssl rand -hex 32"
GEMINI_API_KEY="your-key-from-google-ai-studio"
FRONTEND_URL="http://localhost:5173"
PORT=3000

Frontend — copy frontend/.env.example to frontend/.env:

VITE_API_URL=http://localhost:3000

3. Database setup

The schema uses a vector(1536) column which requires the pgvector extension. Run the following SQL in your database (Supabase SQL editor or psql):

CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE IF NOT EXISTS "User" (
  "id" SERIAL PRIMARY KEY, "email" TEXT NOT NULL UNIQUE,
  "passwordHash" TEXT NOT NULL, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS "Category" (
  "id" SERIAL PRIMARY KEY, "userId" INTEGER NOT NULL, "name" TEXT NOT NULL,
  CONSTRAINT "Category_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "AvoidanceTag" (
  "id" SERIAL PRIMARY KEY, "userId" INTEGER NOT NULL, "name" TEXT NOT NULL,
  CONSTRAINT "AvoidanceTag_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "Task" (
  "id" SERIAL PRIMARY KEY, "userId" INTEGER NOT NULL, "categoryId" INTEGER,
  "title" TEXT NOT NULL, "rawInput" TEXT, "predictedDurationMin" INTEGER,
  "predictedStart" TIMESTAMP(3), "status" TEXT NOT NULL DEFAULT 'pending',
  "actualStart" TIMESTAMP(3), "actualDurationMin" INTEGER, "actualDifficulty" INTEGER,
  "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "completedAt" TIMESTAMP(3),
  "embedding" vector(1536),
  CONSTRAINT "Task_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE,
  CONSTRAINT "Task_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category"("id")
);
CREATE TABLE IF NOT EXISTS "TaskAvoidanceTag" (
  "taskId" INTEGER NOT NULL, "tagId" INTEGER NOT NULL,
  PRIMARY KEY ("taskId", "tagId"),
  CONSTRAINT "TaskAvoidanceTag_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "Task"("id") ON DELETE CASCADE,
  CONSTRAINT "TaskAvoidanceTag_tagId_fkey" FOREIGN KEY ("tagId") REFERENCES "AvoidanceTag"("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "Insight" (
  "id" SERIAL PRIMARY KEY, "userId" INTEGER NOT NULL,
  "weekStart" TIMESTAMP(3) NOT NULL, "content" TEXT NOT NULL,
  "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS task_embedding_idx ON "Task" USING hnsw (embedding vector_cosine_ops);

4. Seed demo data (optional)

cd backend
node seed-demo.js

This creates a demo account with 10 completed tasks across 5 categories and 5 avoidance tags — enough to populate all dashboard charts and generate a weekly insight.

Email:    demo@laterprobably.com
Password: Demo1234

5. Start both servers

# Terminal 1
cd backend && npm run dev
# → http://localhost:3000

# Terminal 2
cd frontend && npm run dev
# → http://localhost:5173

API reference

All routes except /api/auth/* require Authorization: Bearer <token>.

Method Route Auth Description
POST /api/auth/signup — Create account. Body: { email, password }
POST /api/auth/login — Sign in. Returns { token, user }
GET /api/categories ✓ List user's categories
POST /api/categories ✓ Create category. Body: { name }
GET /api/tags ✓ List user's avoidance tags
POST /api/tags ✓ Create tag. Body: { name }
POST /api/tasks/parse ✓ AI extraction from raw text. Does not save.
POST /api/tasks ✓ Create task. Triggers async embedding.
GET /api/tasks ✓ Paginated list. Query: category, tag, status, sort, page, limit
GET /api/tasks/:id ✓ Single task with category and tags
GET /api/tasks/:id/similar ✓ Up to 3 semantically similar tasks via pgvector
PATCH /api/tasks/:id ✓ Update task. status: "completed" auto-sets completedAt
DELETE /api/tasks/:id ✓ Delete task. Returns 204.
GET /api/dashboard/calibration ✓ { byCategory, scatterPoints } for duration analysis
GET /api/dashboard/lag ✓ { byTag } for start-time lag analysis
POST /api/insights/generate ✓ Generate and cache weekly insight
GET /api/insights/latest ✓ Most recent cached insight

About

Later, Probably tracks the gap between predicted and actual task outcomes to surface procrastination patterns. Built with Express, PostgreSQL, Prisma, and JWT auth. Gemini powers freeform task extraction, pgvector-based semantic search, and weekly insights generated from pre-aggregated stats. React + Recharts frontend.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages