Transform GitHub Gists into blog interfaces with caching and real-time updates.
- Dynamic Blog Generation: Convert any GitHub user's public gists into a blog-style interface
- Smart Caching: 4-hour cache with background refresh for optimal performance
- Real-time Search: Livewire-powered filtering by username and programming language
- Queue-based Updates: Background job processing for seamless user experience
- Responsive Design: Beautiful Tailwind CSS interface that works on all devices
- Backend: Laravel 12, PHP 8.4+
- Frontend: Blade templates, Livewire, Alpine.js, Tailwind CSS
- Database: PostgreSQL
- Cache: Redis
- Queue: Laravel queues with Redis driver
- API: GitHub REST API v3
- Local Development: Laravel Sail
- PHP 8.4 or higher
- Docker (for local Development)
- Composer
- Node.js & NPM
- PostgreSQL
- Redis (for production)
- GitHub Personal Access Token
git clone https://github.com/Braunson/github-gists-blog.git
cd github-gists-blog
composer install
npm installcp .env.example .env
php artisan key:generateUpdate your .env file:
# GitHub API Token (public access only needed)
GITHUB_TOKEN=your_github_personal_access_tokenphp artisan migrate# Build frontend assets
npm run build
# Start Laravel development server
php artisan serve
# In another terminal, start queue worker
php artisan queue:workVisit http://localhost to see the application.
- Ensure your code is committed and pushed
-
Connect Repository:
- Log into Laravel Cloud
- Create new project
- Connect your GitHub repository
-
Environment Variables: Configure these in Laravel Cloud environment:
GITHUB_TOKEN=your_github_token -
Database Configuration:
- Laravel Cloud provides PostgreSQL automatically
- Database credentials are auto-configured
-
Redis Configuration:
- Laravel Cloud provides Redis automatically
- Cache and session drivers are auto-configured
-
Queue Configuration:
- Laravel Cloud sets your queue connection as automatically (assuming you configured them ahead of time)
- Laravel Cloud will auto-start queue workers
- Set up push to deploy in Laravel Cloud or manually deploy in the Laravel Cloud UI.
# Run migrations on production with seeds (optional)
# NOTE: Laravel Cloud will automatically run this by default on a deploy excluding the seed flag unless you've modified the deployment commands from their default state
php artisan cloud:command "php artisan migrate --seed --force"
# Optional: Pre-populate a specific users on the fly instead of using the seeder
php artisan cloud:command "php artisan tinker --execute=\"app(\App\Services\GistService::class)->syncUserGists('taylorotwell');\""tests/
โโโ Feature/
โ โโโ BlogControllerTest.php # Route and controller tests
โ โโโ GistManagementTest.php # End-to-end gist operations
โ โโโ LivewireSearchTest.php # Livewire component tests
โโโ Unit/
โ โโโ GistServiceTest.php # GitHub API service tests
โ โโโ GistModelTest.php # Model methods and scopes
โ โโโ JobsTest.php # Queue job testing
โโโ Mocks/
โโโ GitHubApiResponses.php # Mock API responses
# Run all tests
php artisan test
# Run with coverage
php artisan test --coverage
# Run specific test suite
php artisan test --testsuite=Feature
php artisan test --testsuite=Unit
# Run specific test file
php artisan test tests/Feature/BlogControllerTest.phpGistServiceTest.php:
- โ Fetch user gists from GitHub API
- โ Handle API rate limiting and errors
- โ Parse gist data correctly
- โ Cache gist responses
- โ Sync individual gist content
GistModelTest.php:
- โ Model relationships and attributes
- โ Cache expiration logic
- โ Query scopes (forUsername, recent)
- โ Data casting and mutators
JobsTest.php:
- โ RefreshUserGists job execution
- โ Queue job retries and failures
- โ Background processing workflow
BlogControllerTest.php:
- โ Homepage displays recent gists and examples
- โ User blog page loads and caches gists
- โ Individual gist page displays content
- โ Handles non-existent users gracefully
- โ Queue dispatch for cache refresh
GistManagementTest.php:
- โ End-to-end gist fetching and storage
- โ Cache invalidation workflows
- โ Database transaction integrity
- โ API error handling
LivewireSearchTest.php:
- โ Real-time search functionality
- โ Language filtering
- โ Component state management
- โ DOM updates and interactions
GitHub API Mocking:
// Mock successful gist list response
Http::fake([
'api.github.com/users/*/gists' => Http::response($this->mockGistsList(), 200),
'api.github.com/gists/*' => Http::response($this->mockSingleGist(), 200),
]);# Use in-memory SQLite for speed
# Configured in phpunit.xml
# Test database migrations
php artisan test --testsuite=Feature tests/Feature/DatabaseTest.php# Test API response times
php artisan test tests/Performance/ApiPerformanceTest.php
# Test database query efficiency
php artisan test tests/Performance/DatabasePerformanceTest.php- Mock GitHub API responses for consistent testing
- Test rate limiting and error handling
- Verify data parsing and storage
- Test cache hits and misses
- Verify cache expiration logic
- Test background refresh jobs
- Test loading states for new users
- Verify search and filtering functionality
- Test responsive design elements
- Non-existent GitHub users
- API rate limiting scenarios
- Network connectivity issues
- Invalid gist data
# Static analysis with PHPStan
./vendor/bin/phpstan analyse- GitHub API Usage: Rate limiting and response times
- Database Performance: Query count and execution time
- Cache Hit Ratio: Redis performance and efficiency
- Queue Processing: Job completion rates and delays
- Built-in performance monitoring
- Database query analysis
- Queue job tracking
- Error logging and alerts
GitHub API Rate Limiting:
# Check current rate limit status
curl -H "Authorization: token YOUR_TOKEN" https://api.github.com/rate_limitQueue Jobs Not Processing:
# Restart queue workers
php artisan queue:restart
# Check failed jobs
php artisan queue:failedCache Issues:
# Clear application cache
php artisan cache:clear
# Clear config cache
php artisan config:clearGET /- Homepage with recent gists and examplesGET /{username}- User's gist blogGET /{username}/{gistId}- Individual gist view
- Fork the repository
- Create a feature branch
- Write tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is open-sourced software licensed under the MIT license.
- Ability to claim and customize your own blog page
- Ability to hide certain Gists
Built with โค๏ธ from ๐จ๐ฆ