# bangnk2000/event-system-be architecture

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

- Interactive diagram: https://gitdiagram.com/bangnk2000/event-system-be
- Repository: https://github.com/bangnk2000/event-system-be

## Overview

This is a NestJS backend for internal company events. Users manage event lifecycles and registrations, then use supporting features for budgets, surveys, tournaments, and notifications. The README documents a CQRS flow: HTTP commands reach handlers and aggregates, state and outbox events persist transactionally, and queries read models. The six contexts are represented as cohesive product components; detailed command wiring was not sampled, so internal links are limited to relationships stated in the README. The notification adapter and event publication path are documented, but their implementation details are not shown.

Main entry points: [`src/libs/ddd`](https://github.com/bangnk2000/event-system-be/tree/master/src/libs/ddd) (Command handling), [`src/modules`](https://github.com/bangnk2000/event-system-be/tree/master/src/modules) (HTTP API), [`src/libs/outbox/outbox.relay.ts`](https://github.com/bangnk2000/event-system-be/blob/master/src/libs/outbox/outbox.relay.ts) (Outbox relay), [`src/modules/notification`](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/notification) (Notification preferences)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Event operations"]
  node_events["Event lifecycle"]
  node_participation["Registration and check-in"]
end

subgraph group_support["Supporting capabilities"]
  node_budget["Budget tracking"]
  node_survey["Post-event surveys"]
  node_competition["Sports tournaments"]
  node_preferences["Notification preferences"]
  node_chatwork["ChatWork adapter"]
end

subgraph group_runtime["Application runtime"]
  node_http["HTTP API"]
  node_commands["Command handling"]
  node_domain["Aggregates and rules"]
  node_queries["Query handling"]
end

subgraph group_infra["Persistence and events"]
  node_postgres[("PostgreSQL<br/>[database.module.ts]")]
  node_outbox[("Transactional outbox<br/>[outbox.entity.ts]")]
  node_relay["Outbox relay<br/>[outbox.relay.ts]"]
  node_emitter["Event emitter"]
end

node_organizer(("Event organizer"))
node_participant(("Event participant"))

node_organizer -->|"uses API"| node_http
node_participant -->|"uses API"| node_http
node_http -->|"dispatches commands"| node_commands
node_commands -->|"invokes rules"| node_domain
node_commands -->|"writes state"| node_postgres
node_http -->|"dispatches queries"| node_queries
node_queries -->|"reads models"| node_postgres
node_commands -->|"writes events"| node_outbox
node_relay -->|"polls messages"| node_outbox
node_relay -->|"publishes events"| node_emitter
node_emitter -->|"notifies handlers"| node_preferences
node_preferences -->|"sends messages"| node_chatwork

click node_http "https://github.com/bangnk2000/event-system-be/tree/master/src/modules"
click node_commands "https://github.com/bangnk2000/event-system-be/tree/master/src/libs/ddd"
click node_domain "https://github.com/bangnk2000/event-system-be/tree/master/src/modules"
click node_queries "https://github.com/bangnk2000/event-system-be/tree/master/src/modules"
click node_events "https://github.com/bangnk2000/event-system-be/tree/master/src/modules/event"
click node_participation "https://github.com/bangnk2000/event-system-be/tree/master/src/modules/participation"
click node_budget "https://github.com/bangnk2000/event-system-be/tree/master/src/modules/budget"
click node_survey "https://github.com/bangnk2000/event-system-be/tree/master/src/modules/survey"
click node_competition "https://github.com/bangnk2000/event-system-be/tree/master/src/modules/competition"
click node_preferences "https://github.com/bangnk2000/event-system-be/tree/master/src/modules/notification"
click node_chatwork "https://github.com/bangnk2000/event-system-be/blob/master/src/modules/notification/adapters/chatwork.adapter.ts"
click node_postgres "https://github.com/bangnk2000/event-system-be/blob/master/src/database.module.ts"
click node_outbox "https://github.com/bangnk2000/event-system-be/blob/master/src/libs/outbox/outbox.entity.ts"
click node_relay "https://github.com/bangnk2000/event-system-be/blob/master/src/libs/outbox/outbox.relay.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_events,node_participation toneBlue
class node_budget,node_survey,node_competition,node_preferences,node_chatwork toneAmber
class node_http,node_commands,node_domain,node_queries toneMint
class node_postgres,node_outbox,node_relay,node_emitter toneRose
class node_organizer,node_participant toneIndigo
```

## Components

### Event operations

- [Event lifecycle](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/event): `src/modules/event`
- [Registration and check-in](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/participation): `src/modules/participation`

### Supporting capabilities

- [Budget tracking](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/budget): `src/modules/budget`
- [Post-event surveys](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/survey): `src/modules/survey`
- [Sports tournaments](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/competition): `src/modules/competition`
- [Notification preferences](https://github.com/bangnk2000/event-system-be/tree/master/src/modules/notification): `src/modules/notification`
- [ChatWork adapter](https://github.com/bangnk2000/event-system-be/blob/master/src/modules/notification/adapters/chatwork.adapter.ts): `src/modules/notification/adapters/chatwork.adapter.ts`

### Application runtime

- [HTTP API](https://github.com/bangnk2000/event-system-be/tree/master/src/modules): `src/modules`
- [Command handling](https://github.com/bangnk2000/event-system-be/tree/master/src/libs/ddd): `src/libs/ddd`
- [Aggregates and rules](https://github.com/bangnk2000/event-system-be/tree/master/src/modules): `src/modules`
- [Query handling](https://github.com/bangnk2000/event-system-be/tree/master/src/modules): `src/modules`

### Persistence and events

- [PostgreSQL](https://github.com/bangnk2000/event-system-be/blob/master/src/database.module.ts): `src/database.module.ts`
- [Transactional outbox](https://github.com/bangnk2000/event-system-be/blob/master/src/libs/outbox/outbox.entity.ts): `src/libs/outbox/outbox.entity.ts`
- [Outbox relay](https://github.com/bangnk2000/event-system-be/blob/master/src/libs/outbox/outbox.relay.ts): `src/libs/outbox/outbox.relay.ts`
- **Event emitter**

### Other components

- **Event organizer**
- **Event participant**

## Connections

- Event organizer → HTTP API: uses API (evidence: `README.md`)
- Event participant → HTTP API: uses API (evidence: `README.md`)
- HTTP API → Command handling: dispatches commands (evidence: `README.md`)
- Command handling → Aggregates and rules: invokes rules (evidence: `README.md`)
- Command handling → PostgreSQL: writes state (evidence: `README.md`)
- HTTP API → Query handling: dispatches queries (evidence: `README.md`)
- Query handling → PostgreSQL: reads models (evidence: `README.md`)
- Command handling → Transactional outbox: writes events (evidence: `README.md`)
- Outbox relay → Transactional outbox: polls messages (evidence: `README.md`)
- Outbox relay → Event emitter: publishes events (evidence: `README.md`)
- Event emitter → Notification preferences: notifies handlers (evidence: `README.md`)
- Notification preferences → ChatWork adapter: sends messages (evidence: `README.md`)
