# nightcore-team/nightcore architecture

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

- Interactive diagram: https://gitdiagram.com/nightcore-team/nightcore
- Repository: https://github.com/nightcore-team/nightcore

## Overview

Nightcore is a Discord community bot paired with a guild-configuration API. A typical interaction enters through the bot, whose command and event features use shared persistence and return Discord responses; administrators can also configure guild state through the API. The tree shows broad economy, moderation, clan, and other community features, while the README provides no further product detail. Some feature wiring and API setup internals were not sampled, so their relationships are omitted rather than inferred.

Main entry points: [`src/nightcore/bot.py`](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/bot.py) (Discord bot), [`src/infra/db/uow.py`](https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/uow.py) (Unit of work), [`main.py`](https://github.com/nightcore-team/nightcore/blob/main/main.py) (Application entry), [`src/nightcore/api/services/entity_state.py`](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/services/entity_state.py) (Guild state services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["Application entry<br/>[main.py]"]
  node_bot["Discord bot<br/>[bot.py]"]
end

subgraph group_community["Community features"]
  node_economy["Economy"]
  node_moderation["Moderation"]
  node_clans["Clans"]
  node_community_tools["Community tools"]
end

subgraph group_api["Guild API"]
  node_api_server["API server<br/>[setup.py]"]
  node_api_endpoints["Guild endpoints<br/>[guild.py]"]
  node_api_services["Guild state services<br/>[entity_state.py]"]
  node_api_dependencies["API dependencies<br/>[dependencies.py]"]
end

subgraph group_persistence["Persistence and logging"]
  node_uow["Unit of work<br/>[uow.py]"]
  node_operations["Database operations<br/>[operations.py]"]
  node_database[("Relational database<br/>[session.py]")]
  node_webhook["Logging webhooks<br/>[webhook.py]"]
  node_webhook_model["Webhook configuration<br/>[discord_webhook.py]"]
  node_logging_config["Guild logging config<br/>[logging.py]"]
end

node_member(("Discord user"))
node_discord(("Discord platform"))

node_member -.->|"invokes commands"| node_bot
node_main -->|"starts"| node_bot
node_main -->|"creates and serves"| node_api_server
node_main -->|"constructs"| node_uow
node_bot -.->|"connects to"| node_discord
node_bot -->|"loads components"| node_economy
node_bot -->|"loads components"| node_moderation
node_bot -.->|"loads extensions"| node_clans
node_bot -.->|"loads extensions"| node_community_tools
node_bot -->|"uses"| node_uow
node_api_server -.->|"routes requests"| node_api_endpoints
node_api_endpoints -->|"uses"| node_api_dependencies
node_api_dependencies -->|"provides services"| node_api_services
node_api_dependencies -->|"provides unit of work"| node_uow
node_api_services -->|"queries and updates"| node_operations
node_api_services -->|"opens transactions"| node_uow
node_uow -.->|"manages sessions"| node_database
node_operations -.->|"reads and writes"| node_database
node_webhook -->|"checks and invalidates"| node_webhook_model
node_webhook -->|"sends log messages"| node_discord
node_logging_config -->|"references webhook rows"| node_webhook_model

click node_main "https://github.com/nightcore-team/nightcore/blob/main/main.py"
click node_bot "https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/bot.py"
click node_economy "https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features/economy"
click node_moderation "https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features/moderation"
click node_clans "https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features/clans"
click node_community_tools "https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features"
click node_api_server "https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/setup.py"
click node_api_endpoints "https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/endpoints/guild.py"
click node_api_services "https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/services/entity_state.py"
click node_api_dependencies "https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/dependencies.py"
click node_uow "https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/uow.py"
click node_operations "https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/operations.py"
click node_database "https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/session.py"
click node_webhook "https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/utils/webhook.py"
click node_webhook_model "https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/models/discord_webhook.py"
click node_logging_config "https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/models/configurations/logging.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_main,node_bot,node_member toneBlue
class node_economy,node_moderation,node_clans,node_community_tools toneAmber
class node_api_server,node_api_endpoints,node_api_services,node_api_dependencies toneMint
class node_uow,node_operations,node_database,node_webhook,node_webhook_model,node_logging_config toneRose
class node_discord toneIndigo
```

## Components

### Runtime

- [Application entry](https://github.com/nightcore-team/nightcore/blob/main/main.py): `main.py`
- [Discord bot](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/bot.py): `src/nightcore/bot.py`

### Community features

- [Economy](https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features/economy): `src/nightcore/features/economy`
- [Moderation](https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features/moderation): `src/nightcore/features/moderation`
- [Clans](https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features/clans): `src/nightcore/features/clans`
- [Community tools](https://github.com/nightcore-team/nightcore/tree/main/src/nightcore/features): `src/nightcore/features`

### Guild API

- [API server](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/setup.py): `src/nightcore/api/setup.py`
- [Guild endpoints](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/endpoints/guild.py): `src/nightcore/api/endpoints/guild.py`
- [Guild state services](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/services/entity_state.py): `src/nightcore/api/services/entity_state.py`
- [API dependencies](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/api/dependencies.py): `src/nightcore/api/dependencies.py`

### Persistence and logging

- [Unit of work](https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/uow.py): `src/infra/db/uow.py`
- [Database operations](https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/operations.py): `src/infra/db/operations.py`
- [Relational database](https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/session.py): `src/infra/db/session.py`
- [Logging webhooks](https://github.com/nightcore-team/nightcore/blob/main/src/nightcore/utils/webhook.py): `src/nightcore/utils/webhook.py`
- [Webhook configuration](https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/models/discord_webhook.py): `src/infra/db/models/discord_webhook.py`
- [Guild logging config](https://github.com/nightcore-team/nightcore/blob/main/src/infra/db/models/configurations/logging.py): `src/infra/db/models/configurations/logging.py`

### Other components

- **Discord user**
- **Discord platform**

## Connections

- Discord user → Discord bot: invokes commands
- Application entry → Discord bot: starts (evidence: `main.py`)
- Application entry → API server: creates and serves (evidence: `main.py`)
- Application entry → Unit of work: constructs (evidence: `main.py`)
- Discord bot → Discord platform: connects to
- Discord bot → Economy: loads components (evidence: `src/nightcore/bot.py`)
- Discord bot → Moderation: loads components (evidence: `src/nightcore/bot.py`)
- Discord bot → Clans: loads extensions
- Discord bot → Community tools: loads extensions (evidence: `src/nightcore/bot.py`)
- Discord bot → Unit of work: uses (evidence: `src/nightcore/bot.py`)
- API server → Guild endpoints: routes requests
- Guild endpoints → API dependencies: uses (evidence: `src/nightcore/api/endpoints/guild.py`)
- API dependencies → Guild state services: provides services (evidence: `src/nightcore/api/dependencies.py`)
- API dependencies → Unit of work: provides unit of work (evidence: `src/nightcore/api/dependencies.py`)
- Guild state services → Database operations: queries and updates (evidence: `src/nightcore/api/services/entity_state.py`)
- Guild state services → Unit of work: opens transactions (evidence: `src/nightcore/api/services/entity_state.py`)
- Unit of work → Relational database: manages sessions
- Database operations → Relational database: reads and writes
- Logging webhooks → Webhook configuration: checks and invalidates (evidence: `src/nightcore/utils/webhook.py`)
- Logging webhooks → Discord platform: sends log messages (evidence: `src/nightcore/utils/webhook.py`)
- Guild logging config → Webhook configuration: references webhook rows (evidence: `src/infra/db/models/configurations/logging.py`)
