82 lines
5.8 KiB
Markdown
82 lines
5.8 KiB
Markdown
# Domains
|
|
|
|
Each folder below is a **bounded context** — a self-contained slice of
|
|
business logic with its own models, application services, and (optionally)
|
|
infrastructure adapters and UI.
|
|
|
|
## Quick reference
|
|
|
|
| Domain | Purpose | Public entry point |
|
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
|
|
| **attachment** | File upload/download, chunk transfer, persistence | `AttachmentFacade` |
|
|
| **access-control** | Role, permission, ban matching, moderation, and room access rules | `normalizeRoomAccessControl()`, `resolveRoomPermission()`, `hasRoomBanForUser()` |
|
|
| **authentication** | Login / register HTTP orchestration, user-bar UI | `AuthenticationService` |
|
|
| **chat** | Messaging rules, sync logic, GIF/Klipy integration, chat UI | `KlipyService`, `canEditMessage()`, `ChatMessagesComponent` |
|
|
| **notifications** | Notification preferences, unread tracking, desktop alert orchestration | `NotificationsFacade` |
|
|
| **profile-avatar** | Profile picture upload, crop/zoom editing, processing, local persistence, and P2P avatar sync | `ProfileAvatarFacade` |
|
|
| **screen-share** | Source picker, quality presets | `ScreenShareFacade` |
|
|
| **server-directory** | Multi-server endpoint management, health checks, invites, server search UI | `ServerDirectoryFacade` |
|
|
| **theme** | JSON-driven theming, element registry, layout syncing, picker tooling, and Electron saved-theme library management | `ThemeService` |
|
|
| **voice-connection** | Voice activity detection, bitrate profiles, in-channel camera transport | `VoiceConnectionFacade` |
|
|
| **voice-session** | Join/leave orchestration, voice settings persistence | `VoiceSessionFacade` |
|
|
|
|
## Detailed docs
|
|
|
|
The larger domains also keep longer design notes in their own folders:
|
|
|
|
- [attachment/README.md](attachment/README.md)
|
|
- [access-control/README.md](access-control/README.md)
|
|
- [authentication/README.md](authentication/README.md)
|
|
- [chat/README.md](chat/README.md)
|
|
- [notifications/README.md](notifications/README.md)
|
|
- [profile-avatar/README.md](profile-avatar/README.md)
|
|
- [screen-share/README.md](screen-share/README.md)
|
|
- [server-directory/README.md](server-directory/README.md)
|
|
- [voice-connection/README.md](voice-connection/README.md)
|
|
- [voice-session/README.md](voice-session/README.md)
|
|
|
|
## Folder convention
|
|
|
|
Every domain follows the same internal layout:
|
|
|
|
```
|
|
domains/<name>/
|
|
├── index.ts # Barrel — the ONLY file outsiders import
|
|
├── domain/ # Pure types, interfaces, business rules
|
|
│ ├── <name>.models.ts
|
|
│ └── <name>.logic.ts # Pure functions (no Angular, no side effects)
|
|
├── application/ # Angular services that orchestrate domain logic
|
|
│ └── <name>.facade.ts # Public entry point for the domain
|
|
├── infrastructure/ # Technical adapters (HTTP, storage, WebSocket)
|
|
└── feature/ # Optional: domain-owned UI components / routes
|
|
└── settings/ # e.g. settings subpanel owned by this domain
|
|
```
|
|
|
|
## Rules
|
|
|
|
1. **Import from the barrel.** Outside a domain, always import from
|
|
`domains/<name>` (the `index.ts`), never from internal paths.
|
|
|
|
2. **No cross-domain imports.** Domain A must never import from Domain B's
|
|
internals. Shared types live in `shared-kernel/`.
|
|
|
|
3. **Features compose domains.** Top-level `features/` components inject
|
|
domain facades and compose their outputs — they never contain business
|
|
logic.
|
|
|
|
4. **Store slices are application-level.** `store/messages`, `store/rooms`,
|
|
`store/users` are global state managed by NgRx. They import from
|
|
`shared-kernel` for types and from domain facades for side-effects.
|
|
|
|
## Where do I put new code?
|
|
|
|
| I want to… | Put it in… |
|
|
| --------------------------------------- | ----------------------------------------------------------------- |
|
|
| Add a new business concept | New folder under `domains/` following the convention above |
|
|
| Add a type used by multiple domains | `shared-kernel/` with a descriptive file name |
|
|
| Add a UI component for a domain feature | `domains/<name>/feature/` or `domains/<name>/ui/` |
|
|
| Add a settings subpanel | `domains/<name>/feature/settings/` |
|
|
| Add a top-level page or shell component | `features/` |
|
|
| Add persistence logic | `infrastructure/persistence/` or `domains/<name>/infrastructure/` |
|
|
| Add realtime/WebRTC logic | `infrastructure/realtime/` |
|