Skip to content

landim32/GitNews

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitNews - AI-Powered Blog Generator from GitHub Repositories

.NET PostgreSQL OpenAI License

Overview

GitNews is an automated blog article generator that analyzes commits from GitHub repositories, identifies technical novelties (new packages, design patterns, architectural changes), and generates detailed articles using OpenAI's GPT-4. Articles are stored in PostgreSQL with pgvector embeddings to prevent duplicate content. Built with .NET 8 following Clean Architecture.

Available as a one-shot CLI tool or a scheduled background worker that runs daily.


πŸš€ Features

  • πŸ” Automatic Repository Scanning - Lists and processes all repositories from a GitHub account
  • πŸ€– AI-Powered Article Generation - Uses GPT-4 to analyze commit diffs and generate technical blog posts
  • 🧠 Embedding-Based Deduplication - Generates vector embeddings to detect and skip similar articles
  • πŸ“Š Smart Commit Filtering - Tracks processed commits in PostgreSQL to avoid reprocessing
  • πŸ†• New Project Detection - Projects with ≀3 commits get a project description; others focus on technical novelties
  • ⏰ Scheduled Worker - Background service that runs daily at a configurable time
  • 🐳 Docker Ready - Full Docker Compose setup with PostgreSQL and the Worker service

πŸ› οΈ Technologies Used

Core Framework

  • .NET 8 - Target framework for all projects

Database

  • PostgreSQL 16 - Primary data store with pgvector extension
  • Entity Framework Core 8 - ORM with Code First migrations
  • Pgvector - Vector similarity search for article deduplication

External APIs

  • Octokit 13 - GitHub API client for repository and commit data
  • OpenAI API - GPT-4 for article generation, text-embedding-3-small for embeddings

DevOps

  • Docker / Docker Compose - Containerized deployment
  • GitVersion - Semantic versioning from commit messages
  • GitHub Actions - Automated tagging and release creation

πŸ“ Project Structure

GitNews/
β”œβ”€β”€ GitNews.DTO/                  # Data Transfer Objects, settings classes
β”œβ”€β”€ GitNews.Infra.Interfaces/     # Repository & AppService interfaces (generics)
β”‚   β”œβ”€β”€ AppServices/              # IGitHubAppService, IBlogGeneratorAppService, IEmbeddingAppService
β”‚   └── Repository/               # IProcessedCommitRepository, IArticleRepository
β”œβ”€β”€ GitNews.Domain/               # Entity models, service interfaces & implementations
β”‚   β”œβ”€β”€ Interfaces/               # IGitNewsProcessorService
β”‚   β”œβ”€β”€ Models/                   # Article, ProcessedCommit
β”‚   └── Services/                 # GitNewsProcessorService (orchestration)
β”œβ”€β”€ GitNews.Infra/                # Infrastructure implementations
β”‚   β”œβ”€β”€ AppServices/              # GitHubAppService, BlogGeneratorAppService, EmbeddingAppService
β”‚   β”œβ”€β”€ Context/                  # GitNewsDbContext, design-time factory
β”‚   β”œβ”€β”€ Migrations/               # EF Core migrations
β”‚   └── Repository/               # ProcessedCommitRepository, ArticleRepository
β”œβ”€β”€ GitNews.Application/          # DI composition root (Startup.cs)
β”œβ”€β”€ GitNews.Console/              # CLI entry point (one-shot execution)
β”œβ”€β”€ GitNews.Worker/               # Background worker (scheduled daily)
β”œβ”€β”€ docker-compose.yml            # PostgreSQL + Worker services
β”œβ”€β”€ .env.example                  # Environment variable template
└── CLAUDE.md                     # AI assistant instructions

Architecture

GitNews.Console  ─┐
GitNews.Worker   ──→ GitNews.Application β†’ GitNews.Infra       β†’ GitNews.Domain
                  β”‚                       β†’ GitNews.DTO
                  β”‚                       β†’ GitNews.Infra.Interfaces β†’ GitNews.DTO

βš™οΈ Environment Configuration

1. Copy the environment template

cp .env.example .env

2. Edit the .env file

POSTGRES_DB=gitnews
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_secure_password_here
POSTGRES_PORT=5432

GITHUB_TOKEN=your_github_token_here
GITHUB_OWNER=your_github_username
GITHUB_MAXCOMMITS=30
GITHUB_INCLUDEFORKS=false

OPENAI_APIKEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4
OPENAI_BASEURL=https://api.openai.com/v1

WORKER_SCHEDULETIME=19:00

⚠️ IMPORTANT:

  • Never commit the .env file with real credentials
  • You need a GitHub Personal Access Token with repo scope
  • You need an OpenAI API Key with access to GPT-4 and embeddings

🐳 Docker Setup

Quick Start with Docker Compose

1. Configure environment

cp .env.example .env
# Edit .env with your credentials

2. Build and Start Services

docker-compose up -d --build

