Files
GitMa/README.md
panw 44921c5646 feat: complete Git Repo Manager MVP implementation
Backend (Phase 1-6):
- Pydantic schemas for request/response validation
- Service layer (SSH Key, Server, Repo, Sync)
- API routes with authentication
- FastAPI main application with lifespan management
- ORM models (SshKey, Server, Repo, SyncLog)

Frontend (Phase 7):
- Vue 3 + Element Plus + Pinia + Vue Router
- API client with Axios and interceptors
- State management stores
- All page components (Dashboard, Servers, Repos, SyncLogs, SshKeys, Settings)

Deployment (Phase 8):
- README with quick start guide
- Startup script (start.sh)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 16:30:13 +08:00

6.4 KiB

Git Manager

A web-based management platform for Gitea server mirrors and SSH keys, providing centralized control over Git server synchronization and key management.

Features

  • SSH Key Management

    • Create, read, update, and delete SSH keys
    • AES-256 encryption for stored private keys
    • Secure key storage and retrieval
  • Server Management

    • Add and manage Gitea server configurations
    • Server health monitoring
    • Automatic synchronization support
  • Repository Synchronization

    • Mirror repositories from Gitea servers
    • Sync history and logging
    • Scheduled sync operations
  • Web Interface

    • Modern Vue.js-based frontend
    • Element Plus UI components
    • Real-time status monitoring
  • REST API

    • Full-featured REST API
    • Token-based authentication
    • OpenAPI documentation

Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • Git

Installation

  1. Clone the repository:
git clone <repository-url>
cd git
  1. Install backend dependencies:
cd backend
pip install -r requirements.txt
  1. Install frontend dependencies:
cd ../frontend
npm install

Initialization

  1. Create environment configuration:
cp .env.example .env
  1. Edit .env with your configuration:
# Generate a secure encryption key (32 bytes, base64 encoded)
python -c "import base64, os; print(base64.b64encode(os.urandom(32)).decode())"

# Generate a secure API token
python -c "import secrets; print(secrets.token_urlsafe(32))"
  1. Initialize the database:
cd backend
python init_db.py

Build and Run

Option 1: Using the start script (Linux/Mac)

./start.sh

Option 2: Manual startup

  1. Build the frontend:
cd frontend
npm run build
  1. Start the backend server:
cd ../backend
python -m app.main

Or using uvicorn directly:

cd backend
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
  1. Access the application:

API Documentation

Authentication

All API endpoints require authentication via the X-API-Token header:

curl -H "X-API-Token: your-api-token" http://localhost:8000/api/servers

Main Endpoints

Status

  • GET /api/status - Get system status

SSH Keys

  • GET /api/ssh-keys - List all SSH keys
  • POST /api/ssh-keys - Create a new SSH key
  • GET /api/ssh-keys/{key_id} - Get SSH key details
  • PUT /api/ssh-keys/{key_id} - Update SSH key
  • DELETE /api/ssh-keys/{key_id} - Delete SSH key

Servers

  • GET /api/servers - List all servers
  • POST /api/servers - Add a new server
  • GET /api/servers/{server_id} - Get server details
  • PUT /api/servers/{server_id} - Update server
  • DELETE /api/servers/{server_id} - Delete server
  • POST /api/servers/{server_id}/sync - Trigger server sync

For detailed API documentation, visit /api/docs when the server is running.

Development Setup

Backend Development

  1. Install development dependencies:
cd backend
pip install -r requirements.txt
  1. Run tests:
pytest
  1. Run with auto-reload:
uvicorn app.main:app --reload

Frontend Development

  1. Start development server:
cd frontend
npm run dev
  1. Build for production:
npm run build
  1. Preview production build:
npm run preview

Project Structure

git/
├── backend/                 # FastAPI backend
│   ├── app/
│   │   ├── api/            # API route handlers
│   │   ├── models/         # SQLAlchemy ORM models
│   │   ├── schemas/        # Pydantic schemas
│   │   ├── services/       # Business logic
│   │   ├── config.py       # Configuration management
│   │   ├── database.py     # Database connection
│   │   ├── security.py     # Encryption & auth
│   │   └── main.py         # FastAPI application
│   ├── tests/              # Backend tests
│   ├── init_db.py          # Database initialization script
│   └── requirements.txt    # Python dependencies
├── frontend/               # Vue.js frontend
│   ├── src/
│   │   ├── api/           # API client
│   │   ├── components/    # Vue components
│   │   ├── router/        # Vue Router config
│   │   ├── stores/        # Pinia stores
│   │   └── main.js        # App entry point
│   ├── package.json       # Node dependencies
│   └── vite.config.js     # Vite config
├── data/                  # Application data
│   ├── database.db        # SQLite database
│   ├── ssh-keys/          # Stored SSH keys
│   └── repos/             # Mirrored repositories
├── docs/                  # Documentation
├── tests/                 # Integration tests
├── .env.example           # Environment template
├── start.sh               # Startup script
└── README.md              # This file

Configuration

Configuration is managed through environment variables in the .env file:

Variable Description Default
GM_ENCRYPT_KEY AES-256 encryption key (base64) Required
GM_API_TOKEN API authentication token Required
GM_DATA_DIR Data directory path ./data
GM_HOST Server host 0.0.0.0
GM_PORT Server port 8000

Tech Stack

Backend

  • FastAPI - Modern, fast web framework
  • SQLAlchemy - ORM for database operations
  • Pydantic - Data validation using Python type annotations
  • Uvicorn - ASGI server
  • APScheduler - Task scheduling
  • Paramiko - SSH/SCP operations
  • GitPython - Git operations
  • Cryptography - AES-256 encryption

Frontend

  • Vue.js 3 - Progressive JavaScript framework
  • Vite - Build tool and dev server
  • Vue Router - Official router
  • Pinia - State management
  • Element Plus - Vue 3 UI library
  • Axios - HTTP client

Database

  • SQLite - Lightweight database (easily replaceable with PostgreSQL/MySQL)

Security

  • SSH private keys are encrypted using AES-256-GCM
  • API authentication via secure tokens
  • CORS support for cross-origin requests
  • Input validation and sanitization

License

[Your License Here]

Contributing

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