I need to create a productivity app with nextjs frontend that will achieve the following:
take input on ideas for development
create a task list
research resources to assist me complete the task
-track completing and report on the frontend dashboard
-alert on tasks that are falling behind
an agentic workflow at the backend using langgraph
Allow for entry of a model and API key at the front end
may use fastapi to integrate from and back end
may save information to duckdb
Assistant
Below is a complete “starter-blueprint” for the app you described. It isn’t just theory; you can copy / paste most of the snippets and immediately start wiring things together. I break it into:
Why this split?
• Next.js gives you SSR/ISR, a crunchy UI, & static hosting.
• FastAPI is pythonic, async-ready, LLM-friendly.
• LangGraph lives natively in Python.
• DuckDB = zero-deps analytics DB that saves as a single file (state.duckdb) – perfect for side-projects.
2. DuckDB Data Model
sql
-- ideas user wants to develop
CREATE TABLE ideas (
id UUID PRIMARY KEY,
title TEXT,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- granular tasks derived from ideas
CREATE TABLE tasks (
id UUID PRIMARY KEY,
idea_id UUID REFERENCES ideas(id),
title TEXT,
status TEXT, -- todo | in_progress | done | blocked
due_date TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
completed_at TIMESTAMP
);
-- resources produced by the research agent
CREATE TABLE resources (
id UUID PRIMARY KEY,
task_id UUID REFERENCES tasks(id),
url TEXT,
summary TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- system settings (1 row per user -> multi-tenant later)
CREATE TABLE settings (
id UUID PRIMARY KEY,
model_name TEXT,
api_key TEXT, -- store encrypted in prod!
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
DuckDB is embedded; you’ll open it via duckdb.connect("state.duckdb").
3. Backend
3.1 FastAPI skeleton
python
# backend/main.py
from fastapi import FastAPI, WebSocket, Depends
from fastapi.middleware.cors import CORSMiddleware
import duckdb, uuid, datetime as dt
from pydantic import BaseModel
from langgraph import Graph, Message, run_graph
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], allow_methods=["*"], allow_headers=["*"]
)
db = duckdb.connect("state.duckdb")
db.execute("PRAGMA foreign_keys=ON") # ensure FK checks
# ---------- Pydantic shapes ----------
class IdeaIn(BaseModel):
title: str
description: str
class TaskStatusUpdate(BaseModel):
id: str
status: str
class SettingsIn(BaseModel):
model_name: str
api_key: str
# ---------- REST endpoints ----------
@app.post("/ideas")
def create_idea(idea: IdeaIn):
idea_id = str(uuid.uuid4())
db.execute("INSERT INTO ideas VALUES (?, ?, ?, ?)",
(idea_id, idea.title, idea.description, dt.datetime.utcnow()))
# Delegate to LangGraph for task generation & research
kick_off_pipeline(idea_id) # async in real app
return {"id": idea_id}
@app.get("/dashboard")
def dashboard():
return db.execute("""
SELECT i.*, json_group_array(
json_object('id', t.id, 'title', t.title, 'status', t.status, 'due', t.due_date)
) as tasks
FROM ideas i LEFT JOIN tasks t on i.id = t.idea_id
GROUP BY i.id
""").fetchall()
@app.patch("/tasks/status")
def update_status(body: TaskStatusUpdate):
db.execute("UPDATE tasks SET status = ?, completed_at = ? WHERE id = ?",
(body.status, dt.datetime.utcnow() if body.status == "done" else None, body.id))
return {"ok": 1}
@app.post("/settings")
def save_settings(s: SettingsIn):
db.execute("DELETE FROM settings") # single-user
db.execute("INSERT INTO settings VALUES (?,?,?,?)",
(str(uuid.uuid4()), s.model_name, s.api_key, dt.datetime.utcnow()))
return {"ok": 1}
# ---------- WebSocket for push alerts ----------
clients = set()
@app.websocket("/ws")
async def ws_endpoint(ws: WebSocket):
await ws.accept()
clients.add(ws)
try:
while True:
await ws.receive_text() # keep alive
except:
pass
finally:
clients.remove(ws)
3.2 Agentic workflow – LangGraph
A minimal three-node graph:
TaskGenerator – takes Idea, produces list of task titles & due dates
Researcher – for each task, find resources (web search or tool=browser.search)
Tracker – writes all info to DuckDB and notifies front-end via WebSocket
python
# backend/agents.py
from langgraph import Graph, Message, run_graph
import os, requests, json
def get_settings():
row = db.execute("SELECT model_name, api_key FROM settings LIMIT 1").fetchone()
return row[0], row[1] if row else ("gpt-4o", os.getenv("OPENAI_API_KEY",""))
def agent_llm(prompt):
model, key = get_settings()
# quick + dirty, use openai-python
import openai; openai.api_key = key
completion = openai.chat.completions.create(
model=model,
messages=[{"role":"system","content":prompt}]
)
return completion.choices[0].message.content.strip()
def TaskGenerator(msg: Message):
idea_id = msg.content["idea_id"]
idea = db.execute("SELECT title, description FROM ideas WHERE id=?", (idea_id,)).fetchone()
prompt = f"""
You are a senior PM. Break the following product idea into 3-6 actionable engineering tasks, with realistic due dates
(ISO date, within 30 days).
Idea: {idea[0]} — {idea[1]}
Respond as JSON: [{{"title":"...", "due":"YYYY-MM-DD"}}]
"""
tasks_json = agent_llm(prompt)
return Message(kind="tasks", content={"idea_id": idea_id, "tasks": json.loads(tasks_json)})
def Researcher(msg: Message):
task_list = msg.content["tasks"]
out = []
for t in task_list:
q = f"best resources for {t['title']}"
# DuckDuckGo API or Serper etc…
res = requests.get("https://ddg-api.herokuapp.com/search", params={"q":q}).json()
picks = res["results"][:3]
out.append({**t, "resources": picks})
return Message(kind="research", content={"idea_id": msg.content["idea_id"], "tasks": out})
def Tracker(msg: Message):
idea_id = msg.content["idea_id"]
for t in msg.content["tasks"]:
task_id = str(uuid.uuid4())
db.execute("INSERT INTO tasks VALUES (?,?,?,?,?,?,?)",
(task_id, idea_id, t["title"], "todo", t["due"], dt.datetime.utcnow(), None))
for r in t["resources"]:
db.execute("INSERT INTO resources VALUES (?,?,?,?,?)",
(str(uuid.uuid4()), task_id, r["link"], r["snippet"], dt.datetime.utcnow()))
# push to all websocket clients
import asyncio, json
payload = json.dumps({"type":"new_tasks", "idea_id": idea_id})
for c in clients: asyncio.create_task(c.send_text(payload))
return Message(kind="done", content={"ok":1})
workflow = Graph()
workflow.add_node("tasks", TaskGenerator)
workflow.add_node("research", Researcher)
workflow.add_node("save", Tracker)
workflow.add_edge("tasks","research")
workflow.add_edge("research","save")
workflow.set_entry_node("tasks")
def kick_off_pipeline(idea_id: str):
run_graph(workflow, Message(kind="start", content={"idea_id":idea_id}))
3.3 Scheduler for “falling behind” alerts
python
# backend/scheduler.py
from apscheduler.schedulers.background import BackgroundScheduler
def overdue_check():
rows = db.execute("""
SELECT id, title FROM tasks
WHERE status != 'done' AND due_date < CURRENT_TIMESTAMP
""").fetchall()
if rows:
import asyncio, json
payload = json.dumps({"type":"overdue", "ids":[r[0] for r in rows]})
for c in clients: asyncio.create_task(c.send_text(payload))
sched = BackgroundScheduler()
sched.add_job(overdue_check, "interval", minutes=30)
sched.start()
Run the backend:
bash
uvicorn backend.main:app --reload
4. Front-end (Next 13+/App Router)
Install deps:
bash
npx create-next-app@latest prod-app
cd prod-app
npm i @tanstack/react-query axios socket.io-client clsx tailwindcss postcss autoprefixer
npx tailwindcss init -p
4.1 lib/api.ts
ts
import axios from "axios";
const api = axios.create({ baseURL: "http://localhost:8000" });
export default api;
4.2 React-Query provider
tsx
// app/providers.tsx
'use client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
export default function Providers({ children }: { children: React.ReactNode }) {
const qc = new QueryClient();
return <QueryClientProvider client={qc}>{children}</QueryClientProvider>;
}
Tailwind config: enable JIT scanning of app/**/*.{ts,tsx}.
5. Realtime Alerts, CRON & Notifications
• Backend pushes JSON via WS when tasks turn overdue (overdue_check).
• Front-end marks those tasks in red, toast popup etc (use react-toastify for snackbars).
• For background mobile / email notifications add a sidecar celery or just call an SMTP API inside overdue_check.
Prod:
• Render.com: deploy FastAPI Docker; Next.js as static (or Vercel).
• Or fly.io – both services in a single machine with foreman Procfile.
• DuckDB file can be placed on a mounted volume for persistence.
Scaling considerations:
• Swap DuckDB for Postgres later; same schema works.
• Secure API key storage (Hashicorp Vault or at least AES-encrypted column).
• Auth (Clerk / NextAuth) if multi-user.
Next Steps / Optional Polishing
✅ Add drag-and-drop Kanban (e.g., dnd-kit)
✅ Add time-estimation & burndown charts with chart.js
✅ Integrate browser search tool like serpapi inside LangGraph
✅ Use Edge runtime + React Server Components for even snappier UI
✅ Write Cypress tests
That’s the “MVP plus” blueprint—once you spin it up you’ll have idea-to-tasks generation, research links, live dashboard, overdue alerts, model / key injection, and agentic LangGraph orchestration, all stitched together with batteries included. 🚀