This starts:

  • PostgreSQL 16 with pgvector on port 5432
  • GitNews Worker scheduled to run daily at the configured time

3. Verify Deployment

docker-compose ps
docker-compose logs -f worker

Docker Compose Commands

Action Command
Start services docker-compose up -d
Start with rebuild docker-compose up -d --build
Stop services docker-compose stop
View status docker-compose ps
View worker logs docker-compose logs -f worker
Remove containers docker-compose down
Remove containers and volumes (⚠️) docker-compose down -v

πŸ”§ Manual Setup (Without Docker)

Prerequisites

Setup Steps

1. Start PostgreSQL (via Docker or local install)

docker-compose up -d postgres

2. Configure the application

cp GitNews.Console/appsettings.example.json GitNews.Console/appsettings.json
# Edit appsettings.json with your credentials

3. Build the solution

dotnet build

4. Run the Console app (one-shot)

dotnet run --project GitNews.Console

Or with CLI arguments:

dotnet run --project GitNews.Console -- \
  --owner your-github-username \
  --github-token ghp_xxx \
  --openai-key sk-xxx \
  --connection-string "Host=localhost;Port=5432;Database=gitnews;Username=postgres;Password=postgres"

5. Run the Worker (scheduled)

cp GitNews.Worker/appsettings.example.json GitNews.Worker/appsettings.json
# Edit appsettings.json
dotnet run --project GitNews.Worker

CLI Options

Option Description Default
-o, --owner GitHub account owner β€”
--github-token GitHub access token β€”
--openai-key OpenAI API key β€”
-m, --model ChatGPT model gpt-4
--max-commits Max commits per repo 30
--include-forks Include forked repositories false
--connection-string PostgreSQL connection string β€”
-h, --help Show help β€”

Environment Variables

All settings can be configured via environment variables using the ASP.NET Core __ convention:

Variable Description
GitHub__Token GitHub access token
GitHub__Owner Account owner
OpenAI__ApiKey OpenAI API key
OpenAI__Model ChatGPT model
Database__ConnectionString PostgreSQL connection string

πŸ“š Data Flow

1. GitHub API        β†’ List all repositories for an owner
2. For each repo     β†’ Fetch README, commit count, recent commits with diffs
3. PostgreSQL        β†’ Filter out already-processed commits
4. OpenAI GPT-4      β†’ Analyze diffs, generate article (title, content, category, tags)
5. OpenAI Embeddings β†’ Generate vector embedding for the article
6. pgvector          β†’ Check similarity against existing articles (skip duplicates)
7. PostgreSQL        β†’ Save article and mark commits as processed

πŸ’Ύ Database

Tables

  • articles - Generated blog articles with pgvector embedding column (1536 dimensions)
  • processed_commits - Tracks processed commits with unique index on (repository, sha)

Migrations

Migrations are auto-applied on startup. To create a new migration:

dotnet ef migrations add <MigrationName> \
  --project GitNews.Infra \
  --startup-project GitNews.Console

Backup

docker-compose exec postgres pg_dump -U postgres gitnews > backup.sql

Restore

docker-compose exec -T postgres psql -U postgres gitnews < backup.sql

πŸ”„ CI/CD

GitHub Actions

Version and Tag (version-tag.yml):

  • Triggers on push to main
  • Uses GitVersion for semantic versioning based on commit messages
  • Creates and pushes Git tags automatically

Create Release (create-release.yml):

  • Triggers after successful tagging
  • Creates GitHub Releases for major/minor changes
  • Generates changelog from commit messages

Commit Message Conventions

Prefix Version Bump
major: or breaking: Major (x.0.0)
feat: or feature: Minor (0.x.0)
fix: or patch: Patch (0.0.x)

πŸ” Troubleshooting

Common Issues

Database connection failed

Check:

docker-compose ps postgres
docker-compose logs postgres

Common causes:

  • PostgreSQL container not running
  • Wrong connection string or port
  • pgvector extension not installed

GitHub API rate limit

Common causes:

  • Too many repositories being processed
  • Token without proper permissions

Solutions:

  • Reduce MaxCommits setting
  • Use a token with repo scope
  • The app has built-in retry with exponential backoff for rate limits

OpenAI API errors

Common causes:

  • Invalid API key
  • Insufficient credits
  • Model not available

Solutions:

  • Verify API key at platform.openai.com
  • Check billing and usage limits
  • Try a different model (e.g., gpt-3.5-turbo)

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Make your changes
  4. Build and verify (dotnet build)
  5. Commit your changes (git commit -m 'feat: add some AmazingFeature')
  6. Push to the branch (git push origin feature/AmazingFeature)
  7. Open a Pull Request

πŸ‘¨β€πŸ’» Author

Developed by Rodrigo Landim Carneiro


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments


πŸ“ž Support


⭐ If you find this project useful, please consider giving it a star!

About

GitHub News Auto Update

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors