Skip to content

ryanlinjui/git-repository-analysis-system

Repository files navigation

GitRepoScanner

logo

Git Repository Analysis System SvelteKit TypeScript Firebase Google Gemini

"AI-powered repository analysis tool that provides comprehensive insights into your codebase"

✨ Features

πŸ€– AI-Powered Repository Analysis

  • Paste any public GitHub/GitLab/Bitbucket URL and get instant AI insights
  • Analyzes tech stack, code quality, complexity, and skill level
  • Powered by Google Gemini

πŸ”— Share & Compare

  • Every scan gets a permanent shareable URL
  • No account needed to view results
  • Track your scan history with authentication

⚑ Smart & Fast

  • Real-time progress updates
  • Anonymous users get limited scans, authenticated users get more
  • Results include: project description, technologies used, quality score (0-100), and developer skill level assessment

πŸ“Š What You Get

  • Tech Stack Detection - Languages, frameworks, tools with confidence scores
  • Code Quality Score - 0-100 rating with specific improvement suggestions
  • Complexity Analysis - Understand what makes the project advanced
  • Skill Level - Beginner, Junior, Mid-level, or Senior classification
  • Project Structure - Tests, CI/CD, documentation quality assessment

πŸ› οΈ Technology Choices and Rationale

Frontend Stack

  • SvelteKit - Full-stack Framework
  • Svelte 5 - UI Framework with Runes
  • Tailwind CSS 4 - Utility-first Styling
  • Flowbite Svelte - UI Components
  • Lucide Svelte - Icon Library

Backend Stack

  • TypeScript - Type-safe Programming
  • SvelteKit Server - Backend Runtime
  • Node.js - JavaScript Runtime
  • Zod - Schema Validation & Type Safety

Database & Authentication

  • Firebase Firestore - NoSQL Database (User Data & Scans)
  • Firebase Authentication - Email/Password Auth

AI & Analysis

  • Google Gemini - AI Model for Code Analysis

Infrastructure & Deployment

  • Docker - Containerization
  • Docker Compose - Multi-container Orchestration
  • Cloudflare Tunnel (Cloudflared) - Secure Ingress without Open Ports
  • Cloudflare CDN/WAF - DDoS Protection & Edge Caching
  • GitHub Actions - CI/CD Pipeline
  • Ansible - Deployment Automation & Configuration Management

Monitoring & Observability

  • Grafana Loki - Log Aggregation
  • Promtail - Log Collection
  • Grafana - Metrics Visualization & Dashboards

πŸ—οΈ System Architecture

flowchart TB
    subgraph Internet["Internet"]
        Users[Users/Clients]
        GitHubActions[GitHub Actions Runner]
    end
    
    subgraph Cloudflare["Cloudflare Edge Network"]
        CDN[CDN/WAF/DDoS Protection]
        TunnelEdge[Cloudflare Tunnel Edge]
    end
    
    subgraph CICD["CI/CD Pipeline"]
        direction LR
        Build[Build Docker Image]
        Registry[GitHub Container<br/>Registry GHCR]
        Ansible[Ansible Playbook<br/>SSH Deployment]
    end
    
    subgraph DockerHost["Production VM Docker"]
        
        subgraph TunnelContainer["Cloudflared Container"]
            Tunnel[Cloudflare Tunnel]
        end
        
        subgraph AppContainer["App Container"]
            App[SvelteKit Application]
        end
        
        subgraph Monitoring["Monitoring"]
            Grafana[Grafana]
            Loki[Loki]
            Promtail[Promtail]
            Prometheus[Prometheus]
            NodeExporter[Node Exporter]
            CAdvisor[cAdvisor]
        end
        
        Network[Docker Network]
    end

    subgraph DataLayer["Data Layer"]
        Firestore[("Firebase Firestore")]
    end

    DataLayer ~~~ ExternalServices
    
    subgraph ExternalServices["External Services"]
        GitProviders["Git Repository Providers"]
        GeminiAI["Google Gemini"]
        GitProviders ~~~ GeminiAI
    end
    
    %% User Flow - HTTP Traffic
    Users -->|HTTPS request| CDN
    CDN --> TunnelEdge
    TunnelEdge -->|encrypted tunnel| Tunnel
    Tunnel --> App
    App --> Tunnel
    Tunnel -->|encrypted tunnel| TunnelEdge
    TunnelEdge --> CDN
    CDN -->|HTTPS response| Users
    
    %% CI/CD & Deployment Flow
    GitHubActions -->|Build & Push| Build
    Build --> Registry
    GitHubActions -->|Run Ansible| Ansible
    Ansible -->|SSH :22| VMHost
    VMHost -->|Pull| Registry
    VMHost -->|Deploy| DockerHost
    
    %% Database Flow
    App -->|read/write| Firestore
    
    %% External API Flows
    App -->|fetch metadata| GitProviders
    App -->|AI analysis| GeminiAI
    
    %% Monitoring Flow
    App -.->|logs| Promtail
    Tunnel -.->|logs| Promtail
    Promtail --> Loki
    Loki --> Grafana
    Prometheus --> Grafana
    NodeExporter -.-> Prometheus
    CAdvisor -.-> Prometheus
    
    %% Docker Network
    AppContainer -.-> Network
    TunnelContainer -.-> Network
    Monitoring -.-> Network
    
    style Internet fill:#e3f2fd
    style Cloudflare fill:#fff3e0
    style CICD fill:#ffebee
    style DockerHost fill:#c8e6c9
    style DataLayer fill:#f3e5f5
    style ExternalServices fill:#e8f5e9
