A Rust-based service that tracks and analyzes GitHub repository star metrics over time. This project provides a robust API to fetch, store, and analyze star data for any GitHub repository.
- 🌟 Track GitHub repository stars with timestamps
- 📊 Analyze daily star count trends
- 🚀 High-performance Rust implementation
- 🗄️ PostgreSQL database for reliable data storage
- 🔄 Automatic pagination handling for large repositories
- 🔒 Secure GitHub token-based authentication
- Rust (latest stable version)
- Docker and Docker Compose
- A GitHub Personal Access Token with repo scope
.
├── projects/
│ └── databases/ # Main database service
├── interfaces/
│ └── github/
│ └── stargazers/ # GitHub API integration
├── utils/
│ └── trace/ # Logging and tracing utilities
└── scripts/
└── database/ # Database management scripts-
Clone the repository:
git clone https://github.com/alexandre-fiotti/rust_demo.git cd rust_demo -
Create a
.envfile in theprojects/databasesdirectory with the following content:DATABASE_URL=postgresql://rustuser:password@localhost:5432/stargazer GITHUB_TOKEN=your_github_token_here
-
Start the PostgreSQL database:
./scripts/database/run_postgres.sh
# Start PostgreSQL container
./scripts/database/run_postgres.sh
# Stop PostgreSQL container
./scripts/database/stop_postgres.shConnect to the database for manual inspection:
docker exec -it postgres_db psql -U rustuser -d stargazer\dt -- List all tables
\d TABLE -- Describe table
\q -- Exit psqlThis project uses Diesel for database management. First, install the Diesel CLI:
cargo install diesel_cli --no-default-features --features postgresNavigate to the databases project:
cd projects/databasesRun the migrations:
diesel migration runOther useful Diesel commands:
diesel migration revert # Undo the last migration
diesel migration redo # Redo the last migration
diesel migration list # List all migrations
diesel print-schema # Print the current schema.rsIf you need to completely reset the database during development:
-
First, clean the database:
DROP SCHEMA public CASCADE; CREATE SCHEMA public;
-
Then, rerun all migrations:
cd projects/databases diesel migration run
This will give you a clean slate with the proper schema for development.
POST /github/repo_stars/update
Content-Type: application/json
{
"owner": "repository_owner",
"name": "repository_name"
}POST /github/repo_stars/read_per_day
Content-Type: application/json
{
"owner": "repository_owner",
"name": "repository_name"
}-
Build the project:
cargo build
-
Run the service:
cargo run -p projects_databases
The service will start on http://0.0.0.0:8000.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Alexandre Fiotti