## Documentation System - Create complete documentation hub at /dashboard/docs with: - Getting Started guide with quick setup and troubleshooting - Hook Setup Guide with platform-specific configurations - API Reference with all endpoints and examples - FAQ with searchable questions and categories - Add responsive design with interactive features - Update navigation in base template ## Tool Call Tracking - Add ToolCall model for tracking Claude Code tool usage - Create /api/tool-calls endpoints for recording and analytics - Add tool_call hook type with auto-session detection - Include tool calls in project statistics and recalculation - Track tool names, parameters, execution time, and success rates ## Project Enhancements - Add project timeline and statistics pages (fix 404 errors) - Create recalculation script for fixing zero statistics - Update project stats to include tool call counts - Enhance session model with tool call relationships ## Infrastructure - Switch from requirements.txt to pyproject.toml/uv.lock - Add data import functionality for claude.json files - Update database connection to include all new models - Add comprehensive API documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
83 lines
2.5 KiB
Python
83 lines
2.5 KiB
Python
"""
|
|
Claude Code Project Tracker - FastAPI Application
|
|
"""
|
|
|
|
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from fastapi.responses import RedirectResponse
|
|
|
|
from app.database.connection import init_database, close_database
|
|
from app.api import sessions, conversations, activities, waiting, git, projects, analytics, importer, tool_calls
|
|
from app.dashboard.routes import dashboard_router
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Application lifespan management."""
|
|
# Startup
|
|
print("Starting Claude Code Project Tracker...")
|
|
await init_database()
|
|
yield
|
|
# Shutdown
|
|
print("Shutting down...")
|
|
await close_database()
|
|
|
|
|
|
# Create FastAPI app
|
|
app = FastAPI(
|
|
title="Claude Code Project Tracker",
|
|
description="API for tracking Claude Code development sessions and productivity",
|
|
version="1.0.0",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # In production, replace with specific origins
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include API routers
|
|
app.include_router(sessions.router, prefix="/api", tags=["Sessions"])
|
|
app.include_router(conversations.router, prefix="/api", tags=["Conversations"])
|
|
app.include_router(activities.router, prefix="/api", tags=["Activities"])
|
|
app.include_router(waiting.router, prefix="/api", tags=["Waiting Periods"])
|
|
app.include_router(git.router, prefix="/api", tags=["Git Operations"])
|
|
app.include_router(projects.router, prefix="/api", tags=["Projects"])
|
|
app.include_router(analytics.router, prefix="/api", tags=["Analytics"])
|
|
app.include_router(importer.router, prefix="/api", tags=["Data Import"])
|
|
app.include_router(tool_calls.router, prefix="/api", tags=["Tool Calls"])
|
|
|
|
# Include dashboard routes
|
|
app.include_router(dashboard_router, tags=["Dashboard"])
|
|
|
|
# Mount static files
|
|
app.mount("/static", StaticFiles(directory="app/dashboard/static"), name="static")
|
|
|
|
# Root redirect to dashboard
|
|
@app.get("/")
|
|
async def root():
|
|
"""Redirect root to dashboard."""
|
|
return RedirectResponse(url="/dashboard")
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint."""
|
|
return {"status": "healthy", "service": "claude-code-tracker"}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(
|
|
"main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True,
|
|
log_level="info"
|
|
) |