Loading

πŸ“ Project Structure

git-repository-analysis-system/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── deploy.yml              # CI/CD: Build Docker image, push to GHCR, deploy via Ansible
β”‚
β”œβ”€β”€ ansible/                        # Deployment automation
β”‚   β”œβ”€β”€ deploy.yml                  # Ansible playbook: install Docker, pull image, docker compose
β”‚   β”œβ”€β”€ inventory.yml               # Target VM inventory
β”‚   └── README.md                   # Deployment setup guide
β”‚
β”œβ”€β”€ config/                        # Monitoring & logging configuration
β”‚   β”œβ”€β”€ grafana-datasources.yml    # Grafana data source configuration
β”‚   β”œβ”€β”€ loki-config.yml            # Loki log aggregation settings
β”‚   └── promtail-config.yml        # Promtail log collection settings
β”‚
β”œβ”€β”€ firebase/
β”‚   β”œβ”€β”€ firestore.indexes.json     # Firestore indexes
β”‚   └── firestore.rules            # Firestore security rules
β”‚
β”œβ”€β”€ scripts/
β”‚   └── scan-repo.ts               # CLI tool for testing scans
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ components/            # Reusable Svelte components
β”‚   β”‚   β”‚   β”œβ”€β”€ Auth.svelte        # Authentication UI
β”‚   β”‚   β”‚   β”œβ”€β”€ Avatar.svelte      # User avatar display
β”‚   β”‚   β”‚   β”œβ”€β”€ RateLimits.svelte  # Quota display
β”‚   β”‚   β”‚   β”œβ”€β”€ RepoSummary.svelte # Analysis results display
β”‚   β”‚   β”‚   β”œβ”€β”€ ScanArea.svelte    # URL input & submission
β”‚   β”‚   β”‚   β”œβ”€β”€ ScanProgress.svelte # Real-time progress display
β”‚   β”‚   β”‚   β”œβ”€β”€ ScanStatus.svelte  # Scan status indicator
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.svelte     # Navigation sidebar
β”‚   β”‚   β”‚   └── Welcome.svelte     # Welcome message
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ firebase/              # Firebase client SDK
β”‚   β”‚   β”‚   └── index.ts           # Firestore & Auth initialization
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ schema/                # Zod schemas & TypeScript types
β”‚   β”‚   β”‚   β”œβ”€β”€ repository.ts      # Repository & analysis types
β”‚   β”‚   β”‚   β”œβ”€β”€ scan.ts            # Scan status & error types
β”‚   β”‚   β”‚   β”œβ”€β”€ user.ts            # User & quota types
β”‚   β”‚   β”‚   └── utils.ts           # Schema utilities
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ server/                # Server-side logic
β”‚   β”‚   β”‚   β”œβ”€β”€ validate/          # Validation logic
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ quota.ts       # Rate limiting & quotas
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ url.ts         # URL validation & parsing
β”‚   β”‚   β”‚   β”‚   └── user.ts        # User validation
β”‚   β”‚   β”‚   β”œβ”€β”€ analyzer.ts        # Core analysis orchestration
β”‚   β”‚   β”‚   β”œβ”€β”€ constants.ts       # Server constants
β”‚   β”‚   β”‚   β”œβ”€β”€ dummy.ts           # Dummy data for testing
β”‚   β”‚   β”‚   β”œβ”€β”€ firebase.ts        # Firebase Admin SDK setup
β”‚   β”‚   β”‚   β”œβ”€β”€ git-utils.ts       # Git clone & metadata extraction
β”‚   β”‚   β”‚   β”œβ”€β”€ llm.ts             # Gemini AI integration
β”‚   β”‚   β”‚   β”œβ”€β”€ prompt.ts          # AI prompt generation
β”‚   β”‚   β”‚   β”œβ”€β”€ scan.ts            # Scan creation & background jobs
β”‚   β”‚   β”‚   └── scanInit.ts        # Scan initialization
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ stores/                # Svelte stores (state management)
β”‚   β”‚   β”‚   β”œβ”€β”€ anonymous.ts       # Anonymous user tracking
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts            # Auth state & user data
β”‚   β”‚   β”‚   β”œβ”€β”€ history.ts         # Scan history
β”‚   β”‚   β”‚   └── scan-status.ts     # Real-time scan tracking
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   └── date.ts            # Date formatting utilities
β”‚   β”‚   β”‚
β”‚   β”‚   └── scan-client.ts         # Client-side scan operations
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/                    # SvelteKit routes & pages
β”‚   β”‚   β”œβ”€β”€ api/                   # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ anonymous/
β”‚   β”‚   β”‚   β”‚   └── +server.ts     # Anonymous user tracking
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication endpoints
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ signin/
β”‚   β”‚   β”‚   β”‚   β”‚   └── +server.ts # Sign in endpoint
β”‚   β”‚   β”‚   β”‚   └── signout/
β”‚   β”‚   β”‚   β”‚       └── +server.ts # Sign out endpoint
β”‚   β”‚   β”‚   └── scan/
β”‚   β”‚   β”‚       └── +server.ts     # Scan submission endpoint
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ dashboard/[id]/
β”‚   β”‚   β”‚   β”œβ”€β”€ +page.server.ts    # Dashboard server load
β”‚   β”‚   β”‚   └── +page.svelte       # User dashboard page
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ scan/[id]/
β”‚   β”‚   β”‚   β”œβ”€β”€ +page.server.ts    # Scan server load
β”‚   β”‚   β”‚   └── +page.svelte       # Scan progress & results page
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ +layout.svelte         # Root layout with navigation
β”‚   β”‚   └── +page.svelte           # Home page with scan submission
β”‚   β”‚
β”‚   β”œβ”€β”€ app.css                    # Global styles
β”‚   β”œβ”€β”€ app.d.ts                   # TypeScript declarations
β”‚   β”œβ”€β”€ app.html                   # HTML template
β”‚   └── hooks.server.ts            # SvelteKit server hooks (auth)
β”‚
β”œβ”€β”€ static/                        # Static assets (empty)
β”‚
β”œβ”€β”€ .env                           # Environment variables (gitignored)
β”œβ”€β”€ .env.example                   # Environment variables template
β”œβ”€β”€ .gitignore                     # Git ignore rules
β”œβ”€β”€ .npmrc                         # npm configuration
β”œβ”€β”€ compose.yml                    # Docker Compose configuration
β”œβ”€β”€ Dockerfile                     # Application container image
β”œβ”€β”€ LICENSE                        # MIT License
β”œβ”€β”€ package.json                   # Dependencies & scripts
β”œβ”€β”€ pnpm-lock.yaml                # Lock file
β”œβ”€β”€ README.md                      # This file
β”œβ”€β”€ service-account-file.example.json # Firebase Admin credentials example
β”œβ”€β”€ service-account-file.json     # Firebase Admin credentials (gitignored)
β”œβ”€β”€ svelte.config.js              # SvelteKit configuration
β”œβ”€β”€ tsconfig.json                 # TypeScript configuration
└── vite.config.ts                # Vite build configuration

