A service that analyzes GitHub repository changes, providing insights into code contributions by different users within a specified time range. The service uses goroutines for concurrent processing to enhance performance.
.
├── LICENSE
├── development-container
│ ├── docker-compose.yml
│ └── Dockerfile
├── config
│ └── config.go
├── go.mod
├── go.sum
├── internal
│ ├── di
│ │ └── di.go
│ ├── handlers
│ │ └── analysishandler
│ │ └── analysishandler.go
│ ├── models
│ │ └── models.go
│ ├── repos
│ │ └── githubrepository
│ │ └── githubrepository.go
│ ├── server
│ │ └── server.go
│ └── services
│ └── analyzerservice
│ └── analyzerservice.go
└── main.go
- config: Manages application configuration, including GitHub token and server port settings
- di: Handles dependency injection, wiring up all components
- handlers: Contains HTTP request handlers that process incoming API requests
- models: Defines data structures used throughout the application
- repos: Implements data access layer, specifically GitHub API interactions
- server: Sets up the HTTP server and routing using Gin framework
- services: Contains business logic for analyzing repository changes
- Golang
- Gin web framework
- Environment variable configuration
Can either install directly or through Docker
- Clone repository:
git clone https://github.com/brianwu291/repo-changes-analyzer.git
- Install dependencies:
go mod download
- Set up environment variables:
export GITHUB_TOKEN=your_github_token_here
export PORT=8088 # optional, default is 8080
or using .env
file. The dotenv pkg will auto load the env values
- Run the service:
$ go run main.go
or$ air
for hot reload (need install air first)
- Go to
/development-container
folder - Run the whole application:
docker compose up --build
(This includeair
command, so hot-reload supported)
Analyzes the code changes in a GitHub repository within a specified time range.
Endpoint: POST /api/analyze
Request Headers:
Content-Type: application/json
Request Body:
{
"owner": "string", // github repo owner
"repo": "string", // repo name
"start_date": "string", // start date in YYYY-MM-DD format
"end_date": "string" // end date in YYYY-MM-DD format
}
Success Response (200 OK):
{
"repository": "owner/repo",
"time_range": "start_date to end_date",
"user_changes": {
"${username}": {
"username": "xxxxx",
"additions": 10,
"deletions": 2,
"total": 12,
"commit_count": 6,
"avatar_url": "https://avatars.githubusercontent.com/u/xxxxxxx"
}
// ... more users
}
}
Error Response (400 Bad Request):
{
"repository": "",
"time_range": "",
"user_changes": null,
"error": "error message describing what went wrong"
}
curl -X POST http://localhost:8080/api/analyze \
-H "Content-Type: application/json" \
-d '{
"owner": "brianwu291",
"repo": "repo-changes-analyzer",
"start_date": "2025-01-01",
"end_date": "2025-01-31"
}'
- concurrent processing of commits using goroutines
- rate limiting to respect GitHub API limits
- CORS support for web clients
Feel free to open issues or submit pull requests for improvements.
This project is licensed under the MIT License - see the LICENSE file for details.