# anudit/convo architecture

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

- Interactive diagram: https://gitdiagram.com/anudit/convo
- Repository: https://github.com/anudit/convo

## Overview

#### Purpose and Runtime
The Convo Space is a Next.js application providing a decentralized conversation layer: public thread views, embeddable comments, site-scoped discussions, and a signed-in developer/dashboard experience. Its main runtime combines React pages/components with Next.js API routes.
- `pages/_app.js`
- `pages/index.js`
- `next.config.js`

#### UI Entry Points and Rendering
Route-based pages expose the primary user surfaces: thread and site conversation views, lightweight embeds, identity links, and dashboard areas. Shared shells, navigation, cards, and thread rendering keep those surfaces consistent.
- `pages/thread/[threadId].js`
- `pages/site/[siteUrlEncoded].js`
- `pages/embed/c/[commentId].js`
- `components/ThreadView.js`
- `components/DashboardShell.js`

#### Conversation and Identity API Boundary
Server-side API routes are the application boundary for thread retrieval, comments, votes, authentication, identity, API-key management, and authorization validation. Clients should interact through these endpoints rather than directly with persistence or external providers.
- `pages/api/threads.js`
- `pages/api/threads/[threadIds].js`
- `pages/api/comment.js`
- `pages/api/auth.js`
- `pages/api/identity.js`
- `pages/api/apikey.js`

#### Persistence, Publishing, and Access Control
The core backend library layer separates database operations, legacy thread compatibility, publishing/bridging behavior, API-key enforcement, and auth validation from route handlers. MongoDB is the apparent primary persistence integration.
- `lib/mongo-db.js`
- `lib/thread-db.js`
- `lib/thread-db-old.js`
- `lib/publish.js`
- `lib/bridge.js`
- `lib/validateAuth.js`

#### Web3 and Credential Capabilities
A React Web3 context supports wallet- or chain-aware client behavior. The `/api/omnid` namespace implements credential issuance/verification and kit safety checks, making credentials a distinct capability surface from ordinary conversations.
- `contexts/Web3Context.js`
- `pages/api/omnid/credentials/issue.js`
- `pages/api/omnid/credentials/verify.js`
- `pages/api/omnid/kits/isMalicious.js`
- `utils/rpc.js`

#### Realtime and External Message Integrations
Ably authentication enables realtime client connectivity. Webhook-style endpoints and dedicated middleware integrate Discord, Slack, and Telegram while isolating interaction parsing and error handling from application routes.
- `pages/api/getAblyAuth.js`
- `hooks/Ably.js`
- `pages/api/discord.js`
- `pages/api/slack.js`
- `pages/api/telegram.js`
- `middlewares/discordInteraction.js`

#### Background Operations and Deployment
Scheduled cache/restore work supports retained or regenerated Omnid data. The repository is containerized and contains deployment descriptors for multiple hosting targets, plus GitHub automation including a Heroku deployment workflow.
- `cron/cacheV2.js`
- `cron/restore.js`
- `Dockerfile`
- `vercel.json`
- `netlify.toml`
- `.github/workflows/HerokuDeploy.yml`