πŸ“₯ Setup Instructions

Prerequisites

  • Node.js 18+ and pnpm
  • Firebase project with Firestore and Authentication enabled
  • Google Gemini API key (from Google AI Studio)

Dev Environment Setup

git clone https://github.com/ryanlinjui/git-repository-analysis-system
cd git-repository-analysis-system
pnpm i
cp .env.example .env # remember to set variables

Firebase Setup

  1. Go to Firebase Console to create Firebase Project
  2. Create a new project
  3. Enable Firestore Database (start in production mode)
  4. Enable Authentication β†’ Email/Password sign-in method
  5. Copy rules from firebase/firestore.rules to Firebase Console.
  6. Get service-account-file.json in project root for admin auth.

Run Development Server

pnpm dev

Test Repository Scanning

Try scanning a repository:

https://github.com/google-gemini/gemini-cli

Or use dummy data for testing (no actual clone):

https://github.com/dummy/test-repo

πŸš€ Deployment Guide

Automated CI/CD Deployment (Recommended)

This project uses GitHub Actions + Ansible for automated deployment to your VM. Please refer [.env.example](.env.example) for required environment variables and configure GitHub Secrets

Manual Deployment (Local Development)

docker compose down
docker compose build
docker compose up -d

docker compose build --no-cache forces rebuild without cache if needed. Change compose.yml to include build: . under app service for local builds.

Check status

docker compose ps
docker compose logs -f app

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

GitRepoScanner: AI-powered repository analysis tool that provides comprehensive insights into your codebase.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages