English
Topic 3. The domain model: entities for users, chats, members, messages and attachments
Goal: turn the features of the messenger into a set of C# classes — the entities — that describe users, profiles, refresh tokens, chats, memberships, messages and attachments with their relationships, identifiers, timestamps and the small rules that belong to the data itself.
Where we are
We start the data layer, the bottom of the architecture (Fig. 3.1). This topic writes plain C# classes; topic 4 tells EF Core how to store them in PostgreSQL.
Fig. 3.1. The domain model belongs to the data layer
- Starting point: topic 2 — the solution builds, PostgreSQL runs in Docker.
- At the end of the topic Chatex.Data contains ten files in the folder
Entities, the solution builds with zero warnings, and a small program shows how the entities behave.
Steps
- From features to entities — finding the entities · relationships · identifiers · timestamps · where rules belong
- Users, profiles and tokens — ASP.NET Core Identity ·
User·UserProfile·RefreshToken - Chats and members — chat types and roles ·
Chatand its direct key ·ChatMemberand its read position - Messages and attachments —
Messagewith replies and soft delete ·Attachmentuploaded before sending · trying the model - Checkpoint — what must work, self-check questions and exercises
Materials
- Course slides, part 2, Data: PostgreSQL and EF Core (slides "The data model", "Key columns of the chat tables", "Chat types and roles", "An entity with behaviour")
Source/Chatex.Data/Entities– the entitiesDocs/DataModel.md– the data modelDocs/ChatRules.md– chat types, roles and permissions