Add comprehensive development intelligence system that tracks: - Development sessions with automatic start/stop - Full conversation history with semantic search - Tool usage and file operation analytics - Think time and engagement analysis - Git activity correlation - Learning pattern recognition - Productivity insights and metrics Features: - FastAPI backend with SQLite database - Modern web dashboard with interactive charts - Claude Code hook integration for automatic tracking - Comprehensive test suite with 100+ tests - Complete API documentation (OpenAPI/Swagger) - Privacy-first design with local data storage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
81 lines
2.3 KiB
Python
81 lines
2.3 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
|
|
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"])
|
|
|
|
# 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"
|
|
) |