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:
Ryan Malloy 2025-08-11 02:59:21 -06:00
commit 44ed9936b7
48 changed files with 9707 additions and 0 deletions

View file

@ -0,0 +1,346 @@
/* Claude Code Project Tracker Dashboard Styles */
:root {
--primary-color: #007bff;
--secondary-color: #6c757d;
--success-color: #28a745;
--info-color: #17a2b8;
--warning-color: #ffc107;
--danger-color: #dc3545;
--light-color: #f8f9fa;
--dark-color: #343a40;
}
/* Global Styles */
body {
background-color: #f5f5f5;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* Navigation */
.navbar-brand {
font-weight: 600;
}
.navbar-nav .nav-link {
font-weight: 500;
transition: color 0.3s ease;
}
.navbar-nav .nav-link:hover {
color: #fff !important;
}
/* Cards */
.card {
border: none;
border-radius: 0.75rem;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
transition: box-shadow 0.3s ease;
}
.card:hover {
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}
.card-header {
background-color: transparent;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
font-weight: 600;
}
/* Status Cards */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning,
.card.bg-danger {
border: none;
}
.card.bg-primary .card-body,
.card.bg-success .card-body,
.card.bg-info .card-body,
.card.bg-warning .card-body,
.card.bg-danger .card-body {
padding: 1.5rem;
}
/* Charts */
.chart-container {
position: relative;
height: 300px;
width: 100%;
}
/* Tables */
.table {
margin-bottom: 0;
}
.table th {
border-top: none;
font-weight: 600;
color: var(--dark-color);
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.table td {
vertical-align: middle;
font-size: 0.9rem;
}
/* Badges */
.badge {
font-size: 0.75rem;
font-weight: 500;
}
/* Project List */
.project-item {
border-left: 4px solid var(--primary-color);
background-color: #fff;
border-radius: 0.5rem;
padding: 1rem;
margin-bottom: 0.75rem;
transition: all 0.3s ease;
}
.project-item:hover {
transform: translateX(5px);
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}
.project-title {
font-weight: 600;
color: var(--dark-color);
margin-bottom: 0.25rem;
}
.project-path {
color: var(--secondary-color);
font-size: 0.875rem;
font-family: 'Courier New', monospace;
}
.project-stats {
font-size: 0.8rem;
color: var(--secondary-color);
}
/* Activity Timeline */
.activity-timeline {
position: relative;
}
.activity-timeline::before {
content: '';
position: absolute;
left: 20px;
top: 0;
bottom: 0;
width: 2px;
background-color: var(--light-color);
}
.timeline-item {
position: relative;
padding-left: 50px;
margin-bottom: 1.5rem;
}
.timeline-marker {
position: absolute;
left: 12px;
top: 4px;
width: 16px;
height: 16px;
border-radius: 50%;
background-color: var(--primary-color);
border: 3px solid #fff;
box-shadow: 0 0 0 2px var(--primary-color);
}
.timeline-content {
background-color: #fff;
border-radius: 0.5rem;
padding: 1rem;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}
/* Engagement Indicators */
.engagement-indicator {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 0.5rem;
}
.engagement-high {
background-color: var(--success-color);
}
.engagement-medium {
background-color: var(--warning-color);
}
.engagement-low {
background-color: var(--danger-color);
}
/* Loading States */
.loading-skeleton {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: loading 1.5s infinite;
}
@keyframes loading {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
/* Responsive Design */
@media (max-width: 768px) {
.card-body {
padding: 1rem;
}
.project-item {
margin-bottom: 0.5rem;
}
.display-4 {
font-size: 2rem;
}
}
/* Search and Filter */
.search-box {
border-radius: 50px;
border: 2px solid var(--light-color);
transition: border-color 0.3s ease;
}
.search-box:focus {
border-color: var(--primary-color);
box-shadow: none;
}
/* Custom Scrollbar */
.custom-scrollbar {
scrollbar-width: thin;
scrollbar-color: var(--secondary-color) var(--light-color);
}
.custom-scrollbar::-webkit-scrollbar {
width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: var(--light-color);
border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: var(--secondary-color);
border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--dark-color);
}
/* Tool Icons */
.tool-icon {
width: 24px;
height: 24px;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 4px;
margin-right: 0.5rem;
font-size: 0.875rem;
}
.tool-icon.tool-edit {
background-color: rgba(40, 167, 69, 0.1);
color: var(--success-color);
}
.tool-icon.tool-write {
background-color: rgba(0, 123, 255, 0.1);
color: var(--primary-color);
}
.tool-icon.tool-read {
background-color: rgba(23, 162, 184, 0.1);
color: var(--info-color);
}
.tool-icon.tool-bash {
background-color: rgba(108, 117, 125, 0.1);
color: var(--secondary-color);
}
/* Animation Classes */
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.slide-in-right {
animation: slideInRight 0.5s ease-out;
}
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(50px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* Footer */
footer {
margin-top: auto;
border-top: 1px solid rgba(0, 0, 0, 0.125);
}
/* Print Styles */
@media print {
.navbar,
.btn,
footer {
display: none !important;
}
.card {
box-shadow: none !important;
border: 1px solid #ddd !important;
}
body {
background-color: white !important;
}
}

View file

@ -0,0 +1,251 @@
/**
* API Client for Claude Code Project Tracker
*/
class ApiClient {
constructor(baseUrl = '') {
this.baseUrl = baseUrl;
}
async request(endpoint, options = {}) {
const url = `${this.baseUrl}/api${endpoint}`;
const config = {
headers: {
'Content-Type': 'application/json',
...options.headers
},
...options
};
try {
const response = await fetch(url, config);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error(`API request failed: ${endpoint}`, error);
throw error;
}
}
// Projects API
async getProjects(limit = 50, offset = 0) {
return this.request(`/projects?limit=${limit}&offset=${offset}`);
}
async getProject(projectId) {
return this.request(`/projects/${projectId}`);
}
async getProjectTimeline(projectId, startDate = null, endDate = null) {
let url = `/projects/${projectId}/timeline`;
const params = new URLSearchParams();
if (startDate) params.append('start_date', startDate);
if (endDate) params.append('end_date', endDate);
if (params.toString()) {
url += `?${params.toString()}`;
}
return this.request(url);
}
async getProjectStats(projectId, days = 30) {
return this.request(`/projects/${projectId}/stats?days=${days}`);
}
// Analytics API
async getProductivityMetrics(projectId = null, days = 30) {
let url = `/analytics/productivity?days=${days}`;
if (projectId) {
url += `&project_id=${projectId}`;
}
return this.request(url);
}
async getDevelopmentPatterns(projectId = null, days = 30) {
let url = `/analytics/patterns?days=${days}`;
if (projectId) {
url += `&project_id=${projectId}`;
}
return this.request(url);
}
async getLearningInsights(projectId = null, days = 30) {
let url = `/analytics/learning?days=${days}`;
if (projectId) {
url += `&project_id=${projectId}`;
}
return this.request(url);
}
async getAnalyticsSummary(projectId = null) {
let url = '/analytics/summary';
if (projectId) {
url += `?project_id=${projectId}`;
}
return this.request(url);
}
// Conversations API
async searchConversations(query, projectId = null, limit = 20) {
let url = `/conversations/search?query=${encodeURIComponent(query)}&limit=${limit}`;
if (projectId) {
url += `&project_id=${projectId}`;
}
return this.request(url);
}
async getConversation(conversationId) {
return this.request(`/conversations/${conversationId}`);
}
// Activities API
async getActivities(sessionId = null, toolName = null, limit = 50, offset = 0) {
let url = `/activities?limit=${limit}&offset=${offset}`;
if (sessionId) url += `&session_id=${sessionId}`;
if (toolName) url += `&tool_name=${toolName}`;
return this.request(url);
}
async getToolUsageStats(sessionId = null, projectId = null, days = 30) {
let url = `/activities/stats/tools?days=${days}`;
if (sessionId) url += `&session_id=${sessionId}`;
if (projectId) url += `&project_id=${projectId}`;
return this.request(url);
}
async getLanguageUsageStats(projectId = null, days = 30) {
let url = `/activities/stats/languages?days=${days}`;
if (projectId) url += `&project_id=${projectId}`;
return this.request(url);
}
// Waiting Periods API
async getWaitingPeriods(sessionId = null, projectId = null, limit = 50, offset = 0) {
let url = `/waiting/periods?limit=${limit}&offset=${offset}`;
if (sessionId) url += `&session_id=${sessionId}`;
if (projectId) url += `&project_id=${projectId}`;
return this.request(url);
}
async getEngagementStats(sessionId = null, projectId = null, days = 7) {
let url = `/waiting/stats/engagement?days=${days}`;
if (sessionId) url += `&session_id=${sessionId}`;
if (projectId) url += `&project_id=${projectId}`;
return this.request(url);
}
// Git Operations API
async getGitOperations(sessionId = null, projectId = null, operation = null, limit = 50, offset = 0) {
let url = `/git/operations?limit=${limit}&offset=${offset}`;
if (sessionId) url += `&session_id=${sessionId}`;
if (projectId) url += `&project_id=${projectId}`;
if (operation) url += `&operation=${operation}`;
return this.request(url);
}
async getCommitStats(projectId = null, days = 30) {
let url = `/git/stats/commits?days=${days}`;
if (projectId) url += `&project_id=${projectId}`;
return this.request(url);
}
async getGitActivityStats(projectId = null, days = 30) {
let url = `/git/stats/activity?days=${days}`;
if (projectId) url += `&project_id=${projectId}`;
return this.request(url);
}
// Sessions API
async getSession(sessionId) {
return this.request(`/sessions/${sessionId}`);
}
// Health check
async healthCheck() {
return this.request('/../health');
}
}
// Create global API client instance
const apiClient = new ApiClient();
// Utility functions for common operations
const ApiUtils = {
formatDuration: (minutes) => {
if (minutes < 60) {
return `${minutes}m`;
}
const hours = Math.floor(minutes / 60);
const remainingMinutes = minutes % 60;
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
},
formatDate: (dateString) => {
const date = new Date(dateString);
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit'
});
},
formatRelativeTime: (dateString) => {
const date = new Date(dateString);
const now = new Date();
const diffMs = now - date;
const diffMinutes = Math.floor(diffMs / (1000 * 60));
const diffHours = Math.floor(diffMinutes / 60);
const diffDays = Math.floor(diffHours / 24);
if (diffMinutes < 1) return 'just now';
if (diffMinutes < 60) return `${diffMinutes}m ago`;
if (diffHours < 24) return `${diffHours}h ago`;
if (diffDays < 7) return `${diffDays}d ago`;
return date.toLocaleDateString();
},
getToolIcon: (toolName) => {
const icons = {
'Edit': 'fas fa-edit',
'Write': 'fas fa-file-alt',
'Read': 'fas fa-eye',
'Bash': 'fas fa-terminal',
'Grep': 'fas fa-search',
'Glob': 'fas fa-folder-open',
'Task': 'fas fa-cogs',
'WebFetch': 'fas fa-globe'
};
return icons[toolName] || 'fas fa-tool';
},
getToolColor: (toolName) => {
const colors = {
'Edit': 'success',
'Write': 'primary',
'Read': 'info',
'Bash': 'secondary',
'Grep': 'warning',
'Glob': 'info',
'Task': 'dark',
'WebFetch': 'primary'
};
return colors[toolName] || 'secondary';
},
getEngagementBadge: (score) => {
if (score >= 0.8) return { class: 'success', text: 'High' };
if (score >= 0.5) return { class: 'warning', text: 'Medium' };
return { class: 'danger', text: 'Low' };
},
truncateText: (text, maxLength = 100) => {
if (!text || text.length <= maxLength) return text;
return text.substring(0, maxLength) + '...';
}
};

View file

@ -0,0 +1,327 @@
/**
* Dashboard JavaScript functionality
*/
let productivityChart = null;
let toolsChart = null;
async function loadDashboardData() {
try {
// Show loading state
showLoadingState();
// Load data in parallel
const [
analyticsSummary,
productivityMetrics,
toolUsageStats,
recentProjects
] = await Promise.all([
apiClient.getAnalyticsSummary(),
apiClient.getProductivityMetrics(null, 30),
apiClient.getToolUsageStats(null, null, 30),
apiClient.getProjects(5, 0)
]);
// Update summary cards
updateSummaryCards(analyticsSummary);
// Update engagement metrics
updateEngagementMetrics(productivityMetrics);
// Update charts
updateProductivityChart(productivityMetrics.productivity_trends);
updateToolsChart(toolUsageStats);
// Update recent projects
updateRecentProjects(recentProjects);
// Update quick stats
updateQuickStats(analyticsSummary);
} catch (error) {
console.error('Failed to load dashboard data:', error);
showErrorState('Failed to load dashboard data. Please try refreshing the page.');
}
}
function showLoadingState() {
// Update cards with loading state
document.getElementById('total-sessions').textContent = '-';
document.getElementById('total-time').textContent = '-';
document.getElementById('active-projects').textContent = '-';
document.getElementById('productivity-score').textContent = '-';
}
function showErrorState(message) {
// Show error message
const alertHtml = `
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<i class="fas fa-exclamation-triangle me-2"></i>
${message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
`;
const container = document.querySelector('.container');
container.insertAdjacentHTML('afterbegin', alertHtml);
}
function updateSummaryCards(summary) {
const overview = summary.overview || {};
document.getElementById('total-sessions').textContent =
overview.total_sessions?.toLocaleString() || '0';
document.getElementById('total-time').textContent =
overview.total_time_hours?.toFixed(1) || '0';
document.getElementById('active-projects').textContent =
overview.projects_tracked?.toLocaleString() || '0';
document.getElementById('productivity-score').textContent =
overview.productivity_indicators?.productivity_score?.toFixed(0) || '0';
}
function updateEngagementMetrics(metrics) {
document.getElementById('engagement-score').textContent =
metrics.engagement_score?.toFixed(0) || '-';
document.getElementById('avg-session-length').textContent =
metrics.average_session_length?.toFixed(0) || '-';
document.getElementById('think-time').textContent =
metrics.think_time_average?.toFixed(0) || '-';
}
function updateProductivityChart(trendsData) {
const ctx = document.getElementById('productivityChart').getContext('2d');
// Destroy existing chart
if (productivityChart) {
productivityChart.destroy();
}
const labels = trendsData.map(item => {
const date = new Date(item.date);
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
});
const data = trendsData.map(item => item.score);
productivityChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Productivity Score',
data: data,
borderColor: '#007bff',
backgroundColor: 'rgba(0, 123, 255, 0.1)',
borderWidth: 2,
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
}
},
scales: {
y: {
beginAtZero: true,
max: 100,
ticks: {
callback: function(value) {
return value + '%';
}
}
},
x: {
ticks: {
maxTicksLimit: 7
}
}
}
}
});
}
function updateToolsChart(toolsData) {
const ctx = document.getElementById('toolsChart').getContext('2d');
// Destroy existing chart
if (toolsChart) {
toolsChart.destroy();
}
// Get top 5 tools
const topTools = toolsData.slice(0, 5);
const labels = topTools.map(item => item.tool_name);
const data = topTools.map(item => item.usage_count);
const colors = [
'#007bff', '#28a745', '#17a2b8', '#ffc107', '#dc3545'
];
toolsChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: colors,
borderWidth: 2,
borderColor: '#fff'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'bottom',
labels: {
padding: 20,
usePointStyle: true
}
}
}
}
});
}
function updateRecentProjects(projects) {
const container = document.getElementById('recent-projects');
if (!projects.length) {
container.innerHTML = `
<div class="text-center text-muted py-4">
<i class="fas fa-folder-open fa-2x mb-2"></i>
<p>No projects found</p>
</div>
`;
return;
}
const projectsHtml = projects.map(project => `
<div class="project-item fade-in">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="project-title">${project.name}</div>
<div class="project-path">${project.path}</div>
<div class="project-stats mt-2">
<span class="me-3">
<i class="fas fa-clock me-1"></i>
${ApiUtils.formatDuration(project.total_time_minutes)}
</span>
<span class="me-3">
<i class="fas fa-play-circle me-1"></i>
${project.total_sessions} sessions
</span>
${project.languages ? `
<span>
<i class="fas fa-code me-1"></i>
${project.languages.slice(0, 2).join(', ')}
</span>
` : ''}
</div>
</div>
<small class="text-muted">
${ApiUtils.formatRelativeTime(project.last_activity)}
</small>
</div>
</div>
`).join('');
container.innerHTML = projectsHtml;
}
function updateQuickStats(summary) {
const container = document.getElementById('quick-stats');
const recent = summary.recent_activity || {};
const statsHtml = `
<div class="row g-3">
<div class="col-sm-6">
<div class="d-flex align-items-center">
<div class="flex-shrink-0">
<i class="fas fa-calendar-week fa-2x text-primary"></i>
</div>
<div class="flex-grow-1 ms-3">
<div class="fw-bold">${recent.sessions_last_7_days || 0}</div>
<small class="text-muted">Sessions this week</small>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="d-flex align-items-center">
<div class="flex-shrink-0">
<i class="fas fa-clock fa-2x text-success"></i>
</div>
<div class="flex-grow-1 ms-3">
<div class="fw-bold">${(recent.time_last_7_days_hours || 0).toFixed(1)}h</div>
<small class="text-muted">Time this week</small>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="d-flex align-items-center">
<div class="flex-shrink-0">
<i class="fas fa-chart-line fa-2x text-info"></i>
</div>
<div class="flex-grow-1 ms-3">
<div class="fw-bold">${(recent.daily_average_last_week || 0).toFixed(1)}</div>
<small class="text-muted">Daily average</small>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="d-flex align-items-center">
<div class="flex-shrink-0">
<i class="fas fa-fire fa-2x text-warning"></i>
</div>
<div class="flex-grow-1 ms-3">
<div class="fw-bold">${summary.overview?.tracking_period_days || 0}</div>
<small class="text-muted">Days tracked</small>
</div>
</div>
</div>
</div>
`;
container.innerHTML = statsHtml;
}
function refreshDashboard() {
// Add visual feedback
const refreshBtn = document.querySelector('[onclick="refreshDashboard()"]');
const icon = refreshBtn.querySelector('i');
icon.classList.add('fa-spin');
refreshBtn.disabled = true;
loadDashboardData().finally(() => {
icon.classList.remove('fa-spin');
refreshBtn.disabled = false;
});
}
// Auto-refresh dashboard every 5 minutes
setInterval(() => {
loadDashboardData();
}, 5 * 60 * 1000);
// Handle window resize for charts
window.addEventListener('resize', () => {
if (productivityChart) {
productivityChart.resize();
}
if (toolsChart) {
toolsChart.resize();
}
});