Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

GitHub Clone & Backup System

A full-stack application that automatically backs up and mirrors your GitHub repositories with an exact GitHub UI replica. Built with React, FastAPI, SQLAlchemy, and PostgreSQL.

Features

Core Functionality

  • GitHub OAuth Integration - Seamlessly connect your GitHub account
  • Repository Mirroring - Full git clone --mirror for complete history preservation
  • Metadata Sync - Automatically sync issues, pull requests, and comments using GitHub API
  • Recurring Backups - Automatic sync every 6 hours (configurable)
  • Background Workers - Celery + Redis for long-running sync jobs

Frontend (React + Tailwind)

  • GitHub UI Replica - Pixel-perfect match of GitHub's dark theme
  • Dashboard - Repository listing with sync status
  • Repository Detail - File tree, README, branches, commits
  • Issues & PRs - Browse and filter with state filtering
  • Sync Monitoring - Track sync history and logs
  • Responsive Design - Mobile-friendly interface

Backend (FastAPI + SQLAlchemy)

  • RESTful API - Complete REST endpoints for all operations
  • SQLAlchemy ORM - Type-safe database models with JSONB fields
  • PostgreSQL - Robust relational database with JSON support
  • Celery Tasks - Async job processing for clones and syncs
  • JWT Authentication - Secure token-based auth

Architecture

github-clone-backup/
├── client/                    # React frontend
│   ├── src/
│   │   ├── pages/            # Page components
│   │   ├── components/       # Reusable UI components
│   │   ├── contexts/         # Auth context
│   │   ├── lib/
│   │   │   ├── api.ts        # API client
│   │   │   └── utils.ts      # Utilities
│   │   └── index.css         # GitHub dark theme
│   └── vite.config.ts
│
├── backend/                   # FastAPI backend
│   ├── app.py               # Main FastAPI app
│   ├── models.py            # SQLAlchemy models
│   ├── database.py          # DB configuration
│   ├── config.py            # Environment config
│   ├── celery_config.py     # Celery setup
│   ├── tasks.py             # Background tasks
│   ├── routes/              # API route handlers
│   │   ├── auth.py
│   │   ├── repositories.py
│   │   ├── issues.py
│   │   ├── prs.py
│   │   └── sync.py
│   └── requirements.txt
│
└── README.md

Technology Stack

Frontend

  • React 19 - UI framework
  • Vite - Build tool
  • Tailwind CSS 4 - Styling
  • Lucide React - Icons
  • shadcn/ui - Component library
  • Wouter - Routing

Backend

  • FastAPI - Web framework
  • SQLAlchemy - ORM
  • PostgreSQL - Database
  • Celery - Task queue
  • Redis - Message broker
  • GitPython - Git operations
  • httpx - Async HTTP client
  • PyJWT - Authentication

Setup & Deployment

Prerequisites

  • Node.js 18+
  • Python 3.9+
  • PostgreSQL 12+
  • Redis 6+

Local Development

  1. Frontend Setup
cd client
pnpm install
pnpm dev
  1. Backend Setup
cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Environment Variables Create .env in backend directory:
DATABASE_URL=postgresql://user:password@localhost:5432/github_backup
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
JWT_SECRET=your-secret-key
REDIS_URL=redis://localhost:6379/0
  1. Run Backend
python app.py
  1. Run Celery Worker (in another terminal)
celery -A celery_config worker --loglevel=info
  1. Run Celery Beat (for scheduled tasks)
celery -A celery_config beat --loglevel=info

Render Deployment

  1. Create PostgreSQL Database

    • Add PostgreSQL database in Render dashboard
    • Copy connection string to DATABASE_URL
  2. Create Redis Instance

    • Add Redis in Render dashboard
    • Copy connection string to REDIS_URL
  3. Deploy Backend

    • Connect GitHub repository
    • Set environment variables
    • Deploy with python app.py as start command
  4. Deploy Frontend

    • Build: pnpm build
    • Set VITE_API_URL to backend URL
    • Deploy to Render or Vercel

API Endpoints

