A NestJS-based backend service that analyzes GitHub user activity to assess open source contributions, engagement, and project involvement. This service is part of the broader Maakaf Home initiative - the website for Maakaf, an Israeli open source community.
This service provides detailed analysis of GitHub user activity over the past 6 months, including:
- Commits: Code contributions to repositories
- Pull Requests: Feature contributions and bug fixes
- Issues: Problem reporting and feature requests
- Comments: Engagement on PRs and issues
- π Activity Analysis: Tracks commits, PRs, issues, and comments from the last 6 months
- π Repository Filtering: Only analyzes repositories with more than 3 forks (indicating community interest)
- π― User-Specific Data: Filters activity by specific GitHub usernames
- π Comprehensive Logging: Winston-based logging with file output
- π API Documentation: Swagger/OpenAPI documentation
- β Input Validation: Class-validator based request validation
- Framework: NestJS
- Language: TypeScript
- API: GitHub GraphQL API
- Documentation: Swagger/OpenAPI
- Logging: Winston
- Validation: class-validator
- Node.js (v16 or higher)
- npm or yarn
- GitHub Personal Access Token
- MongoDB instance (local or cloud)
-
Clone the repository
git clone <repository-url> cd maakaf_home_backend
-
Install dependencies
npm install
-
Set up environment variables
# Create .env file echo "GITHUB_TOKEN=your_github_token_here" > .env echo "MONGODB_URI=<your_mongo_connection_string" >> .env
- Install MongoDB locally or use Docker:
# Using Docker docker run -d -p 27017:27017 --name mongodb mongo:latest # Or install locally following MongoDB installation guide
- Create a free account at MongoDB Atlas
- Create a new cluster
- Get your connection string and replace
<password>
with your database user password - Use the connection string as your
MONGODB_URI
- Go to GitHub Settings > Developer settings > Personal access tokens
- Generate a new token with the following scopes:
public_repo
(for public repository access)read:user
(for user information)
- Copy the token and add it to your
.env
file
# Unix/Linux/macOS
npm run start:dev:unix
# Windows
npm run start:dev:win
# Cross-platform
npm run start:dev
# Build the application
npm run build
# Start the production server
npm start
The server will start on http://localhost:3000
Once the server is running, you can access the Swagger documentation at:
- Swagger UI: http://localhost:3000/api
Analyzes GitHub activity for the provided usernames.
Request Body:
{
"usernames": ["octocat", "torvalds", "your-username"]
}
Response:
[
{
"username": "octocat",
"repos": [
{
"repoName": "Hello-World",
"description": "My first repository on GitHub!",
"url": "https://github.com/octocat/Hello-World",
"commits": 5,
"pullRequests": 2,
"issues": 1,
"prComments": 3,
"issueComments": 2
}
],
"summary": {
"totalCommits": 5,
"totalPRs": 2,
"totalIssues": 1,
"totalPRComments": 3,
"totalIssueComments": 2
}
}
]
The API returns appropriate error responses:
400 Bad Request
: Missing or invalid GitHub token500 Internal Server Error
: GitHub API errors or processing failures
The service uses GitHub's GraphQL API which has rate limits:
- Authenticated requests: 5,000 requests per hour
- Unauthenticated requests: 60 requests per hour
The service includes error handling for rate limit exceeded scenarios.
Logs are written to logs/app.log
with the following levels:
debug
: Detailed GraphQL responses and processing informationwarn
: Repository processing errorserror
: User processing errors and API failures
src/
βββ main.ts # Application entry point
βββ github.controller.ts # API endpoints
βββ github-activity.service.ts # GitHub API integration
βββ github.dto.ts # Request/response DTOs
βββ logger.ts # Winston logger configuration
npm run start:dev
: Start development servernpm run build
: Build for productionnpm start
: Start production servernpm test
: Run tests (not implemented yet)
We welcome contributions from the community! Please see our CONTRIBUTING.md file for guidelines on:
- Documentation: Improving README, API docs, or code comments
- Bug Fixes: Reporting and fixing issues
- Feature Suggestions: Proposing new features or improvements
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature
- Make your changes
- Add tests if applicable
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature/your-feature
- Submit a pull request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
For questions, issues, or contributions:
- Open an issue on GitHub
- Contact the Maakaf community through maakaf.com
- Built with NestJS
- Powered by GitHub GraphQL API
- Part of the Maakaf open source community initiative