Initial commit: Claude Code Monitor v1.0.0
Complete real-time monitoring dashboard for Claude Code Features: - FastAPI backend with REST API and WebSocket - React + TypeScript frontend with dark theme - SQLite database for event storage - 6 hook scripts for Claude Code events - Docker deployment setup - Real-time event tracking and statistics - Event filtering (ALL, TOOLS, AGENTS, PROMPTS, SESSIONS) - Connection status indicator - Reset stats functionality Tech Stack: - Backend: Python 3.11, FastAPI, SQLAlchemy, WebSockets - Frontend: React 18, TypeScript, Vite - Database: SQLite - Deployment: Docker, Docker Compose 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
50
backend/app/api/statistics.py
Normal file
50
backend/app/api/statistics.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""API endpoints for statistics."""
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from app.database import get_db
|
||||
from app.schemas import StatisticsResponse, ToolUsageResponse, SessionResponse
|
||||
from app.crud import get_statistics, get_tool_usage, get_sessions
|
||||
|
||||
router = APIRouter(prefix="/api/statistics", tags=["statistics"])
|
||||
|
||||
|
||||
@router.get("", response_model=StatisticsResponse)
|
||||
async def get_stats(db: Session = Depends(get_db)):
|
||||
"""
|
||||
Get current statistics.
|
||||
|
||||
Returns aggregated statistics including:
|
||||
- Total events count
|
||||
- Number of unique tools used
|
||||
- Number of agents spawned
|
||||
- Number of unique sessions
|
||||
- Last update timestamp
|
||||
"""
|
||||
stats = get_statistics(db)
|
||||
return stats
|
||||
|
||||
|
||||
@router.get("/tools", response_model=List[ToolUsageResponse])
|
||||
async def get_tool_stats(db: Session = Depends(get_db)):
|
||||
"""
|
||||
Get tool usage statistics.
|
||||
|
||||
Returns a list of all tools used with their usage counts and timestamps.
|
||||
Sorted by usage count (descending).
|
||||
"""
|
||||
tools = get_tool_usage(db)
|
||||
return tools
|
||||
|
||||
|
||||
@router.get("/sessions", response_model=List[SessionResponse])
|
||||
async def get_sessions_list(limit: int = 100, db: Session = Depends(get_db)):
|
||||
"""
|
||||
Get list of sessions.
|
||||
|
||||
Returns recent sessions with their metadata.
|
||||
"""
|
||||
sessions = get_sessions(db, limit=limit)
|
||||
return sessions
|
||||
Reference in New Issue
Block a user