Skip to content

About

C#/.NET CLI for retrieving and displaying GitHub repository and activity data through the GitHub REST API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Git Activity Tracker

C# .NET GitHub API xUnit

A command-line application written in C# and .NET for retrieving and displaying GitHub repository and activity data through the GitHub REST API.

The project focuses on API integration, asynchronous HTTP communication, JSON processing, configuration management, and separation of application responsibilities.

Features

  • Retrieve repositories associated with the authenticated GitHub account
  • View recent public GitHub activity
  • Look up another user's public repositories and recent activity
  • Authenticate GitHub API requests using a personal access token
  • Dynamically construct GitHub API endpoints from usernames
  • Parse API responses using System.Text.Json
  • Display repository and event data through a console interface
  • Unit tests for URL generation and user interaction logic

Tech Stack

C# .NET 10 GitHub REST API HttpClient System.Text.Json xUnit DotNetEnv

How It Works

User selects operation
        |
        v
Dialogue / Request
        |
        v
Construct GitHub API endpoint
        |
        v
GitHubService
        |
        v
HTTP GET request
        |
        v
JSON response
        |
        v
Parse repository / event data
        |
        v
Console output

The application only requests the API resources required for the selected operation.

For example, requesting recent activity fetches the GitHub events endpoint without making an unnecessary repository request.

GitHub API Integration

GitHubService wraps communication with the GitHub REST API using HttpClient.

The client configures:

  • GitHub-compatible User-Agent
  • application/vnd.github+json response format
  • Optional Bearer-token authentication
  • HTTP status validation
  • Asynchronous JSON retrieval

Responses are converted into JsonDocument objects before being processed by the output layer.

Available Operations

The CLI currently supports three workflows:

Track authenticated repositories

Retrieves repository data associated with the configured authenticated-user endpoint.

Track recent public activity

Retrieves recent GitHub events and displays:

timestamp | event type | repository

Inspect another GitHub user

Given a username, the application builds GitHub API endpoints for that user's:

  • Public repositories
  • Public activity

and retrieves both resources asynchronously.

Architecture

The application separates user interaction, API communication, request representation, and output formatting.

ConsoleApp/
├── Program.cs
├── Dialogue.cs
├── Request.cs
├── Output.cs
│
├── Services/
│   └── GitHubService.cs
│
├── Helpers/
│   └── ParseUrl.cs
│
└── Models/
    ├── Repos.cs
    └── Events.cs

ConsoleApp.Tests/
└── UnitTest1.cs

Main Components

Component Responsibility
Program.cs Application orchestration and dependency setup
Dialogue.cs CLI interaction and operation selection
Request.cs Represents the requested API resources
GitHubService.cs HTTP communication with GitHub
ParseUrl.cs Builds user-specific GitHub API URLs
Output.cs Parses and renders API data
ConsoleApp.Tests Unit tests for core application behavior

Example Output

---------------
username's Repositories:
---------------
* repository-one
* repository-two

---------------
username's Recent Activities:
---------------
2026-01-01T12:30:00Z | PushEvent | username/repository-one
2026-01-01T10:15:00Z | CreateEvent | username/repository-two

Setup

1. Clone the repository

git clone https://github.com/jungwonenjoyericl/git_activity_tracker.git
cd git_activity_tracker

2. Restore dependencies

dotnet restore

3. Configure environment variables

Create a .env file and configure the GitHub API endpoints and token used by the application.

GITHUB_TOKEN=your_github_token

PRIVATE_URL=https://api.github.com/user/repos
MY_EVENTS_URL=https://api.github.com/users/YOUR_USERNAME/events

USER_URL=https://api.github.com/users/placeholder/repos
USER_EVENTS_URL=https://api.github.com/users/placeholder/events

placeholder is replaced with the username entered through the CLI.

4. Run

dotnet run --project ConsoleApp

Tests

The project contains xUnit tests covering:

  • Repository URL generation
  • Activity URL generation
  • CLI option handling
  • Construction of user-specific requests

Run the tests with:

dotnet test

Technical Focus

This project demonstrates practical use of:

  • REST API integration
  • Asynchronous programming with async / await
  • HttpClient
  • JSON parsing
  • HTTP authentication and request headers
  • Environment-based configuration
  • Separation of concerns
  • Dependency injection through constructors
  • Unit testing in .NET

About

C#/.NET CLI for retrieving and displaying GitHub repository and activity data through the GitHub REST API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages