# filiksyos/gitreverse architecture

> Architecture diagram of the GitHub repository filiksyos/gitreverse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/filiksyos/gitreverse
- Repository: https://github.com/filiksyos/gitreverse

## Overview

GitReverse turns public GitHub repositories and live websites into coding-agent prompts, then makes cached prompts discoverable and supports user history, accounts, and paid plans. The primary flow starts at the home or shareable repository page, submits a repository, gathers GitHub context, and generates a prompt. A parallel website flow gathers site evidence, generates both a design system and prompt, and caches them. The graph also includes library search, authentication/history, and billing. Some links rely on README statements or SOURCE INDEX references; unsampled implementations are not inferred beyond those references.

Main entry points: [`app/api/reverse-prompt/route.ts`](https://github.com/filiksyos/gitreverse/blob/main/app/api/reverse-prompt/route.ts) (Repository prompt API), [`lib/website-reverse-engine.ts`](https://github.com/filiksyos/gitreverse/blob/main/lib/website-reverse-engine.ts) (Website reverse engine), [`lib/library-query.ts`](https://github.com/filiksyos/gitreverse/blob/main/lib/library-query.ts) (Library search and ranking), [`contexts/AuthContext.tsx`](https://github.com/filiksyos/gitreverse/blob/main/contexts/AuthContext.tsx) (Authentication state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prompt_generation["Prompt generation"]
  node_home_ui["Reverse prompt UI"]
  node_repo_page["Shareable repo page<br/>[page.tsx]"]
  node_repo_api["Repository prompt API<br/>[route.ts]"]
  node_repo_parser["Repo input parser"]
  node_github_context["GitHub context fetch<br/>[github-client.ts]"]
  node_prompt_format["Tree and prompt formatting"]
  node_quick_llm["Quick LLM<br/>[quick-llm.ts]"]
  node_website_ui["Website reverse UI"]
  node_website_api["Website reverse API<br/>[route.ts]"]
  node_website_parser["Website input parser"]
  node_website_engine["Website reverse engine"]
  node_website_scraper["Website evidence gathering<br/>[website-scraper.ts]"]
  node_website_prompts["Website prompt builders"]
  node_website_cache[("Website prompt cache")]
end

subgraph group_library["Prompt library"]
  node_library_page["Library page<br/>[page.tsx]"]
  node_library_ui["Library browsing UI<br/>[library-page.tsx]"]
  node_library_query["Library search and ranking<br/>[library-query.ts]"]
  node_embeddings["Search embeddings<br/>[embeddings.ts]"]
  node_library_api["Library search API<br/>[route.ts]"]
end

subgraph group_accounts["Accounts and history"]
  node_auth_context["Authentication state<br/>[AuthContext.tsx]"]
  node_supabase_auth["Supabase auth client<br/>[supabase-auth.ts]"]
  node_history_ui["History page<br/>[history-page.tsx]"]
  node_history_api["History API<br/>[route.ts]"]
  node_history_store["User history<br/>[user-history.ts]"]
end

subgraph group_billing["Billing and sponsorship"]
  node_billing_ui["Account and plan UI<br/>[navbar.tsx]"]
  node_checkout_api["Checkout routes<br/>[route.ts]"]
  node_credit_verify["Credit purchase verification<br/>[route.ts]"]
  node_subscriber["Billing status<br/>[subscriber.ts]"]
  node_sponsor_page["Sponsor page<br/>[partner-page.tsx]"]
  node_sponsorship["Sponsorship analytics"]
end

node_visitor(("Visitor"))
node_llm_provider["LLM providers"]
node_supabase[("Supabase")]
node_stripe["Stripe"]

node_visitor -->|"enters"| node_home_ui
node_visitor -->|"opens"| node_repo_page
node_home_ui -->|"requests prompt"| node_repo_api
node_repo_page -->|"renders"| node_home_ui
node_repo_api -->|"parses input"| node_repo_parser
node_repo_api -->|"fetches context"| node_github_context
node_repo_api -->|"formats tree"| node_prompt_format
node_repo_api -.->|"generates prompt"| node_quick_llm
node_quick_llm -.->|"calls provider"| node_llm_provider
node_visitor -->|"submits site"| node_website_ui
node_website_ui -->|"requests reverse"| node_website_api
node_website_api -->|"validates URL"| node_website_parser
node_website_api -->|"runs reverse"| node_website_engine
node_website_engine -->|"gathers evidence"| node_website_scraper
node_website_engine -->|"builds prompts"| node_website_prompts
node_website_engine -->|"generates results"| node_quick_llm
node_website_engine -->|"reads and writes"| node_website_cache
node_website_cache -->|"stores cache"| node_supabase
node_visitor -->|"browses"| node_library_page
node_library_page -->|"fetches initial entries"| node_library_query
node_library_page -->|"renders"| node_library_ui
node_library_ui -.->|"searches"| node_library_api
node_library_api -->|"queries entries"| node_library_query
node_library_query -->|"embeds search"| node_embeddings
node_library_query -.->|"searches cache"| node_supabase
node_visitor -->|"signs in"| node_auth_context
node_auth_context -->|"uses auth client"| node_supabase_auth
node_visitor -->|"views history"| node_history_ui
node_history_ui -->|"loads history"| node_history_store
node_history_ui -->|"reads session"| node_auth_context
node_history_api -->|"manages history"| node_history_store
node_history_store -.->|"syncs history"| node_supabase
node_billing_ui -->|"reads account"| node_auth_context
node_billing_ui -.->|"starts checkout"| node_checkout_api
node_checkout_api -.->|"creates session"| node_stripe
node_credit_verify -->|"verifies payment"| node_stripe
node_credit_verify -->|"loads billing status"| node_subscriber
node_credit_verify -->|"records credits"| node_supabase
node_visitor -->|"visits sponsorship"| node_sponsor_page
node_sponsor_page -->|"records analytics"| node_sponsorship

click node_home_ui "https://github.com/filiksyos/gitreverse/blob/main/components/reverse-prompt-home.tsx"
click node_repo_page "https://github.com/filiksyos/gitreverse/blob/main/app/%5Bowner%5D/%5Brepo%5D/page.tsx"
click node_repo_api "https://github.com/filiksyos/gitreverse/blob/main/app/api/reverse-prompt/route.ts"
click node_repo_parser "https://github.com/filiksyos/gitreverse/blob/main/lib/parse-github-repo.ts"
click node_github_context "https://github.com/filiksyos/gitreverse/blob/main/lib/github-client.ts"
click node_prompt_format "https://github.com/filiksyos/gitreverse/blob/main/lib/file-tree-formatter.ts"
click node_quick_llm "https://github.com/filiksyos/gitreverse/blob/main/lib/quick-llm.ts"
click node_website_ui "https://github.com/filiksyos/gitreverse/blob/main/components/website-reverse-page.tsx"
click node_website_api "https://github.com/filiksyos/gitreverse/blob/main/app/api/reverse-website/route.ts"
click node_website_parser "https://github.com/filiksyos/gitreverse/blob/main/lib/parse-website-input.ts"
click node_website_engine "https://github.com/filiksyos/gitreverse/blob/main/lib/website-reverse-engine.ts"
click node_website_scraper "https://github.com/filiksyos/gitreverse/blob/main/lib/website-scraper.ts"
click node_website_prompts "https://github.com/filiksyos/gitreverse/blob/main/lib/website-design-system-prompt.ts"
click node_website_cache "https://github.com/filiksyos/gitreverse/blob/main/lib/website-reverse-storage.ts"
click node_library_page "https://github.com/filiksyos/gitreverse/blob/main/app/library/page.tsx"
click node_library_ui "https://github.com/filiksyos/gitreverse/blob/main/components/library-page.tsx"
click node_library_query "https://github.com/filiksyos/gitreverse/blob/main/lib/library-query.ts"
click node_embeddings "https://github.com/filiksyos/gitreverse/blob/main/lib/embeddings.ts"
click node_library_api "https://github.com/filiksyos/gitreverse/blob/main/app/api/library/route.ts"
click node_auth_context "https://github.com/filiksyos/gitreverse/blob/main/contexts/AuthContext.tsx"
click node_supabase_auth "https://github.com/filiksyos/gitreverse/blob/main/lib/supabase-auth.ts"
click node_history_ui "https://github.com/filiksyos/gitreverse/blob/main/components/history-page.tsx"
click node_history_api "https://github.com/filiksyos/gitreverse/blob/main/app/api/user-history/route.ts"
click node_history_store "https://github.com/filiksyos/gitreverse/blob/main/lib/user-history.ts"
click node_billing_ui "https://github.com/filiksyos/gitreverse/blob/main/components/navbar.tsx"
click node_checkout_api "https://github.com/filiksyos/gitreverse/blob/main/app/api/create-checkout/route.ts"
click node_credit_verify "https://github.com/filiksyos/gitreverse/blob/main/app/api/verify-credit-purchase/route.ts"
click node_subscriber "https://github.com/filiksyos/gitreverse/blob/main/lib/subscriber.ts"
click node_sponsor_page "https://github.com/filiksyos/gitreverse/blob/main/components/partner-page.tsx"
click node_sponsorship "https://github.com/filiksyos/gitreverse/blob/main/lib/sponsorship-analytics.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home_ui,node_repo_page,node_repo_api,node_repo_parser,node_github_context,node_prompt_format,node_quick_llm,node_website_ui,node_website_api,node_website_parser,node_website_engine,node_website_scraper,node_website_prompts,node_website_cache toneBlue
class node_library_page,node_library_ui,node_library_query,node_embeddings,node_library_api,node_supabase toneAmber
class node_auth_context,node_supabase_auth,node_history_ui,node_history_api,node_history_store toneMint
class node_billing_ui,node_checkout_api,node_credit_verify,node_subscriber,node_sponsor_page,node_sponsorship toneRose
class node_visitor,node_llm_provider,node_stripe toneIndigo
```

## Components

### Prompt generation

- [Reverse prompt UI](https://github.com/filiksyos/gitreverse/blob/main/components/reverse-prompt-home.tsx): `components/reverse-prompt-home.tsx`
- [Shareable repo page](https://github.com/filiksyos/gitreverse/blob/main/app/%5Bowner%5D/%5Brepo%5D/page.tsx): `app/[owner]/[repo]/page.tsx`
- [Repository prompt API](https://github.com/filiksyos/gitreverse/blob/main/app/api/reverse-prompt/route.ts): `app/api/reverse-prompt/route.ts`
- [Repo input parser](https://github.com/filiksyos/gitreverse/blob/main/lib/parse-github-repo.ts): `lib/parse-github-repo.ts`
- [GitHub context fetch](https://github.com/filiksyos/gitreverse/blob/main/lib/github-client.ts): `lib/github-client.ts`
- [Tree and prompt formatting](https://github.com/filiksyos/gitreverse/blob/main/lib/file-tree-formatter.ts): `lib/file-tree-formatter.ts`
- [Quick LLM](https://github.com/filiksyos/gitreverse/blob/main/lib/quick-llm.ts): `lib/quick-llm.ts`
- [Website reverse UI](https://github.com/filiksyos/gitreverse/blob/main/components/website-reverse-page.tsx): `components/website-reverse-page.tsx`
- [Website reverse API](https://github.com/filiksyos/gitreverse/blob/main/app/api/reverse-website/route.ts): `app/api/reverse-website/route.ts`
- [Website input parser](https://github.com/filiksyos/gitreverse/blob/main/lib/parse-website-input.ts): `lib/parse-website-input.ts`
- [Website reverse engine](https://github.com/filiksyos/gitreverse/blob/main/lib/website-reverse-engine.ts): `lib/website-reverse-engine.ts`
- [Website evidence gathering](https://github.com/filiksyos/gitreverse/blob/main/lib/website-scraper.ts): `lib/website-scraper.ts`
- [Website prompt builders](https://github.com/filiksyos/gitreverse/blob/main/lib/website-design-system-prompt.ts): `lib/website-design-system-prompt.ts`
- [Website prompt cache](https://github.com/filiksyos/gitreverse/blob/main/lib/website-reverse-storage.ts): `lib/website-reverse-storage.ts`

### Prompt library

- [Library page](https://github.com/filiksyos/gitreverse/blob/main/app/library/page.tsx): `app/library/page.tsx`
- [Library browsing UI](https://github.com/filiksyos/gitreverse/blob/main/components/library-page.tsx): `components/library-page.tsx`
- [Library search and ranking](https://github.com/filiksyos/gitreverse/blob/main/lib/library-query.ts): `lib/library-query.ts`
- [Search embeddings](https://github.com/filiksyos/gitreverse/blob/main/lib/embeddings.ts): `lib/embeddings.ts`
- [Library search API](https://github.com/filiksyos/gitreverse/blob/main/app/api/library/route.ts): `app/api/library/route.ts`

### Accounts and history

- [Authentication state](https://github.com/filiksyos/gitreverse/blob/main/contexts/AuthContext.tsx): `contexts/AuthContext.tsx`
- [Supabase auth client](https://github.com/filiksyos/gitreverse/blob/main/lib/supabase-auth.ts): `lib/supabase-auth.ts`
- [History page](https://github.com/filiksyos/gitreverse/blob/main/components/history-page.tsx): `components/history-page.tsx`
- [History API](https://github.com/filiksyos/gitreverse/blob/main/app/api/user-history/route.ts): `app/api/user-history/route.ts`
- [User history](https://github.com/filiksyos/gitreverse/blob/main/lib/user-history.ts): `lib/user-history.ts`

### Billing and sponsorship

- [Account and plan UI](https://github.com/filiksyos/gitreverse/blob/main/components/navbar.tsx): `components/navbar.tsx`
- [Checkout routes](https://github.com/filiksyos/gitreverse/blob/main/app/api/create-checkout/route.ts): `app/api/create-checkout/route.ts`
- [Credit purchase verification](https://github.com/filiksyos/gitreverse/blob/main/app/api/verify-credit-purchase/route.ts): `app/api/verify-credit-purchase/route.ts`
- [Billing status](https://github.com/filiksyos/gitreverse/blob/main/lib/subscriber.ts): `lib/subscriber.ts`
- [Sponsor page](https://github.com/filiksyos/gitreverse/blob/main/components/partner-page.tsx): `components/partner-page.tsx`
- [Sponsorship analytics](https://github.com/filiksyos/gitreverse/blob/main/lib/sponsorship-analytics.ts): `lib/sponsorship-analytics.ts`

### Other components

- **Visitor**
- **LLM providers**
- **Supabase**
- **Stripe**

## Connections

- Visitor → Reverse prompt UI: enters
- Visitor → Shareable repo page: opens
- Reverse prompt UI → Repository prompt API: requests prompt
- Shareable repo page → Reverse prompt UI: renders (evidence: `app/[owner]/[repo]/page.tsx`)
- Repository prompt API → Repo input parser: parses input (evidence: `app/api/reverse-prompt/route.ts`)
- Repository prompt API → GitHub context fetch: fetches context (evidence: `app/api/reverse-prompt/route.ts`)
- Repository prompt API → Tree and prompt formatting: formats tree (evidence: `app/api/reverse-prompt/route.ts`)
- Repository prompt API → Quick LLM: generates prompt
- Quick LLM → LLM providers: calls provider
- Visitor → Website reverse UI: submits site
- Website reverse UI → Website reverse API: requests reverse
- Website reverse API → Website input parser: validates URL (evidence: `app/api/reverse-website/route.ts`)
- Website reverse API → Website reverse engine: runs reverse (evidence: `app/api/reverse-website/route.ts`)
- Website reverse engine → Website evidence gathering: gathers evidence (evidence: `lib/website-reverse-engine.ts`)
- Website reverse engine → Website prompt builders: builds prompts (evidence: `lib/website-reverse-engine.ts`)
- Website reverse engine → Quick LLM: generates results (evidence: `lib/website-reverse-engine.ts`)
- Website reverse engine → Website prompt cache: reads and writes (evidence: `lib/website-reverse-engine.ts`)
- Website prompt cache → Supabase: stores cache (evidence: `lib/website-reverse-storage.ts`)
- Visitor → Library page: browses
- Library page → Library search and ranking: fetches initial entries (evidence: `app/library/page.tsx`)
- Library page → Library browsing UI: renders (evidence: `app/library/page.tsx`)
- Library browsing UI → Library search API: searches
- Library search API → Library search and ranking: queries entries (evidence: `app/api/library/route.ts`)
- Library search and ranking → Search embeddings: embeds search (evidence: `lib/library-query.ts`)
- Library search and ranking → Supabase: searches cache
- Visitor → Authentication state: signs in (evidence: `contexts/AuthContext.tsx`)
- Authentication state → Supabase auth client: uses auth client (evidence: `contexts/AuthContext.tsx`)
- Visitor → History page: views history
- History page → User history: loads history (evidence: `components/history-page.tsx`)
- History page → Authentication state: reads session (evidence: `components/history-page.tsx`)
- History API → User history: manages history (evidence: `app/api/user-history/route.ts`)
- User history → Supabase: syncs history
- Account and plan UI → Authentication state: reads account (evidence: `components/navbar.tsx`)
- Account and plan UI → Checkout routes: starts checkout
- Checkout routes → Stripe: creates session
- Credit purchase verification → Stripe: verifies payment (evidence: `app/api/verify-credit-purchase/route.ts`)
- Credit purchase verification → Billing status: loads billing status (evidence: `app/api/verify-credit-purchase/route.ts`)
- Credit purchase verification → Supabase: records credits (evidence: `app/api/verify-credit-purchase/route.ts`)
- Visitor → Sponsor page: visits sponsorship
- Sponsor page → Sponsorship analytics: records analytics (evidence: `components/partner-page.tsx`)
