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
The project follows a three-layered data architecture for processing GitHub data:
- Purpose: Stores raw data exactly as received from GitHub API
- Format: JSONB format preserving original API responses
- Tables:
bronze.github_events,bronze.github_users,bronze.github_repos - Characteristics:
- Zero processing - direct API response storage
- Complete data preservation for auditing and reprocessing
- Flexible schema that adapts to API changes
- Purpose: Processes, cleans, and normalizes raw data into structured relational tables
- Format: Traditional relational database tables with defined schemas
- Services: Dedicated services for each data type (
UsersSilverService,ReposSilverService, etc.) - Characteristics:
- Data extraction and transformation from raw JSON
- Normalization into separate, related tables
- Data validation and cleaning
- Optimized for queries and analysis
- Purpose: Aggregated and processed data ready for frontend consumption
- Format: Optimized tables for specific use cases
- Tables:
gold.user_profile,gold.repository,gold.user_activity - Characteristics:
- Pre-calculated metrics and aggregations
- User-friendly data structures
- Performance-optimized for API responses
GitHub API β Bronze Layer β Silver Layer β Gold Layer β Frontend
β β β β
Raw JSON β Normalized β Aggregated β API Response
- π 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 + Fastify
- Language: TypeScript
- Database: PostgreSQL via Neon cloud
- ORM: TypeORM (with migrations)
- Documentation: Swagger/OpenAPI
- Logging: Winston
- Node.js (v20 or higher)
- npm or yarn
- GitHub Personal Access Token
- PostgreSQL database (Neon account + connection string)
-
Clone the repository
git clone <repository-url> cd friends-activity-backend
-
Install dependencies
npm install
-
Set up environment variables
# Create .env file DATABASE_URL="postgres://appuser:STRONG_PASSWORD@YOURHOST.region.aws.neon.tech/appdb?sslmode=require" GITHUB_TOKEN=your_github_token_here
- Create a free account at Neon
- Create a project + database
- Copy the provided connection string into your .env file as DATABASE_URL
- Run migrations to initialize schemas:
npm run build
npm run migration:run- 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
.envfile
# Cross-platform
npm run dev
# Build the application
npm run build
# Start the production server
npm startThe server will start on http://localhost:3000 Swagger UI is available at http://localhost:3000/docs
npm run dev: Start development servernpm run build: Build for productionnpm start: Start production servernpm test: Run tests
We welcome contributions from the community! Please read CONTRIBUTING.md for the full workflow (branching, tests, and type-safety rules).
Quick highlights:
- TypeScript runs with
"strict": true+"noImplicitAny": true. - ESLint treats
@typescript-eslint/no-explicit-anyas an error.
- Fork the repository
- Open a new issue - make sure to provide a good subject and description to let others understand the content of that issue.
- Create a local branch:
git checkout -b issue-<issue number taken from #2>/short-descriptive-name - Make your changes
- Add tests if applicable
- Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin <your branch name> - Submit a pull request
Before merging a PR to main, all CI checks should pass (github actions).
To make sure CI will run on your branch, please follow the naming convention:
each branch name should look like issue-<issue number>/short-descriptive-name.
for example: issue-48/github-service-basic-utests
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