How filiksyos/gittodoc works
Project Type and Purpose
• This is a full-stack Python application with both a CLI tool (“gitingest”) and an HTTP server (“Gittodoc”) for converting Git repositories into documentation links consumable by AI coding tools.
• The CLI and server share a core ingestion library (“src/gitingest”), and the server uses FastAPI + Jinja2 + Tailwind CSS for its web front-end.
File-Structure Analysis
• Top-level entrypoints & config
• Dockerfile, docker-compose.yml, Heroku scripts (setup-heroku.sh, heroku-prebuild.sh)
• .env.example, runtime.txt, pyproject.toml, requirements.txt/dev
• Core library (src/gitingest)
• cli.py, entrypoint.py – CLI entrypoint & command definitions
• cloning.py, ingestion.py, cloud_uploader.py – pipeline stages
• query_parsing.py, output_formatters.py – transforming and formatting data
• schemas/ – JSON schemas for validation
• utils/ – shared helpers (git_utils, file_utils, timeout, exceptions, etc.)
• HTTP server (src/server)
• main.py – FastAPI app instantiation
• routers/ (index.py, dynamic.py) – HTTP routes/controllers
• query_processor.py – orchestrates ingestion & parsing on request
• templates/ + static/ – Jinja2 views and Tailwind CSS/JS assets
• Tests under tests/ validate both CLI and ingestion components.
Key Components
a. Entry Points
• CLI Tool (“gitingest”): runs locally, invokes ingestion pipeline, outputs a doc‐link or uploads via cloud_uploader.
• HTTP Server (“Gittodoc”): FastAPI app exposing a web UI and API endpoints.
b. Core Ingestion Library
• Git Cloning Service (cloning.py → uses git_utils)
• Ingestion Engine (ingestion.py → uses ingestion_utils, timeout_wrapper)
• Query Parser (query_parsing.py → query_parser_utils)
• Output Formatter (output_formatters.py)
• Cloud Uploader (cloud_uploader.py) – optional persistence to S3/GCS/etc.
• Configuration (config.py) & Schemas (filesystem_schema, ingestion_schema)
c. HTTP Server Layer
• FastAPI App (main.py)
• Routers/Controllers (routers/index, routers/dynamic)
• Query Processor Service (query_processor.py) orchestrates ingestion for web requests
• Templating Engine (Jinja2 templates + components)
• Static Assets (Tailwind CSS, JS utilities)
d. External Services
• Git Hosts (GitHub, GitLab, etc.)
• Cloud Storage (if using cloud_uploader)
• AI tools / tiktoken for token estimation (library dependency)
Relationships & Data Flow
• CLI Flow:
[CLI Entrypoint] → [Config] → [Cloning Service] → [Ingestion Engine] → [Query Parser] → [Output Formatter] → [Local STDOUT or Cloud Uploader]
• HTTP Flow:
Browser → HTTP Request → [FastAPI Router] → [Query Processor] → (same core ingestion pipeline modules) → [Render Jinja2 Template] + [Static Assets] → Browser
Architectural Patterns & Principles
• Layered Architecture:
• Presentation Layer (CLI or HTTP + Templates)
• Application Layer (CLI commands or FastAPI routers)
• Domain/Service Layer (ingestion, parsing, formatting)
• Infrastructure Layer (Git cloning, file I/O, cloud storage)
• Single-Source-of-Truth core library that is invoked by both CLI and server.
• MVC-like pattern in the server: Routers (Controllers) → Templates (Views) → Core Library (Model/Services).