Ryan Malloy 50c80596d0 Add comprehensive Docker deployment and file upload functionality
Features Added:
• Docker containerization with multi-stage Python 3.12 build
• Caddy reverse proxy integration with automatic SSL
• File upload interface for .claude.json imports with preview
• Comprehensive hook system with 39+ hook types across 9 categories
• Complete documentation system with Docker and import guides

Technical Improvements:
• Enhanced database models with hook tracking capabilities
• Robust file validation and error handling for uploads
• Production-ready Docker compose configuration
• Health checks and resource limits for containers
• Database initialization scripts for containerized deployments

Documentation:
• Docker Deployment Guide with troubleshooting
• Data Import Guide with step-by-step instructions
• Updated Getting Started guide with new features
• Enhanced documentation index with responsive grid layout

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 08:02:09 -06:00

94 lines
2.9 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, hooks
from app.dashboard.routes import dashboard_router
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan management."""
# Startup
print("Starting Claude Code Project Tracker...")
try:
await init_database()
print("Database initialized successfully!")
except Exception as e:
print(f"Database initialization failed: {e}")
print("Application will continue with limited functionality...")
yield
# Shutdown
print("Shutting down...")
try:
await close_database()
except Exception as e:
print(f"Error during shutdown: {e}")
# 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"])
app.include_router(hooks.router, prefix="/api", tags=["Hooks"])
# 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"
)