init
This commit is contained in:
commit
ab2e20f7e1
72 changed files with 2000 additions and 0 deletions
98
Femto.Docs/Design/MediaUpload/PostMediaClaimFlow.md
Normal file
98
Femto.Docs/Design/MediaUpload/PostMediaClaimFlow.md
Normal file
|
@ -0,0 +1,98 @@
|
|||
~~**Design Specification: Post Creation with Media Claiming in a Modular Monolith (DDD + MediatR)**
|
||||
|
||||
---
|
||||
|
||||
## 1. Overview
|
||||
This document describes the design of a feature that allows users to upload media files and later attach them to a Post within a modular monolith application. The system is built using Domain-Driven Design (DDD) principles and uses MediatR for in-process communication between modules.
|
||||
|
||||
---
|
||||
|
||||
## 2. Modules Involved
|
||||
|
||||
### a. Microblogging Module
|
||||
- Responsible for Post aggregate lifecycle.
|
||||
- Attaches media to posts based on Media IDs.
|
||||
|
||||
### b. MediaManagement Module
|
||||
- Handles file uploads and MediaUpload entity lifecycle.
|
||||
- Validates and claims media for Posts.
|
||||
|
||||
---
|
||||
|
||||
## 3. Key Entities
|
||||
|
||||
### Post (Aggregate Root)
|
||||
- Properties: Id, AuthorId, Content, List<MediaItem>
|
||||
- Methods: AttachMedia(MediaItem), Create(), etc.
|
||||
|
||||
### MediaItem (Owned Entity)
|
||||
- Properties: MediaId, Uri, Type, AltText, Order
|
||||
|
||||
### MediaUpload (Entity in MediaManagement)
|
||||
- Properties: Id, UploaderId, Uri, MimeType, Status (Unassigned, Attached), PostId (nullable)
|
||||
|
||||
---
|
||||
|
||||
## 4. Use Case Flow
|
||||
|
||||
### Step 1: Upload Media
|
||||
**Command**: `UploadMediaCommand`
|
||||
**Handler**: `UploadMediaHandler` (MediaManagement)
|
||||
|
||||
- Validates file and stores it.
|
||||
- Creates MediaUpload record with `Status = Unassigned`.
|
||||
- Returns `MediaId` to client.
|
||||
|
||||
### Step 2: Create Post
|
||||
**Command**: `CreatePostCommand`
|
||||
**Handler**: `CreatePostHandler` (Microblogging)
|
||||
|
||||
- Creates new Post aggregate.
|
||||
- For each referenced MediaId:
|
||||
- Sends `ClaimMediaRequest` command via MediatR.
|
||||
|
||||
### Step 3: Claim Media
|
||||
**Command**: `ClaimMediaRequest`
|
||||
**Handler**: `ClaimMediaHandler` (MediaManagement)
|
||||
|
||||
- Validates ownership and existence.
|
||||
- Updates `Status = Attached`, sets `PostId`.
|
||||
- Publishes `MediaClaimedEvent`.
|
||||
|
||||
### Step 4: Attach Media to Post
|
||||
**Event**: `MediaClaimedEvent`
|
||||
**Handler**: `MediaClaimedHandler` (Microblogging)
|
||||
|
||||
- Loads corresponding Post.
|
||||
- Calls `post.AttachMedia()`.
|
||||
- Saves updated Post.
|
||||
|
||||
---
|
||||
|
||||
## 5. Event & Command Definitions
|
||||
|
||||
### UploadMediaCommand
|
||||
- FileStream, FileName, MimeType, UploaderId
|
||||
|
||||
### CreatePostCommand
|
||||
- AuthorId, Content, List<MediaId>
|
||||
|
||||
### ClaimMediaRequest
|
||||
- MediaId, AuthorId, PostId
|
||||
|
||||
### MediaClaimedEvent
|
||||
- MediaId, PostId, Uri, Type, AltText
|
||||
|
||||
---
|
||||
|
||||
## 6. Rules and Invariants
|
||||
- Only the uploader can claim media.
|
||||
- Media can only be claimed once.
|
||||
- Posts only accept claimed media.
|
||||
|
||||
---
|
||||
|
||||
## 7. UML Diagrams
|
||||
|
||||
UML Diagrams for the described system are provided below.~~
|
||||
|
BIN
Femto.Docs/Design/MediaUpload/PostMediaClaimFlowDiagram.png
Normal file
BIN
Femto.Docs/Design/MediaUpload/PostMediaClaimFlowDiagram.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
10
Femto.Docs/Femto.Docs.csproj
Normal file
10
Femto.Docs/Femto.Docs.csproj
Normal file
|
@ -0,0 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
3
Femto.Docs/Program.cs
Normal file
3
Femto.Docs/Program.cs
Normal file
|
@ -0,0 +1,3 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
Loading…
Add table
Add a link
Reference in a new issue