Main entry points: [`pages/_app.js`](https://github.com/anudit/convo/blob/main/pages/_app.js) (Next.js runtime), [`pages/api/threads.js`](https://github.com/anudit/convo/blob/main/pages/api/threads.js) (Conversation API), [`pages/thread/[threadId].js`](https://github.com/anudit/convo/blob/main/pages/thread/[threadId].js) (Conversation pages), [`components/DashboardShell.js`](https://github.com/anudit/convo/blob/main/components/DashboardShell.js) (Developer dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Next.js application"]
  node_next_runtime["Next.js runtime<br/>application runtime<br/>[_app.js]"]
  node_public_pages["Conversation pages<br/>route pages<br/>[[threadId].js]"]
  node_thread_ui["Thread rendering<br/>React component<br/>[ThreadView.js]"]
  node_dashboard["Developer dashboard<br/>React shell<br/>[DashboardShell.js]"]
  node_web3_context["Web3 context<br/>React context<br/>[Web3Context.js]"]
end

subgraph group_backend["Backend services"]
  node_conversation_api["Conversation API<br/>API routes<br/>[threads.js]"]
  node_auth_identity_api["Identity and key API<br/>API routes<br/>[auth.js]"]
  node_thread_store["Thread data layer<br/>persistence library<br/>[thread-db.js]"]
  node_mongo[("MongoDB<br/>database<br/>[mongo-db.js]")]
  node_publishing_bridge["Publishing bridge<br/>backend library<br/>[publish.js]"]
  node_access_validation["Access validation<br/>auth library<br/>[validateAuth.js]"]
end

subgraph group_integrations["External capabilities"]
  node_omnid_credentials["Omnid credentials<br/>API capability<br/>[issue.js]"]
  node_rpc["Chain RPC<br/>Web3 utility<br/>[rpc.js]"]
  node_realtime["Ably realtime<br/>realtime integration<br/>[getAblyAuth.js]"]
  node_message_webhooks["Message webhooks<br/>integration routes<br/>[discord.js]"]
  node_discord_middleware["Discord interaction parser<br/>middleware"]
end

subgraph group_ops["Operations"]
  node_scheduled_jobs["Cache and restore jobs<br/>scheduled tasks<br/>[cacheV2.js]"]
  node_deployment{{"Multi-target deployment<br/>container and hosting config"}}
end

node_next_runtime -->|"serves"| node_public_pages
node_public_pages -->|"renders"| node_thread_ui
node_next_runtime -->|"serves"| node_dashboard
node_next_runtime -->|"provides"| node_web3_context
node_public_pages -->|"calls"| node_conversation_api
node_dashboard -->|"calls"| node_conversation_api
node_dashboard -->|"calls"| node_auth_identity_api
node_conversation_api -->|"uses"| node_thread_store
node_thread_store -->|"persists to"| node_mongo
node_conversation_api -->|"publishes through"| node_publishing_bridge
node_auth_identity_api -->|"enforces"| node_access_validation
node_web3_context -->|"uses"| node_rpc
node_next_runtime -->|"exposes"| node_omnid_credentials
node_omnid_credentials -->|"uses"| node_rpc
node_next_runtime -->|"exposes"| node_realtime
node_next_runtime -->|"receives"| node_message_webhooks
node_message_webhooks -->|"parses with"| node_discord_middleware
node_scheduled_jobs -->|"caches and restores"| node_mongo
node_deployment -.->|"deploys"| node_next_runtime

click node_next_runtime "https://github.com/anudit/convo/blob/main/pages/_app.js"
click node_public_pages "https://github.com/anudit/convo/blob/main/pages/thread/[threadId].js"
click node_thread_ui "https://github.com/anudit/convo/blob/main/components/ThreadView.js"
click node_dashboard "https://github.com/anudit/convo/blob/main/components/DashboardShell.js"
click node_web3_context "https://github.com/anudit/convo/blob/main/contexts/Web3Context.js"
click node_conversation_api "https://github.com/anudit/convo/blob/main/pages/api/threads.js"
click node_auth_identity_api "https://github.com/anudit/convo/blob/main/pages/api/auth.js"
click node_thread_store "https://github.com/anudit/convo/blob/main/lib/thread-db.js"
click node_mongo "https://github.com/anudit/convo/blob/main/lib/mongo-db.js"
click node_publishing_bridge "https://github.com/anudit/convo/blob/main/lib/publish.js"
click node_access_validation "https://github.com/anudit/convo/blob/main/lib/validateAuth.js"
click node_omnid_credentials "https://github.com/anudit/convo/blob/main/pages/api/omnid/credentials/issue.js"
click node_rpc "https://github.com/anudit/convo/blob/main/utils/rpc.js"
click node_realtime "https://github.com/anudit/convo/blob/main/pages/api/getAblyAuth.js"
click node_message_webhooks "https://github.com/anudit/convo/blob/main/pages/api/discord.js"
click node_discord_middleware "https://github.com/anudit/convo/blob/main/middlewares/discordInteraction.js"
click node_scheduled_jobs "https://github.com/anudit/convo/blob/main/cron/cacheV2.js"
click node_deployment "https://github.com/anudit/convo/tree/main/Dockerfile"

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_next_runtime,node_public_pages,node_thread_ui,node_dashboard,node_web3_context toneBlue
class node_conversation_api,node_auth_identity_api,node_thread_store,node_mongo,node_publishing_bridge,node_access_validation toneAmber
class node_omnid_credentials,node_rpc,node_realtime,node_message_webhooks,node_discord_middleware toneMint
class node_scheduled_jobs,node_deployment toneRose
```

## Components

### Next.js application

- [Next.js runtime](https://github.com/anudit/convo/blob/main/pages/_app.js): application runtime · Hosts React pages and API routes. · `pages/_app.js`
- [Conversation pages](https://github.com/anudit/convo/blob/main/pages/thread/[threadId].js): route pages · Thread, site, and embed conversation surfaces. · `pages/thread/[threadId].js`
- [Thread rendering](https://github.com/anudit/convo/blob/main/components/ThreadView.js): React component · `components/ThreadView.js`
- [Developer dashboard](https://github.com/anudit/convo/blob/main/components/DashboardShell.js): React shell · `components/DashboardShell.js`
- [Web3 context](https://github.com/anudit/convo/blob/main/contexts/Web3Context.js): React context · Provides wallet- and chain-aware client state. · `contexts/Web3Context.js`

### Backend services

- [Conversation API](https://github.com/anudit/convo/blob/main/pages/api/threads.js): API routes · Retrieves threads and processes comments. · `pages/api/threads.js`
- [Identity and key API](https://github.com/anudit/convo/blob/main/pages/api/auth.js): API routes · Handles authentication, identity, and API keys. · `pages/api/auth.js`
- [Thread data layer](https://github.com/anudit/convo/blob/main/lib/thread-db.js): persistence library · Supports current and legacy thread access. · `lib/thread-db.js`
- [MongoDB](https://github.com/anudit/convo/blob/main/lib/mongo-db.js): database · Primary persistence integration. · `lib/mongo-db.js`
- [Publishing bridge](https://github.com/anudit/convo/blob/main/lib/publish.js): backend library · Publishes and bridges conversation activity. · `lib/publish.js`
- [Access validation](https://github.com/anudit/convo/blob/main/lib/validateAuth.js): auth library · Validates authentication and API-key access. · `lib/validateAuth.js`

### External capabilities

- [Omnid credentials](https://github.com/anudit/convo/blob/main/pages/api/omnid/credentials/issue.js): API capability · Issues, verifies, and safety-checks credentials and kits. · `pages/api/omnid/credentials/issue.js`
- [Chain RPC](https://github.com/anudit/convo/blob/main/utils/rpc.js): Web3 utility · `utils/rpc.js`
- [Ably realtime](https://github.com/anudit/convo/blob/main/pages/api/getAblyAuth.js): realtime integration · Authenticates clients for live connectivity. · `pages/api/getAblyAuth.js`
- [Message webhooks](https://github.com/anudit/convo/blob/main/pages/api/discord.js): integration routes · Receives Discord, Slack, and Telegram interactions. · `pages/api/discord.js`
- [Discord interaction parser](https://github.com/anudit/convo/blob/main/middlewares/discordInteraction.js): middleware · `middlewares/discordInteraction.js`

### Operations

- [Cache and restore jobs](https://github.com/anudit/convo/blob/main/cron/cacheV2.js): scheduled tasks · Maintains retained or regenerated Omnid data. · `cron/cacheV2.js`
- [Multi-target deployment](https://github.com/anudit/convo/tree/main/Dockerfile): container and hosting config · Supports Docker, Vercel, Netlify, and Heroku automation. · `Dockerfile`

## Connections

- Next.js runtime → Conversation pages: serves
- Conversation pages → Thread rendering: renders
- Next.js runtime → Developer dashboard: serves
- Next.js runtime → Web3 context: provides
- Conversation pages → Conversation API: calls
- Developer dashboard → Conversation API: calls
- Developer dashboard → Identity and key API: calls
- Conversation API → Thread data layer: uses
- Thread data layer → MongoDB: persists to
- Conversation API → Publishing bridge: publishes through
- Identity and key API → Access validation: enforces
- Web3 context → Chain RPC: uses
- Next.js runtime → Omnid credentials: exposes
- Omnid credentials → Chain RPC: uses
- Next.js runtime → Ably realtime: exposes
- Next.js runtime → Message webhooks: receives
- Message webhooks → Discord interaction parser: parses with
- Cache and restore jobs → MongoDB: caches and restores
- Multi-target deployment → Next.js runtime: deploys
