# brxj19/revforge architecture

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

- Interactive diagram: https://gitdiagram.com/brxj19/revforge
- Repository: https://github.com/brxj19/revforge

## Overview

RevForge is a self-hosted Mercurial forge. Users browse and manage repositories, inspect revisions and code, and collaborate through review workflows; operators manage access and observe activity. The backend exposes API workflows and Mercurial HTTP/SSH transport, while the current React app and redesigned Solid app provide separate web interfaces. The sampled startup, routing, dependency, and read-service references support the shown links; README capability statements preserve major unsampled areas. Other implementation connections are omitted where excerpts do not establish them.

Main entry points: [`backend/app/api/v1/router.py`](https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/router.py) (API router), [`backend/app/db/session.py`](https://github.com/brxj19/revforge/blob/main/backend/app/db/session.py) (Forge database), [`frontend-next/src/app/App.tsx`](https://github.com/brxj19/revforge/blob/main/frontend-next/src/app/App.tsx) (Redesigned web app), [`backend/app/main.py`](https://github.com/brxj19/revforge/blob/main/backend/app/main.py) (Backend application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interfaces"]
  node_current_app["Current web app<br/>[router.tsx]"]
  node_graph_view["Revision graph"]
  node_new_app["Redesigned web app<br/>[App.tsx]"]
  node_new_routes["Feature routes<br/>[routes.tsx]"]
  node_api_client["Web API client<br/>[client.ts]"]
end

subgraph group_api["API workflows"]
  node_backend["Backend application<br/>[main.py]"]
  node_api_router["API router<br/>[router.py]"]
  node_org_api["Organization API<br/>[organizations.py]"]
  node_repo_api["Repository API<br/>[repositories.py]"]
  node_pr_api["Pull request API<br/>[pull_requests.py]"]
  node_webhook_api["Webhook API<br/>[webhooks.py]"]
  node_dependencies["Request identity<br/>[deps.py]"]
end

subgraph group_hg["Mercurial platform"]
  node_read_service["Revision and code reads<br/>[read_service.py]"]
  node_command_runner["Mercurial command runner<br/>[command_runner.py]"]
  node_storage_locator["Repository storage paths<br/>[storage_locator.py]"]
  node_http_gateway["HTTP clone gateway"]
  node_ssh_gateway["SSH clone gateway<br/>[ssh_gateway.py]"]
end

subgraph group_domain["Forge services"]
  node_repo_service["Repository services"]
  node_pr_service["Review workflows"]
  node_search_service["Visibility-aware search<br/>[search_service.py]"]
  node_admin_service["Administration<br/>[admin_service.py]"]
end

subgraph group_state["Persistent state"]
  node_database[("Forge database<br/>[session.py]")]
  node_repository_model["Repository records<br/>[repository.py]"]
  node_user_model["User records<br/>[user.py]"]
end

node_developer(("Developer or operator"))
node_mercurial_repos[("Mercurial repositories")]
node_clone_client(("Mercurial client"))

node_developer -->|"uses"| node_current_app
node_developer -->|"uses"| node_new_app
node_current_app -->|"routes to"| node_graph_view
node_new_app -->|"renders routes"| node_new_routes
node_new_routes -.->|"queries API"| node_api_client
node_new_app -.->|"calls API"| node_backend
node_backend -->|"mounts"| node_api_router
node_api_router -->|"registers"| node_org_api
node_api_router -->|"registers"| node_repo_api
node_api_router -->|"registers"| node_pr_api
node_api_router -->|"registers"| node_webhook_api
node_org_api -.->|"delegates"| node_repo_service
node_pr_api -.->|"delegates"| node_pr_service
node_webhook_api -->|"resolves identity"| node_dependencies
node_dependencies -->|"loads identity"| node_user_model
node_repo_api -.->|"reads revisions"| node_read_service
node_repo_api -.->|"searches"| node_search_service
node_admin_service -->|"provisions paths"| node_storage_locator
node_read_service -->|"runs commands"| node_command_runner
node_storage_locator -->|"resolves path for"| node_repository_model
node_backend -->|"mounts"| node_http_gateway
node_clone_client -.->|"clones over HTTPS"| node_http_gateway
node_clone_client -.->|"clones over SSH"| node_ssh_gateway
node_http_gateway -.->|"serves"| node_mercurial_repos
node_ssh_gateway -.->|"serves"| node_mercurial_repos
node_repo_service -.->|"persists records"| node_database
node_pr_service -.->|"persists reviews"| node_database
node_search_service -->|"queries visibility"| node_database
node_database -.->|"stores"| node_repository_model
node_database -.->|"stores"| node_user_model

click node_current_app "https://github.com/brxj19/revforge/blob/main/frontend/src/app/router.tsx"
click node_graph_view "https://github.com/brxj19/revforge/blob/main/frontend/src/routes/repository-graph.tsx"
click node_new_app "https://github.com/brxj19/revforge/blob/main/frontend-next/src/app/App.tsx"
click node_new_routes "https://github.com/brxj19/revforge/blob/main/frontend-next/src/app/routes.tsx"
click node_api_client "https://github.com/brxj19/revforge/blob/main/frontend-next/src/lib/api/client.ts"
click node_backend "https://github.com/brxj19/revforge/blob/main/backend/app/main.py"
click node_api_router "https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/router.py"
click node_org_api "https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/organizations.py"
click node_repo_api "https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/repositories.py"
click node_pr_api "https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/pull_requests.py"
click node_webhook_api "https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/webhooks.py"
click node_dependencies "https://github.com/brxj19/revforge/blob/main/backend/app/api/deps.py"
click node_repo_service "https://github.com/brxj19/revforge/blob/main/backend/app/services/repository_service.py"
click node_pr_service "https://github.com/brxj19/revforge/blob/main/backend/app/services/pull_request_service.py"
click node_search_service "https://github.com/brxj19/revforge/blob/main/backend/app/services/search_service.py"
click node_admin_service "https://github.com/brxj19/revforge/blob/main/backend/app/services/admin_service.py"
click node_read_service "https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/read_service.py"
click node_command_runner "https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/command_runner.py"
click node_storage_locator "https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/storage_locator.py"
click node_http_gateway "https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/http_gateway_service.py"
click node_ssh_gateway "https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/ssh_gateway.py"
click node_database "https://github.com/brxj19/revforge/blob/main/backend/app/db/session.py"
click node_repository_model "https://github.com/brxj19/revforge/blob/main/backend/app/models/repository.py"
click node_user_model "https://github.com/brxj19/revforge/blob/main/backend/app/models/user.py"

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_current_app,node_graph_view,node_new_app,node_new_routes,node_api_client,node_clone_client toneBlue
class node_backend,node_api_router,node_org_api,node_repo_api,node_pr_api,node_webhook_api,node_dependencies,node_mercurial_repos toneAmber
class node_read_service,node_command_runner,node_storage_locator,node_http_gateway,node_ssh_gateway toneMint
class node_repo_service,node_pr_service,node_search_service,node_admin_service toneRose
class node_database,node_repository_model,node_user_model,node_developer toneIndigo
```

## Components

### Web interfaces

- [Current web app](https://github.com/brxj19/revforge/blob/main/frontend/src/app/router.tsx): `frontend/src/app/router.tsx`
- [Revision graph](https://github.com/brxj19/revforge/blob/main/frontend/src/routes/repository-graph.tsx): `frontend/src/routes/repository-graph.tsx`
- [Redesigned web app](https://github.com/brxj19/revforge/blob/main/frontend-next/src/app/App.tsx): `frontend-next/src/app/App.tsx`
- [Feature routes](https://github.com/brxj19/revforge/blob/main/frontend-next/src/app/routes.tsx): `frontend-next/src/app/routes.tsx`
- [Web API client](https://github.com/brxj19/revforge/blob/main/frontend-next/src/lib/api/client.ts): `frontend-next/src/lib/api/client.ts`

### API workflows

- [Backend application](https://github.com/brxj19/revforge/blob/main/backend/app/main.py): `backend/app/main.py`
- [API router](https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Organization API](https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/organizations.py): `backend/app/api/v1/organizations.py`
- [Repository API](https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/repositories.py): `backend/app/api/v1/repositories.py`
- [Pull request API](https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/pull_requests.py): `backend/app/api/v1/pull_requests.py`
- [Webhook API](https://github.com/brxj19/revforge/blob/main/backend/app/api/v1/webhooks.py): `backend/app/api/v1/webhooks.py`
- [Request identity](https://github.com/brxj19/revforge/blob/main/backend/app/api/deps.py): `backend/app/api/deps.py`

### Mercurial platform

- [Revision and code reads](https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/read_service.py): `backend/app/mercurial/read_service.py`
- [Mercurial command runner](https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/command_runner.py): `backend/app/mercurial/command_runner.py`
- [Repository storage paths](https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/storage_locator.py): `backend/app/mercurial/storage_locator.py`
- [HTTP clone gateway](https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/http_gateway_service.py): `backend/app/mercurial/http_gateway_service.py`
- [SSH clone gateway](https://github.com/brxj19/revforge/blob/main/backend/app/mercurial/ssh_gateway.py): `backend/app/mercurial/ssh_gateway.py`

### Forge services

- [Repository services](https://github.com/brxj19/revforge/blob/main/backend/app/services/repository_service.py): `backend/app/services/repository_service.py`
- [Review workflows](https://github.com/brxj19/revforge/blob/main/backend/app/services/pull_request_service.py): `backend/app/services/pull_request_service.py`
- [Visibility-aware search](https://github.com/brxj19/revforge/blob/main/backend/app/services/search_service.py): `backend/app/services/search_service.py`
- [Administration](https://github.com/brxj19/revforge/blob/main/backend/app/services/admin_service.py): `backend/app/services/admin_service.py`

### Persistent state

- [Forge database](https://github.com/brxj19/revforge/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Repository records](https://github.com/brxj19/revforge/blob/main/backend/app/models/repository.py): `backend/app/models/repository.py`
- [User records](https://github.com/brxj19/revforge/blob/main/backend/app/models/user.py): `backend/app/models/user.py`

### Other components

- **Developer or operator**
- **Mercurial repositories**
- **Mercurial client**

## Connections

- Developer or operator → Current web app: uses (evidence: `README.md`)
- Developer or operator → Redesigned web app: uses (evidence: `README.md`)
- Current web app → Revision graph: routes to (evidence: `frontend/src/app/router.tsx`)
- Redesigned web app → Feature routes: renders routes (evidence: `frontend-next/src/app/App.tsx`)
- Feature routes → Web API client: queries API
- Redesigned web app → Backend application: calls API
- Backend application → API router: mounts (evidence: `backend/app/main.py`)
- API router → Organization API: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Repository API: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Pull request API: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Webhook API: registers (evidence: `backend/app/api/v1/router.py`)
- Organization API → Repository services: delegates
- Pull request API → Review workflows: delegates
- Webhook API → Request identity: resolves identity (evidence: `backend/app/api/v1/webhooks.py`)
- Request identity → User records: loads identity (evidence: `backend/app/api/deps.py`)
- Repository API → Revision and code reads: reads revisions
- Repository API → Visibility-aware search: searches
- Administration → Repository storage paths: provisions paths (evidence: `backend/app/services/admin_service.py`)
- Revision and code reads → Mercurial command runner: runs commands (evidence: `backend/app/mercurial/read_service.py`)
- Repository storage paths → Repository records: resolves path for (evidence: `backend/app/mercurial/storage_locator.py`)
- Backend application → HTTP clone gateway: mounts (evidence: `backend/app/main.py`)
- Mercurial client → HTTP clone gateway: clones over HTTPS
- Mercurial client → SSH clone gateway: clones over SSH
- HTTP clone gateway → Mercurial repositories: serves
- SSH clone gateway → Mercurial repositories: serves
- Repository services → Forge database: persists records
- Review workflows → Forge database: persists reviews
- Visibility-aware search → Forge database: queries visibility (evidence: `backend/app/services/search_service.py`)
- Forge database → Repository records: stores
- Forge database → User records: stores