Authentication

  • POST /api/auth/github/login - Get GitHub OAuth URL
  • GET /api/auth/callback - OAuth callback handler
  • GET /api/auth/me - Get current user
  • POST /api/auth/logout - Logout
  • POST /api/auth/refresh-token - Refresh JWT

Repositories

  • GET /api/repositories - List repositories
  • GET /api/repositories/{id} - Get repository details
  • POST /api/repositories/sync-from-github - Fetch from GitHub

Issues

  • GET /api/issues - List issues
  • GET /api/issues/{id} - Get issue details
  • GET /api/issues/repository/{repo_id} - Repository issues

Pull Requests

  • GET /api/pull-requests - List PRs
  • GET /api/pull-requests/{id} - Get PR details
  • GET /api/pull-requests/repository/{repo_id} - Repository PRs

Sync Management

  • GET /api/sync/status - Overall sync status
  • GET /api/sync/logs - Sync logs
  • POST /api/sync/repository/{repo_id}/trigger - Trigger sync
  • GET /api/sync/repository/{repo_id}/last-sync - Last sync info

Database Schema

Users

- id (PK)
- github_id (unique)
- github_username
- email
- name
- avatar_url
- access_token (encrypted)
- created_at
- updated_at
- last_synced_at

Repositories

- id (PK)
- user_id (FK)
- github_id (unique)
- name
- full_name
- description
- language
- stars, forks, watchers
- is_private
- clone_url
- local_path
- sync_status (enum)
- synced_at
- raw_data (JSONB)

Issues

- id (PK)
- repository_id (FK)
- github_id (unique)
- number
- title, body
- state
- author, author_id
- created_at, updated_at, closed_at
- raw_data (JSONB)

Pull Requests

- id (PK)
- repository_id (FK)
- github_id (unique)
- number
- title, body
- state
- author, author_id
- source_branch, target_branch
- created_at, updated_at, closed_at, merged_at
- raw_data (JSONB)

Sync Logs

- id (PK)
- user_id (FK)
- repository_id (FK)
- sync_type (clone|metadata|full)
- status (pending|in_progress|success|failed)
- started_at, completed_at
- duration_seconds
- items_processed, items_failed
- message

Background Tasks (Celery)

Periodic Tasks

  • sync_all_repositories - Every 6 hours
  • cleanup_old_sync_logs - Daily at 2 AM UTC

On-Demand Tasks

  • sync_repository_clone - Git mirror clone
  • sync_repository_metadata - Fetch issues/PRs

UI/UX Design

The frontend is a pixel-perfect replica of GitHub's dark theme:

  • Colors: GitHub's exact color palette (#0d1117, #1f6feb, #c9d1d9, etc.)
  • Typography: System fonts matching GitHub
  • Components: Buttons, cards, tabs matching GitHub's design
  • Interactions: Smooth transitions and hover states
  • Responsive: Mobile-first design with breakpoints

Security

  • JWT Authentication - Secure token-based auth
  • Encrypted Tokens - GitHub access tokens encrypted in database
  • HTTPS Only - All communications encrypted
  • CORS - Configured for frontend domain
  • SQL Injection Prevention - SQLAlchemy parameterized queries
  • Rate Limiting - GitHub API rate limit handling

Performance

  • Async Operations - Celery for non-blocking tasks
  • Database Indexing - Optimized queries
  • Caching - Redis for session management
  • Pagination - Efficient data retrieval
  • JSONB Fields - Flexible schema with full API payloads

Monitoring & Logging

  • Sync Logs - Complete history of all sync operations
  • Error Tracking - Failed syncs with error messages
  • Performance Metrics - Sync duration and item counts
  • User Activity - Last sync times and status

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - See LICENSE file for details

Support

For issues and questions:

Roadmap

  • Webhook support for real-time sync
  • Scheduled backups to cloud storage (S3, GCS)
  • Repository search and filtering
  • Contribution graph visualization
  • Release management
  • Wiki page backup
  • Discussions backup
  • Custom sync schedules per repository
  • Backup export/import
  • Team collaboration features

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages