# koreanbots/core architecture

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

- Interactive diagram: https://gitdiagram.com/koreanbots/core
- Repository: https://github.com/koreanbots/core

## Overview

Koreanbots is a Korean Discord listing and discovery application for bots, servers, and their owners. Visitors browse or search listings and profiles; owners can submit and manage listings, while users can vote and report. The repository also exposes API routes and supports application management, moderation, notifications, and Discord webhook delivery. The graph emphasizes the main listing and voting flows plus shared data and notification services. Some routes and capabilities are identified from the file tree; where source excerpts do not establish a connection, the graph leaves it out.

Main entry points: [`utils/Query.ts`](https://github.com/koreanbots/core/blob/master/utils/Query.ts) (Query and domain data), [`pages/api/v2/index.ts`](https://github.com/koreanbots/core/blob/master/pages/api/v2/index.ts) (API routes), [`pages/bots/[id]/index.tsx`](https://github.com/koreanbots/core/blob/master/pages/bots/%5Bid%5D/index.tsx) (Bot details), [`utils/NotificationManager.ts`](https://github.com/koreanbots/core/blob/master/utils/NotificationManager.ts) (Vote notifications)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Discovery and profiles"]
  node_bot_pages["Bot listings<br/>[index.tsx]"]
  node_bot_detail["Bot details<br/>[index.tsx]"]
  node_server_pages["Server listings<br/>[index.tsx]"]
  node_server_detail["Server details<br/>[index.tsx]"]
  node_search["Search<br/>[search.tsx]"]
  node_user_profile["User profiles<br/>[index.tsx]"]
  node_listing_ui["Listing components<br/>[ServerCard.tsx]"]
end

subgraph group_contribution["Listing lifecycle"]
  node_submission["Bot submission<br/>[addbot.tsx]"]
  node_server_submission["Server submission<br/>[index.tsx]"]
  node_owner_edit["Listing edits<br/>[edit.tsx]"]
  node_application_ui["Developer applications<br/>[index.tsx]"]
  node_review["Submission review<br/>[&#91;date&#93;.tsx]"]
end

subgraph group_service["API and services"]
  node_api["API routes<br/>[index.ts]"]
  node_bot_api["Bot API<br/>[index.ts]"]
  node_server_api["Server API<br/>[index.ts]"]
  node_applications_api["Application API<br/>[index.ts]"]
  node_query["Query and domain data<br/>[Query.ts]"]
end

subgraph group_storage["Data and integrations"]
  node_sql[("SQL database<br/>[Knex.ts]")]
  node_mongo[("MongoDB models<br/>[Mongo.ts]")]
  node_discord["Discord clients<br/>[DiscordBot.ts]"]
  node_notifications["Vote notifications"]
  node_webhooks["Webhook delivery<br/>[Webhook.ts]"]
end

node_visitor(("Visitor"))
node_firebase["Firebase messaging"]

node_visitor -->|"browses"| node_bot_pages
node_visitor -->|"browses"| node_server_pages
node_visitor -->|"searches"| node_search
node_bot_pages -.->|"renders"| node_listing_ui
node_server_pages -.->|"renders"| node_listing_ui
node_bot_detail -->|"fetches stats"| node_api
node_bot_detail -->|"submits report"| node_api
node_bot_detail -->|"loads bot"| node_query
node_server_detail -->|"loads server"| node_query
node_user_profile -->|"loads user"| node_query
node_api -.->|"routes"| node_bot_api
node_api -.->|"routes"| node_server_api
node_query -->|"queries"| node_sql
node_query -->|"reads"| node_mongo
node_notifications -->|"loads vote data"| node_query
node_notifications -->|"sends push"| node_firebase
node_discord -->|"initializes"| node_notifications
node_webhooks -->|"loads targets"| node_query
node_webhooks -.->|"sends messages"| node_discord

click node_bot_pages "https://github.com/koreanbots/core/blob/master/pages/bots/index.tsx"
click node_bot_detail "https://github.com/koreanbots/core/blob/master/pages/bots/%5Bid%5D/index.tsx"
click node_server_pages "https://github.com/koreanbots/core/blob/master/pages/servers/index.tsx"
click node_server_detail "https://github.com/koreanbots/core/blob/master/pages/servers/%5Bid%5D/index.tsx"
click node_search "https://github.com/koreanbots/core/blob/master/pages/search.tsx"
click node_user_profile "https://github.com/koreanbots/core/blob/master/pages/users/%5Bid%5D/index.tsx"
click node_listing_ui "https://github.com/koreanbots/core/blob/master/components/ServerCard.tsx"
click node_submission "https://github.com/koreanbots/core/blob/master/pages/addbot.tsx"
click node_server_submission "https://github.com/koreanbots/core/blob/master/pages/addserver/index.tsx"
click node_owner_edit "https://github.com/koreanbots/core/blob/master/pages/bots/%5Bid%5D/edit.tsx"
click node_application_ui "https://github.com/koreanbots/core/blob/master/pages/developers/applications/index.tsx"
click node_review "https://github.com/koreanbots/core/blob/master/pages/pendingBots/%5Bid%5D/%5Bdate%5D.tsx"
click node_api "https://github.com/koreanbots/core/blob/master/pages/api/v2/index.ts"
click node_bot_api "https://github.com/koreanbots/core/blob/master/pages/api/v2/bots/%5Bid%5D/index.ts"
click node_server_api "https://github.com/koreanbots/core/blob/master/pages/api/v2/servers/%5Bid%5D/index.ts"
click node_applications_api "https://github.com/koreanbots/core/blob/master/pages/api/v2/applications/bots/%5Bid%5D/index.ts"
click node_query "https://github.com/koreanbots/core/blob/master/utils/Query.ts"
click node_sql "https://github.com/koreanbots/core/blob/master/utils/Knex.ts"
click node_mongo "https://github.com/koreanbots/core/blob/master/utils/Mongo.ts"
click node_discord "https://github.com/koreanbots/core/blob/master/utils/DiscordBot.ts"
click node_notifications "https://github.com/koreanbots/core/blob/master/utils/NotificationManager.ts"
click node_webhooks "https://github.com/koreanbots/core/blob/master/utils/Webhook.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_bot_pages,node_bot_detail,node_server_pages,node_server_detail,node_search,node_user_profile,node_listing_ui toneBlue
class node_submission,node_server_submission,node_owner_edit,node_application_ui,node_review toneAmber
class node_api,node_bot_api,node_server_api,node_applications_api,node_query toneMint
class node_sql,node_mongo,node_discord,node_notifications,node_webhooks toneRose
class node_visitor,node_firebase toneIndigo
```

## Components

### Discovery and profiles

- [Bot listings](https://github.com/koreanbots/core/blob/master/pages/bots/index.tsx): `pages/bots/index.tsx`
- [Bot details](https://github.com/koreanbots/core/blob/master/pages/bots/%5Bid%5D/index.tsx): `pages/bots/[id]/index.tsx`
- [Server listings](https://github.com/koreanbots/core/blob/master/pages/servers/index.tsx): `pages/servers/index.tsx`
- [Server details](https://github.com/koreanbots/core/blob/master/pages/servers/%5Bid%5D/index.tsx): `pages/servers/[id]/index.tsx`
- [Search](https://github.com/koreanbots/core/blob/master/pages/search.tsx): `pages/search.tsx`
- [User profiles](https://github.com/koreanbots/core/blob/master/pages/users/%5Bid%5D/index.tsx): `pages/users/[id]/index.tsx`
- [Listing components](https://github.com/koreanbots/core/blob/master/components/ServerCard.tsx): `components/ServerCard.tsx`

### Listing lifecycle

- [Bot submission](https://github.com/koreanbots/core/blob/master/pages/addbot.tsx): `pages/addbot.tsx`
- [Server submission](https://github.com/koreanbots/core/blob/master/pages/addserver/index.tsx): `pages/addserver/index.tsx`
- [Listing edits](https://github.com/koreanbots/core/blob/master/pages/bots/%5Bid%5D/edit.tsx): `pages/bots/[id]/edit.tsx`
- [Developer applications](https://github.com/koreanbots/core/blob/master/pages/developers/applications/index.tsx): `pages/developers/applications/index.tsx`
- [Submission review](https://github.com/koreanbots/core/blob/master/pages/pendingBots/%5Bid%5D/%5Bdate%5D.tsx): `pages/pendingBots/[id]/[date].tsx`

### API and services

- [API routes](https://github.com/koreanbots/core/blob/master/pages/api/v2/index.ts): `pages/api/v2/index.ts`
- [Bot API](https://github.com/koreanbots/core/blob/master/pages/api/v2/bots/%5Bid%5D/index.ts): `pages/api/v2/bots/[id]/index.ts`
- [Server API](https://github.com/koreanbots/core/blob/master/pages/api/v2/servers/%5Bid%5D/index.ts): `pages/api/v2/servers/[id]/index.ts`
- [Application API](https://github.com/koreanbots/core/blob/master/pages/api/v2/applications/bots/%5Bid%5D/index.ts): `pages/api/v2/applications/bots/[id]/index.ts`
- [Query and domain data](https://github.com/koreanbots/core/blob/master/utils/Query.ts): `utils/Query.ts`

### Data and integrations

- [SQL database](https://github.com/koreanbots/core/blob/master/utils/Knex.ts): `utils/Knex.ts`
- [MongoDB models](https://github.com/koreanbots/core/blob/master/utils/Mongo.ts): `utils/Mongo.ts`
- [Discord clients](https://github.com/koreanbots/core/blob/master/utils/DiscordBot.ts): `utils/DiscordBot.ts`
- [Vote notifications](https://github.com/koreanbots/core/blob/master/utils/NotificationManager.ts): `utils/NotificationManager.ts`
- [Webhook delivery](https://github.com/koreanbots/core/blob/master/utils/Webhook.ts): `utils/Webhook.ts`

### Other components

- **Visitor**
- **Firebase messaging**

## Connections

- Visitor → Bot listings: browses
- Visitor → Server listings: browses
- Visitor → Search: searches
- Bot listings → Listing components: renders
- Server listings → Listing components: renders
- Bot details → API routes: fetches stats (evidence: `pages/bots/[id]/index.tsx`)
- Bot details → API routes: submits report (evidence: `pages/bots/[id]/index.tsx`)
- Bot details → Query and domain data: loads bot (evidence: `utils/Query.ts`)
- Server details → Query and domain data: loads server (evidence: `utils/Query.ts`)
- User profiles → Query and domain data: loads user (evidence: `pages/users/[id]/index.tsx`)
- API routes → Bot API: routes
- API routes → Server API: routes
- Query and domain data → SQL database: queries (evidence: `utils/Query.ts`)
- Query and domain data → MongoDB models: reads (evidence: `utils/Query.ts`)
- Vote notifications → Query and domain data: loads vote data (evidence: `utils/NotificationManager.ts`)
- Vote notifications → Firebase messaging: sends push (evidence: `utils/NotificationManager.ts`)
- Discord clients → Vote notifications: initializes (evidence: `utils/DiscordBot.ts`)
- Webhook delivery → Query and domain data: loads targets (evidence: `utils/Webhook.ts`)
- Webhook delivery → Discord clients: sends messages (evidence: `utils/Webhook.ts`)
