How repo.md Works
repo.md transforms GitHub repositories into comprehensive Markdown documents. This page delves into the technical details of its core functionality and its GitOps-driven automated deployment pipelines for both the web application (to Fly.io) and the iOS application (to TestFlight).
1. Core Web App Functionality (Runtime)
The primary function of repo.md is to take a public GitHub repository URL and generate a single Markdown document representing its structure and content. This process is handled by Go WASM (WebAssembly) which executes directly in the browser when a user interacts with the application.
- User Input: A user enters a GitHub repository URL into the input field on the repo.md homepage (
capacitor/src/index.html
).
- WASM Initialization: Upon page load, a Web Worker loads and initializes the Go WASM module (
main.wasm
):
- The worker first loads
wasm_exec.js
(provided by Go) to set up the WASM environment.
- Then it instantiates the compiled WASM module (
main.wasm
) which contains the Go code.
- The Go runtime starts in the worker thread, running independently from the main browser thread.
- GitHub API Processing (
wasm/main.go
):
- When the user submits a GitHub URL, the frontend JavaScript sends this to the WASM module via the worker.
- The Go code in the worker makes direct HTTP requests to the GitHub API to retrieve repository information.
- It fetches the repository structure and file contents using GitHub's REST API endpoints.
- All processing happens directly in the browser - no server-side processing is needed.
- Markdown Generation (
wasm/main.go
):
- The Go code parses the GitHub API responses and organizes the repository structure.
- It processes each file, checking content type and determining if it's binary or text.
- For each text file, the content is retrieved and embedded in Markdown code blocks.
- The process creates a single, comprehensive Markdown document that represents the entire repository.
- File size limits and binary detection are implemented to prevent memory issues.
- Response: The WASM module sends the generated Markdown back to the main thread via a callback function.
- Display: The frontend JavaScript populates a
<pre><code>
block with the received Markdown and enables the "Copy to Clipboard" and "Download .md" buttons.
- Client-side Execution: Since all processing happens in the browser via WASM, there's no need for server cleanup or temporary directories.
The following diagram shows the runtime process of how a GitHub repository URL is processed by the deployed repo.md web app to generate Markdown content:
flowchart TD
subgraph "Web App (Runtime)"
A["User opens repo.md website"] --> W["Go WASM initializes in browser"]
A --> B["User enters GitHub URL"]
B --> D["Frontend sends URL to WASM worker"]
D --> E["Go WASM code in worker"]
E -- "Makes direct API requests to GitHub" --> G["GitHub API"]
G -- "Returns repo structure & content" --> E
E -- "Processes data & generates Markdown" --> F["Markdown content ready"]
F -- "Sends Markdown back to main thread" --> D
D --> C["User views generated Markdown"]
end
style A fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style B fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style C fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style D fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style E fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style F fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style W fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style G fill:#2ea44f30,stroke:#2ea44f,strokeWidth:2px
2. Web App GitOps Deployment to Fly.io
The repo.md web application's deployment to Fly.io is managed via a GitOps workflow. Changes pushed to the main
branch automatically trigger a new build and deployment.
- Git Push: A developer pushes code changes (e.g., to Go code in
wasm/main.go
, or frontend files in capacitor/src/
) to the main
branch of the repo.md GitHub repository.
- GitHub Actions Trigger: This push automatically triggers the
.github/workflows/fly-deploy.yml
workflow.
- Workflow Execution:
- The repository code is checked out on an
ubuntu-latest
runner.
- The Fly.io CLI (
flyctl
) is set up.
flyctl deploy --remote-only
is executed. This command tells Fly.io to:
- Pull the latest code from the
main
branch.
- Build a new Docker image using the
Dockerfile
in the repository root. The Dockerfile
defines a multi-stage build process that:
- Compiles the Go WASM module from
wasm/main.go
using the Go compiler
- Builds and serves static frontend assets along with the compiled WASM file
- Deploy this new image to the Fly.io infrastructure as defined in
fly.toml
.
- Live Application: Once Fly.io successfully builds and deploys the new version, it becomes the live application accessible at repo-md.com.
This GitOps deployment pipeline is visualized below:
flowchart TD
subgraph "Web App GitOps Deployment"
A["Developer pushes code changes to Git"] -->|Triggers| B["GitHub Actions workflow starts (fly-deploy.yml)"]
B -- "GitHub Actions workflow instructs Fly.io to deploy" --> C["Fly.io processes deployment request"]
C -- "1. Compiles Go code to WASM" --> W["WebAssembly module built (main.wasm)"]
W -- "2. Combines with frontend assets" --> P["Complete static site package created"]
P -- "3. Deployed to Fly.io CDN" --> D["Updated website is live (repo-md.com)"]
end
style A fill:#0366d630,stroke:#0366d6,strokeWidth:2px
style B fill:#ff950030,stroke:#ff9500,strokeWidth:2px
style C fill:#6f42c130,stroke:#6f42c1,strokeWidth:2px
style W fill:#61dafb30,stroke:#61dafb,strokeWidth:2px
style P fill:#6f42c130,stroke:#6f42c1,strokeWidth:2px
style D fill:#2ea44f30,stroke:#2ea44f,strokeWidth:2px
3. iOS App GitOps Build & Deployment
The repo.md iOS application, a Capacitor-wrapped version of the web app, also follows a GitOps approach for builds and deployments to TestFlight, leveraging GitHub Actions and Fastlane.
3.1. Prerequisite: iOS Code Signing (ios-match-init.yml
)
Code signing is a critical part of iOS development. Fastlane Match is used to manage certificates and provisioning profiles, storing them securely in a separate private Git repository (bobbyhiddn/fastlane
). This setup is an example of "Infrastructure as Code."
- Manual Initialization: The
.github/workflows/ios-match-init.yml
workflow is run manually when new certificates are needed (e.g., initial setup, yearly renewal).
- Certificate Generation: This workflow securely generates and stores the necessary signing identities and provisioning profiles in the dedicated Match Git repository.
3.2. Automated iOS Deployment to TestFlight (ios.yml
)
Changes to the web application's codebase or manual triggers can initiate an automated build and deployment of the iOS app to TestFlight.
- Git Push / Manual Trigger:
- A push to the
main
branch (if relevant web app files like .html
, .js
, .css
, or .go
for potential WASM changes are modified) triggers the .github/workflows/ios.yml
workflow.
- Alternatively, the workflow can be dispatched manually with versioning options.
- GitHub Actions Workflow Execution (
ios.yml
):
- The workflow first checks if a build is necessary and if the Match repository is set up.
- Web Asset Build: The latest web application code from the
main
branch is built (e.g., using Vite via npm run build
).
- Capacitor Sync:
npx cap sync ios
integrates these fresh web assets into the native iOS project structure.
- Fastlane Execution: The
closed_beta
lane in capacitor/ios/App/fastlane/Fastfile
is executed. Fastlane handles:
- Fetching code signing assets from the Match Git repository.
- Incrementing app version and build numbers.
- Building the native iOS application (
.ipa
file).
- Uploading the
.ipa
to App Store Connect for TestFlight distribution.
- TestFlight Release: Once App Store Connect processes the build, it becomes available to testers via TestFlight.
This automated iOS build and deployment pipeline is shown below:
flowchart TD
subgraph "iOS App GitOps Build & Deployment"
A["Developer pushes code or starts iOS build manually"] -->|Triggers| B["GitHub Actions workflow for iOS build begins (ios.yml)"];
B -- "GitHub Actions workflow builds web parts,\nupdates iOS project,\n& runs Fastlane (iOS automation)" --> C["iOS App file created (.ipa)"];
C -- "Fastlane securely signs & uploads app package" --> D["App available to testers on TestFlight / App Store"];
end
style A fill:#0366d630,stroke:#0366d6,strokeWidth:2px
style B fill:#ff950030,stroke:#ff9500,strokeWidth:2px
style C fill:#34c75930,stroke:#34c759,strokeWidth:2px
style D fill:#34c75950,stroke:#34c759,strokeWidth:2px
Back to Home