Initial commit: Claude Code Project Tracker
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>
This commit is contained in:
commit
44ed9936b7
48 changed files with 9707 additions and 0 deletions
7
app/database/__init__.py
Normal file
7
app/database/__init__.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"""
|
||||
Database connection and initialization for Claude Code Project Tracker.
|
||||
"""
|
||||
|
||||
from .connection import get_db, get_engine, init_database
|
||||
|
||||
__all__ = ["get_db", "get_engine", "init_database"]
|
||||
71
app/database/connection.py
Normal file
71
app/database/connection.py
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
"""
|
||||
Database connection management for the Claude Code Project Tracker.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import AsyncGenerator
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
# Database configuration
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///./data/tracker.db")
|
||||
|
||||
# Create async engine
|
||||
engine = create_async_engine(
|
||||
DATABASE_URL,
|
||||
echo=os.getenv("DEBUG", "false").lower() == "true", # Log SQL queries in debug mode
|
||||
connect_args={"check_same_thread": False} if "sqlite" in DATABASE_URL else {},
|
||||
poolclass=StaticPool if "sqlite" in DATABASE_URL else None,
|
||||
)
|
||||
|
||||
# Create session factory
|
||||
async_session_maker = async_sessionmaker(
|
||||
engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False
|
||||
)
|
||||
|
||||
|
||||
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
||||
"""
|
||||
Dependency function to get database session.
|
||||
|
||||
Used by FastAPI dependency injection to provide database sessions
|
||||
to route handlers.
|
||||
"""
|
||||
async with async_session_maker() as session:
|
||||
try:
|
||||
yield session
|
||||
except Exception:
|
||||
await session.rollback()
|
||||
raise
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
|
||||
def get_engine():
|
||||
"""Get the database engine."""
|
||||
return engine
|
||||
|
||||
|
||||
async def init_database():
|
||||
"""Initialize the database by creating all tables."""
|
||||
async with engine.begin() as conn:
|
||||
# Import all models to ensure they're registered
|
||||
from app.models import (
|
||||
Project, Session, Conversation, Activity,
|
||||
WaitingPeriod, GitOperation
|
||||
)
|
||||
|
||||
# Create all tables
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
print("Database initialized successfully!")
|
||||
|
||||
|
||||
async def close_database():
|
||||
"""Close database connections."""
|
||||
await engine.dispose()
|
||||
print("Database connections closed.")
|
||||
24
app/database/init_db.py
Normal file
24
app/database/init_db.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"""
|
||||
Database initialization script.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from app.database.connection import init_database
|
||||
|
||||
|
||||
async def main():
|
||||
"""Initialize the database."""
|
||||
# Ensure data directory exists
|
||||
data_dir = Path("data")
|
||||
data_dir.mkdir(exist_ok=True)
|
||||
|
||||
print("Initializing Claude Code Project Tracker database...")
|
||||
await init_database()
|
||||
print("Database initialization complete!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue