Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Claude Code Task Management Guide

## Documentation Available

📚 **Project Documentation**: Check the documentation files in this directory for project-specific setup instructions and guides.
**Project Tasks**: Check the tasks directory in documentation/tasks for the list of tasks to be completed. Use the CLI commands below to interact with them.

## MANDATORY Task Management Workflow

🚨 **YOU MUST FOLLOW THIS EXACT WORKFLOW - NO EXCEPTIONS** 🚨

### **STEP 1: DISCOVER TASKS (MANDATORY)**
You MUST start by running this command to see all available tasks:
```bash
task-manager list-tasks
```

### **STEP 2: START EACH TASK (MANDATORY)**
Before working on any task, you MUST mark it as started:
```bash
task-manager start-task <task_id>
```

### **STEP 3: COMPLETE OR CANCEL EACH TASK (MANDATORY)**
After finishing implementation, you MUST mark the task as completed, or cancel if you cannot complete it:
```bash
task-manager complete-task <task_id> "Brief description of what was implemented"
# or
task-manager cancel-task <task_id> "Reason for cancellation"
```

## Task Files Location

📁 **Task Data**: Your tasks are organized in the `documentation/tasks/` directory:
- Task JSON files contain complete task information
- Use ONLY the `task-manager` commands listed above
- Follow the mandatory workflow sequence for each task

## MANDATORY Task Workflow Sequence

🔄 **For EACH individual task, you MUST follow this sequence:**

1. 📋 **DISCOVER**: `task-manager list-tasks` (first time only)
2. 🚀 **START**: `task-manager start-task <task_id>` (mark as in progress)
3. 💻 **IMPLEMENT**: Do the actual coding/implementation work
4. ✅ **COMPLETE**: `task-manager complete-task <task_id> "What was done"` (or cancel with `task-manager cancel-task <task_id> "Reason"`)
5. 🔁 **REPEAT**: Go to next task (start from step 2)

## Task Status Options

- `pending` - Ready to work on
- `in_progress` - Currently being worked on
- `completed` - Successfully finished
- `blocked` - Cannot proceed (waiting for dependencies)
- `cancelled` - No longer needed

## CRITICAL WORKFLOW RULES

❌ **NEVER skip** the `task-manager start-task` command
❌ **NEVER skip** the `task-manager complete-task` command (use `task-manager cancel-task` if a task is not planned, not required, or you must stop it)
❌ **NEVER work on multiple tasks simultaneously**
✅ **ALWAYS complete one task fully before starting the next**
✅ **ALWAYS provide completion details in the complete command**
✅ **ALWAYS follow the exact 3-step sequence: list → start → complete (or cancel if not required)**
113 changes: 113 additions & 0 deletions app/api/finance/assets/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { auth } from "@/lib/auth";
import { getAssetById, updateAsset, deleteAsset } from "@/lib/services/financeService";
import { NextRequest } from "next/server";

// Get a specific asset by ID
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const asset = await getAssetById(params.id, session.user.id);

if (!asset) {
return new Response(
JSON.stringify({ error: "Asset not found" }),
{ status: 404, headers: { "Content-Type": "application/json" } }
);
}

return new Response(
JSON.stringify(asset),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error fetching asset:", error);
return new Response(
JSON.stringify({ error: "Failed to fetch asset" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}

// Update a specific asset by ID
export async function PUT(request: NextRequest, { params }: { params: { id: string } }) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const data = await request.json();

const asset = await updateAsset(params.id, session.user.id, data);

if (!asset) {
return new Response(
JSON.stringify({ error: "Asset not found" }),
{ status: 404, headers: { "Content-Type": "application/json" } }
);
}

return new Response(
JSON.stringify(asset),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error updating asset:", error);
return new Response(
JSON.stringify({ error: "Failed to update asset" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}

// Delete a specific asset by ID
export async function DELETE(request: NextRequest, { params }: { params: { id: string } }) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const asset = await deleteAsset(params.id, session.user.id);

if (!asset) {
return new Response(
JSON.stringify({ error: "Asset not found" }),
{ status: 404, headers: { "Content-Type": "application/json" } }
);
}

return new Response(
JSON.stringify({ message: "Asset deleted successfully" }),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error deleting asset:", error);
return new Response(
JSON.stringify({ error: "Failed to delete asset" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}
74 changes: 74 additions & 0 deletions app/api/finance/assets/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { auth } from "@/lib/auth";
import { createAsset, getAssetsByUserId, getAssetById, updateAsset, deleteAsset } from "@/lib/services/financeService";
import { NextRequest } from "next/server";

// Create a new asset
export async function POST(request: NextRequest) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const data = await request.json();

// Validate required fields
if (!data.name || data.value === undefined) {
return new Response(
JSON.stringify({ error: "Name and value are required" }),
{ status: 400, headers: { "Content-Type": "application/json" } }
);
}

const asset = await createAsset({
...data,
userId: session.user.id,
});

return new Response(
JSON.stringify(asset),
{ status: 201, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error creating asset:", error);
return new Response(
JSON.stringify({ error: "Failed to create asset" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}

// Get all assets for the authenticated user
export async function GET(request: NextRequest) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const assets = await getAssetsByUserId(session.user.id);

return new Response(
JSON.stringify(assets),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error fetching assets:", error);
return new Response(
JSON.stringify({ error: "Failed to fetch assets" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}
113 changes: 113 additions & 0 deletions app/api/finance/expenses/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { auth } from "@/lib/auth";
import { getExpenseById, updateExpense, deleteExpense } from "@/lib/services/financeService";
import { NextRequest } from "next/server";

// Get a specific expense by ID
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const expense = await getExpenseById(params.id, session.user.id);

if (!expense) {
return new Response(
JSON.stringify({ error: "Expense not found" }),
{ status: 404, headers: { "Content-Type": "application/json" } }
);
}

return new Response(
JSON.stringify(expense),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error fetching expense:", error);
return new Response(
JSON.stringify({ error: "Failed to fetch expense" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}

// Update a specific expense by ID
export async function PUT(request: NextRequest, { params }: { params: { id: string } }) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const data = await request.json();

const expense = await updateExpense(params.id, session.user.id, data);

if (!expense) {
return new Response(
JSON.stringify({ error: "Expense not found" }),
{ status: 404, headers: { "Content-Type": "application/json" } }
);
}

return new Response(
JSON.stringify(expense),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error updating expense:", error);
return new Response(
JSON.stringify({ error: "Failed to update expense" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}

// Delete a specific expense by ID
export async function DELETE(request: NextRequest, { params }: { params: { id: string } }) {
try {
const session = await auth.api.getSession({
headers: request.headers,
});

if (!session) {
return new Response(
JSON.stringify({ error: "Unauthorized" }),
{ status: 401, headers: { "Content-Type": "application/json" } }
);
}

const expense = await deleteExpense(params.id, session.user.id);

if (!expense) {
return new Response(
JSON.stringify({ error: "Expense not found" }),
{ status: 404, headers: { "Content-Type": "application/json" } }
);
}

return new Response(
JSON.stringify({ message: "Expense deleted successfully" }),
{ status: 200, headers: { "Content-Type": "application/json" } }
);
} catch (error) {
console.error("Error deleting expense:", error);
return new Response(
JSON.stringify({ error: "Failed to delete expense" }),
{ status: 500, headers: { "Content-Type": "application/json" } }
);
}
}
Loading