# 3obhan/mr-judge architecture

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

- Interactive diagram: https://gitdiagram.com/3obhan/mr-judge
- Repository: https://github.com/3obhan/mr-judge

## Overview

Mr Judge is a multilingual AI dispute-analysis product with anonymous accounts, a limited free allowance, paid credit packs, and a thin Android shell. Users enter a dispute, obtain an AI analysis and verdict, and can review results/history; account and credit management support that workflow. Payments span several providers, while the API verifies purchases and persists account state. The excerpts show some client/API and server/storage calls; other domain links below are documented in the README, and unsampled implementation details are not assumed.

Main entry points: [`src/lib/account.js`](https://github.com/3obhan/mr-judge/blob/main/src/lib/account.js) (Account client), [`src/pages`](https://github.com/3obhan/mr-judge/tree/main/src/pages) (Product pages), [`src/lib/geminiClient.js`](https://github.com/3obhan/mr-judge/blob/main/src/lib/geminiClient.js) (AI and transcription), [`api/_lib/redis.js`](https://github.com/3obhan/mr-judge/blob/main/api/_lib/redis.js) (Account store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_app["Localized app<br/>[App.jsx]"]
  node_pages["Product pages"]
  node_history["History and results<br/>[History.jsx]"]
  node_settings["Account settings<br/>[Settings.jsx]"]
  node_android["Android shell"]
end

subgraph group_analysis["Dispute analysis"]
  node_disputeform["Dispute entry<br/>[DisputeForm.jsx]"]
  node_judge["Analysis orchestration<br/>[judge.js]"]
  node_gemini["AI and transcription<br/>[geminiClient.js]"]
  node_voice["Voice input<br/>[VoiceButton.jsx]"]
  node_verdict["Verdict display<br/>[VerdictDisplay.jsx]"]
  node_pdf["PDF export<br/>[pdfGenerator.js]"]
  node_ai_services{{"AI services"}}
end

subgraph group_identity["Accounts and credits"]
  node_accountclient["Account client<br/>[account.js]"]
  node_accountapi["Account API<br/>[account.js]"]
  node_credits["Credit API<br/>[credits.js]"]
  node_email["Email verification<br/>[email.js]"]
end

subgraph group_commerce["Payments"]
  node_creditsui["Credits page<br/>[Credits.jsx]"]
  node_paymentsui["Payment choices<br/>[PaymentButtons.jsx]"]
  node_paymentclient["Billing client<br/>[billing.js]"]
  node_paymentapi["Payment endpoints"]
  node_stripehook["Stripe webhook<br/>[stripe-webhook.js]"]
  node_providers{{"Payment providers"}}
end

subgraph group_backend["API and hosting"]
  node_storage[("Account store<br/>[redis.js]")]
  node_apiadapter["Cloudflare API adapter<br/>[adapter.js]"]
  node_hosting["Hosting runtime<br/>[&#91;&#91;path&#93;&#93;.js]"]
end

node_user(("User"))

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_pages
node_pages -.->|"collects dispute"| node_disputeform
node_disputeform -.->|"submits analysis"| node_judge
node_judge -.->|"requests analysis"| node_gemini
node_gemini -->|"ensures account"| node_accountclient
node_gemini -->|"calls AI"| node_ai_services
node_voice -->|"transcribes audio"| node_gemini
node_judge -.->|"returns verdict"| node_verdict
node_verdict -.->|"exports report"| node_pdf
node_pages -.->|"offers history"| node_history
node_pages -.->|"offers settings"| node_settings
node_settings -->|"manages account"| node_accountclient
node_creditsui -->|"loads balance"| node_accountclient
node_accountclient -->|"calls account API"| node_accountapi
node_accountclient -->|"calls credit API"| node_credits
node_accountclient -->|"verifies email"| node_email
node_accountapi -->|"reads and writes"| node_storage
node_credits -.->|"reads and writes"| node_storage
node_email -->|"reads and writes"| node_storage
node_creditsui -->|"renders choices"| node_paymentsui
node_paymentsui -->|"starts billing"| node_paymentclient
node_paymentclient -.->|"requests checkout"| node_paymentapi
node_paymentapi -->|"verifies payment"| node_providers
node_providers -->|"sends events"| node_stripehook
node_stripehook -->|"grants credits"| node_storage
node_hosting -->|"forwards requests"| node_apiadapter
node_apiadapter -->|"dispatches API"| node_paymentapi
node_apiadapter -->|"dispatches API"| node_accountapi
node_android -->|"opens website"| node_app

click node_app "https://github.com/3obhan/mr-judge/blob/main/src/App.jsx"
click node_pages "https://github.com/3obhan/mr-judge/tree/main/src/pages"
click node_history "https://github.com/3obhan/mr-judge/blob/main/src/pages/History.jsx"
click node_settings "https://github.com/3obhan/mr-judge/blob/main/src/pages/Settings.jsx"
click node_disputeform "https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/DisputeForm.jsx"
click node_judge "https://github.com/3obhan/mr-judge/blob/main/src/lib/judge.js"
click node_gemini "https://github.com/3obhan/mr-judge/blob/main/src/lib/geminiClient.js"
click node_voice "https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/VoiceButton.jsx"
click node_verdict "https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/VerdictDisplay.jsx"
click node_pdf "https://github.com/3obhan/mr-judge/blob/main/src/lib/pdfGenerator.js"
click node_accountclient "https://github.com/3obhan/mr-judge/blob/main/src/lib/account.js"
click node_accountapi "https://github.com/3obhan/mr-judge/blob/main/api/account.js"
click node_credits "https://github.com/3obhan/mr-judge/blob/main/api/credits.js"
click node_storage "https://github.com/3obhan/mr-judge/blob/main/api/_lib/redis.js"
click node_email "https://github.com/3obhan/mr-judge/blob/main/api/email.js"
click node_creditsui "https://github.com/3obhan/mr-judge/blob/main/src/pages/Credits.jsx"
click node_paymentsui "https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/PaymentButtons.jsx"
click node_paymentclient "https://github.com/3obhan/mr-judge/blob/main/src/lib/billing.js"
click node_paymentapi "https://github.com/3obhan/mr-judge/tree/main/api"
click node_stripehook "https://github.com/3obhan/mr-judge/blob/main/api/stripe-webhook.js"
click node_apiadapter "https://github.com/3obhan/mr-judge/blob/main/cloudflare/adapter.js"
click node_hosting "https://github.com/3obhan/mr-judge/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_android "https://github.com/3obhan/mr-judge/blob/main/capacitor.config.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_app,node_pages,node_history,node_settings,node_android,node_user toneBlue
class node_disputeform,node_judge,node_gemini,node_voice,node_verdict,node_pdf,node_ai_services toneAmber
class node_accountclient,node_accountapi,node_credits,node_email toneMint
class node_creditsui,node_paymentsui,node_paymentclient,node_paymentapi,node_stripehook,node_providers toneRose
class node_storage,node_apiadapter,node_hosting toneIndigo
```

## Components

### Web experience

- [Localized app](https://github.com/3obhan/mr-judge/blob/main/src/App.jsx): `src/App.jsx`
- [Product pages](https://github.com/3obhan/mr-judge/tree/main/src/pages): `src/pages`
- [History and results](https://github.com/3obhan/mr-judge/blob/main/src/pages/History.jsx): `src/pages/History.jsx`
- [Account settings](https://github.com/3obhan/mr-judge/blob/main/src/pages/Settings.jsx): `src/pages/Settings.jsx`
- [Android shell](https://github.com/3obhan/mr-judge/blob/main/capacitor.config.ts): `capacitor.config.ts`

### Dispute analysis

- [Dispute entry](https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/DisputeForm.jsx): `src/components/arbiter/DisputeForm.jsx`
- [Analysis orchestration](https://github.com/3obhan/mr-judge/blob/main/src/lib/judge.js): `src/lib/judge.js`
- [AI and transcription](https://github.com/3obhan/mr-judge/blob/main/src/lib/geminiClient.js): `src/lib/geminiClient.js`
- [Voice input](https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/VoiceButton.jsx): `src/components/arbiter/VoiceButton.jsx`
- [Verdict display](https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/VerdictDisplay.jsx): `src/components/arbiter/VerdictDisplay.jsx`
- [PDF export](https://github.com/3obhan/mr-judge/blob/main/src/lib/pdfGenerator.js): `src/lib/pdfGenerator.js`
- **AI services**

### Accounts and credits

- [Account client](https://github.com/3obhan/mr-judge/blob/main/src/lib/account.js): `src/lib/account.js`
- [Account API](https://github.com/3obhan/mr-judge/blob/main/api/account.js): `api/account.js`
- [Credit API](https://github.com/3obhan/mr-judge/blob/main/api/credits.js): `api/credits.js`
- [Email verification](https://github.com/3obhan/mr-judge/blob/main/api/email.js): `api/email.js`

### Payments

- [Credits page](https://github.com/3obhan/mr-judge/blob/main/src/pages/Credits.jsx): `src/pages/Credits.jsx`
- [Payment choices](https://github.com/3obhan/mr-judge/blob/main/src/components/arbiter/PaymentButtons.jsx): `src/components/arbiter/PaymentButtons.jsx`
- [Billing client](https://github.com/3obhan/mr-judge/blob/main/src/lib/billing.js): `src/lib/billing.js`
- [Payment endpoints](https://github.com/3obhan/mr-judge/tree/main/api): `api`
- [Stripe webhook](https://github.com/3obhan/mr-judge/blob/main/api/stripe-webhook.js): `api/stripe-webhook.js`
- **Payment providers**

### API and hosting

- [Account store](https://github.com/3obhan/mr-judge/blob/main/api/_lib/redis.js): `api/_lib/redis.js`
- [Cloudflare API adapter](https://github.com/3obhan/mr-judge/blob/main/cloudflare/adapter.js): `cloudflare/adapter.js`
- [Hosting runtime](https://github.com/3obhan/mr-judge/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`

### Other components

- **User**

## Connections

- User → Localized app: opens
- Localized app → Product pages: routes to (evidence: `src/App.jsx`)
- Product pages → Dispute entry: collects dispute
- Dispute entry → Analysis orchestration: submits analysis
- Analysis orchestration → AI and transcription: requests analysis
- AI and transcription → Account client: ensures account (evidence: `src/lib/geminiClient.js`)
- AI and transcription → AI services: calls AI
- Voice input → AI and transcription: transcribes audio (evidence: `src/components/arbiter/VoiceButton.jsx`)
- Analysis orchestration → Verdict display: returns verdict
- Verdict display → PDF export: exports report
- Product pages → History and results: offers history
- Product pages → Account settings: offers settings
- Account settings → Account client: manages account (evidence: `src/pages/Settings.jsx`)
- Credits page → Account client: loads balance (evidence: `src/pages/Credits.jsx`)
- Account client → Account API: calls account API (evidence: `src/lib/account.js`)
- Account client → Credit API: calls credit API (evidence: `src/lib/account.js`)
- Account client → Email verification: verifies email (evidence: `src/lib/account.js`)
- Account API → Account store: reads and writes
- Credit API → Account store: reads and writes
- Email verification → Account store: reads and writes (evidence: `api/email.js`)
- Credits page → Payment choices: renders choices (evidence: `src/pages/Credits.jsx`)
- Payment choices → Billing client: starts billing (evidence: `src/components/arbiter/PaymentButtons.jsx`)
- Billing client → Payment endpoints: requests checkout
- Payment endpoints → Payment providers: verifies payment
- Payment providers → Stripe webhook: sends events (evidence: `api/stripe-webhook.js`)
- Stripe webhook → Account store: grants credits (evidence: `api/stripe-webhook.js`)
- Hosting runtime → Cloudflare API adapter: forwards requests (evidence: `functions/api/[[path]].js`)
- Cloudflare API adapter → Payment endpoints: dispatches API (evidence: `cloudflare/adapter.js`)
- Cloudflare API adapter → Account API: dispatches API (evidence: `cloudflare/adapter.js`)
- Android shell → Localized app: opens website
