# filipomc/rzejbot architecture

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

- Interactive diagram: https://gitdiagram.com/filipomc/rzejbot
- Repository: https://github.com/filipomc/rzejbot

## Overview

Rzej is a shift- and employee-management product with a Discord bot and a web application backed by a shared API and database. The main operational workflow is that staff use Discord commands to manage employees and plan or send shifts; the web API stores shift records and supports reports and attendance, absence, and station logs, which the web interface can present. The tree also shows automated shift-briefing tasks and a shared validation/configuration package. The README is empty and bot helpers, web pages, and task implementations were not sampled, so their internal wiring is left unspecified.

Main entry points: [`packages/web/src/app/api/shifts`](https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/shifts) (Shift endpoints), [`packages/web/src/lib/prisma.ts`](https://github.com/filipomc/rzejbot/blob/main/packages/web/src/lib/prisma.ts) (Prisma client), [`packages/web/src/app/api/shifts/[id]/logs`](https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/shifts/%5Bid%5D/logs) (Shift log endpoints), [`packages/shared/src/zod/shiftSchemas.ts`](https://github.com/filipomc/rzejbot/blob/main/packages/shared/src/zod/shiftSchemas.ts) (Shift schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord["Discord bot"]
  node_bot_commands["Staff commands"]
  node_shift_editor["Shift editor"]
  node_bot_helpers["Bot helpers"]
  node_shift_tasks["Shift briefing tasks"]
end

subgraph group_web["Web application"]
  node_web_pages["Shift pages<br/>[page.tsx]"]
  node_web_api_client["Web API client<br/>[api.ts]"]
end

subgraph group_data["API and persistence"]
  node_employee_routes["Employee endpoints"]
  node_shift_routes["Shift endpoints"]
  node_shift_log_routes["Shift log endpoints"]
  node_report_route["Shift reports<br/>[route.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_database[("Application database")]
end

subgraph group_shared["Shared contracts"]
  node_employee_schemas["Employee schemas<br/>[employeeSchemas.ts]"]
  node_shift_schemas["Shift schemas<br/>[shiftSchemas.ts]"]
  node_shared_config["Shared config"]
end

node_discord_users(("Discord staff"))
node_web_users(("Web users"))

node_discord_users -->|"invoke commands"| node_bot_commands
node_bot_commands -->|"open editor"| node_shift_editor
node_bot_helpers -.->|"call API"| node_shift_routes
node_shift_tasks -.->|"call API"| node_shift_routes
node_web_users -->|"view shifts"| node_web_pages
node_web_pages -->|"request data"| node_web_api_client
node_web_api_client -->|"call API"| node_shift_routes
node_employee_routes -->|"read/write employees"| node_prisma
node_shift_routes -->|"read/write shifts"| node_prisma
node_shift_log_routes -->|"read/write logs"| node_prisma
node_report_route -->|"read/write reports"| node_prisma
node_prisma -->|"read/write records"| node_database
node_employee_routes -->|"validate input"| node_employee_schemas
node_shift_routes -->|"validate input"| node_shift_schemas
node_shift_log_routes -->|"validate input"| node_shift_schemas
node_report_route -->|"validate input"| node_shift_schemas
node_shift_log_routes -->|"order stations"| node_shared_config

click node_bot_commands "https://github.com/filipomc/rzejbot/tree/main/packages/bot/src/app/commands/(Kierownictwo)"
click node_shift_editor "https://github.com/filipomc/rzejbot/tree/main/packages/bot/src/app/components/zmiana/manageShiftEmbed"
click node_bot_helpers "https://github.com/filipomc/rzejbot/tree/main/packages/bot/src/helper"
click node_shift_tasks "https://github.com/filipomc/rzejbot/blob/main/packages/bot/src/app/tasks/prepareShiftBriefing.ts"
click node_web_pages "https://github.com/filipomc/rzejbot/blob/main/packages/web/src/app/zmiana/%5BshiftNumber%5D/plan/page.tsx"
click node_web_api_client "https://github.com/filipomc/rzejbot/blob/main/packages/web/src/lib/api.ts"
click node_employee_routes "https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/employees"
click node_shift_routes "https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/shifts"
click node_shift_log_routes "https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/shifts/%5Bid%5D/logs"
click node_report_route "https://github.com/filipomc/rzejbot/blob/main/packages/web/src/app/api/shifts/%5Bid%5D/report/route.ts"
click node_prisma "https://github.com/filipomc/rzejbot/blob/main/packages/web/src/lib/prisma.ts"
click node_employee_schemas "https://github.com/filipomc/rzejbot/blob/main/packages/shared/src/zod/employeeSchemas.ts"
click node_shift_schemas "https://github.com/filipomc/rzejbot/blob/main/packages/shared/src/zod/shiftSchemas.ts"
click node_shared_config "https://github.com/filipomc/rzejbot/tree/main/packages/shared/src/config"

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_commands,node_shift_editor,node_bot_helpers,node_shift_tasks,node_web_users toneBlue
class node_web_pages,node_web_api_client toneAmber
class node_employee_routes,node_shift_routes,node_shift_log_routes,node_report_route,node_prisma,node_database toneMint
class node_employee_schemas,node_shift_schemas,node_shared_config toneRose
class node_discord_users toneIndigo
```

## Components

### Discord bot

- [Staff commands](https://github.com/filipomc/rzejbot/tree/main/packages/bot/src/app/commands/(Kierownictwo)): `packages/bot/src/app/commands/(Kierownictwo)`
- [Shift editor](https://github.com/filipomc/rzejbot/tree/main/packages/bot/src/app/components/zmiana/manageShiftEmbed): `packages/bot/src/app/components/zmiana/manageShiftEmbed`
- [Bot helpers](https://github.com/filipomc/rzejbot/tree/main/packages/bot/src/helper): `packages/bot/src/helper`
- [Shift briefing tasks](https://github.com/filipomc/rzejbot/blob/main/packages/bot/src/app/tasks/prepareShiftBriefing.ts): `packages/bot/src/app/tasks/prepareShiftBriefing.ts`

### Web application

- [Shift pages](https://github.com/filipomc/rzejbot/blob/main/packages/web/src/app/zmiana/%5BshiftNumber%5D/plan/page.tsx): `packages/web/src/app/zmiana/[shiftNumber]/plan/page.tsx`
- [Web API client](https://github.com/filipomc/rzejbot/blob/main/packages/web/src/lib/api.ts): `packages/web/src/lib/api.ts`

### API and persistence

- [Employee endpoints](https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/employees): `packages/web/src/app/api/employees`
- [Shift endpoints](https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/shifts): `packages/web/src/app/api/shifts`
- [Shift log endpoints](https://github.com/filipomc/rzejbot/tree/main/packages/web/src/app/api/shifts/%5Bid%5D/logs): `packages/web/src/app/api/shifts/[id]/logs`
- [Shift reports](https://github.com/filipomc/rzejbot/blob/main/packages/web/src/app/api/shifts/%5Bid%5D/report/route.ts): `packages/web/src/app/api/shifts/[id]/report/route.ts`
- [Prisma client](https://github.com/filipomc/rzejbot/blob/main/packages/web/src/lib/prisma.ts): `packages/web/src/lib/prisma.ts`
- **Application database**

### Shared contracts

- [Employee schemas](https://github.com/filipomc/rzejbot/blob/main/packages/shared/src/zod/employeeSchemas.ts): `packages/shared/src/zod/employeeSchemas.ts`
- [Shift schemas](https://github.com/filipomc/rzejbot/blob/main/packages/shared/src/zod/shiftSchemas.ts): `packages/shared/src/zod/shiftSchemas.ts`
- [Shared config](https://github.com/filipomc/rzejbot/tree/main/packages/shared/src/config): `packages/shared/src/config`

### Other components

- **Discord staff**
- **Web users**

## Connections

- Discord staff → Staff commands: invoke commands
- Staff commands → Shift editor: open editor
- Bot helpers → Shift endpoints: call API
- Shift briefing tasks → Shift endpoints: call API
- Web users → Shift pages: view shifts
- Shift pages → Web API client: request data
- Web API client → Shift endpoints: call API
- Employee endpoints → Prisma client: read/write employees
- Shift endpoints → Prisma client: read/write shifts
- Shift log endpoints → Prisma client: read/write logs
- Shift reports → Prisma client: read/write reports
- Prisma client → Application database: read/write records
- Employee endpoints → Employee schemas: validate input
- Shift endpoints → Shift schemas: validate input
- Shift log endpoints → Shift schemas: validate input
- Shift reports → Shift schemas: validate input
- Shift log endpoints → Shared config: order stations
