This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This repository contains a web-based service for analyzing git repository code activity and statistics. It's a multi-user web service with REST API and database storage for tracking development metrics over time.
- Record important discussion keypoints and agreement with claude code into a markdown file in doc folder (create different files for different topics)
- Uses git's native commands for data extraction and diff analysis
- Backend: FastAPI-based REST API with SQLAlchemy ORM
- Database: SQLite (development) with migration path to PostgreSQL/MySQL
- Authentication: JWT-based user authentication
- Data Model: Day-based atomic storage with user/author separation
- Analysis Engine: Adapted existing git analysis logic for web service
- Analyze code activity over configurable time periods
- Daily breakdown of development statistics
- Track commits, lines added/deleted, files changed, and net activity
- Handle edge cases like empty repositories and initial commits
- Multi-branch analysis: Analyzes all branches by default with automatic deduplication
- Rebase detection: Uses git patch-id to track commits across rebases
- Commit deduplication: Ensures commits appearing in multiple branches are counted only once
- Multi-user support with JWT authentication
- Repository management (add, update, delete repositories)
- Git analysis integration with job tracking
- Statistics API (single-repo and cross-repo with flexible filtering)
- Author tracking separate from system users
- Manual AI coder flagging capability
- Day-based atomic storage for flexible aggregation
- Database migration system for schema evolution
- RESTful API with automatic Swagger documentation
- Users: System users who access the web interface
- Authors: Git commit authors (separate from users)
- Repositories: Git repositories managed by users
- DailyAuthorStats: Atomic daily statistics per author per repository
- Day-based atomic storage - only daily author stats are stored
- All period/aggregated statistics are calculated from daily data at query time
- Clear separation between system users and git authors
- Manual AI coder flagging (no automatic detection)
- Database schema versioning with migration support
- Avoid storing computed fields (net_change, code_activities) to prevent data redundancy
- Date-indexed API responses for frontend time-series visualization
- Author ID references only in responses, frontend fetches author details separately
the venv of this project is at .venv sub-folder
or use uv run python xxx to run python scripts
Virtual environment is at .venv directory of the workspace usually you don't need to start development server, if you have, ask to confirm
# Install dependencies and start development server
uv sync
uv run uvicorn backend.app.main:app --reload --port 8002
- Backend: FastAPI + SQLAlchemy + SQLite + JWT authentication
- Frontend: Vue 3 + TypeScript + Tailwind CSS 4 + Chart.js + Vite
- Integration: FastAPI serves Vue SPA with API routes prefixed with
/api/
- Authentication: User registration and login with JWT tokens
- Repository Management: Add, view, analyze, and delete Git repositories
- Statistics Dashboard: Interactive charts and visualizations of commit activity
- Real-time Analysis: Trigger Git analysis and view results immediately
- Responsive Design: Modern, clean UI that works on desktop and mobile
refer to docs/api-endpoints.md
- Use FastAPI with SQLAlchemy for new API endpoints
- Follow day-based storage pattern - avoid storing aggregated or computed data
- Use migration system for all database schema changes
- Maintain user/author separation in data model
- Write Pydantic schemas for request/response validation
- Design APIs with date-indexed responses for frontend charting
- Return minimal data references (e.g. author_id) to avoid response bloat
- Support flexible filtering (repo scope, AI coder exclusion, date ranges)
refer to docs/database-migration-guides.md
When implementing any significant module changes, feature additions, or architectural modifications, you MUST create and maintain documentation in the docs/plan/ directory.
- Create Planning Document: Before starting any major modification, create a detailed plan document in
docs/plan/[feature-name]-plan.md - Document Progress: Update the plan document with progress status as work progresses
- Maintain Both Tracking Systems: Use both in-memory todo lists AND persistent documentation
# [Feature/Change Name] Plan
## Overview
Brief description of the change and its purpose
## Current Problem Analysis
Detailed analysis of what needs to be changed and why
## Strategy and Approach
How the change will be implemented
## Implementation Steps
Detailed breakdown of tasks with priorities and status
## Timeline
Expected completion dates for each phase
## Risk Assessment
Potential risks and mitigation strategies
## Success Criteria
How to measure successful completion
## Progress Tracking
Real-time status updates (✅ ✓ ⏳ ❌)
## Related Files
List of all files that will be modified- New feature implementations
- Architectural refactoring (like removing v1 dependencies)
- Database schema changes
- API version migrations
- Security enhancements
- Performance optimizations
- Major bug fixes that affect multiple components
- Update progress markers in real-time as tasks complete
- Record any deviation from original plan with reasoning
- Document lessons learned and implementation notes
- Keep status current for team visibility
This ensures that all major work is properly tracked, documented, and can be resumed by anyone on the team.