# File Service Domain
## Files Aggregate
### Files Entity (Aggregate Root)
> [!NOTE] Name as Identifiers
> We are using `string` names as identifier instead of having some sort of `int` or `Guid` that is used to identify thinks such as `Application`, `Tenant`, `StorageProvider` ...etc.
> This is to make the information clean without the need to jump between tables and relations, also to make it possible to get these info from any source such as `appsettings` or `static-configs` if we need
> [!NOTE] Table Structure
> **TBD:** should we use single table to store file properties, or should we split them into `FileInformation`, `StorageInfomation`, `EntityInformation`, `ThumbnailInformation`
> **TBD:** Should we have a versions for the files and a table to store old version information or the versions are just another file and the versioning is left to the client (Integrated Service)
| Property Name | Type | Notes |
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Id` | `Guid` | |
| `Correlationid` | `Guid` | This Property should be used to prevent uploading the same file twice. |
| `Status` | `Enum` | `Temp`, `Stored`, `ScheduledForDelete`, `Deleted`, `Chunk [Future]` |
| `ExpireTime` | `DateTimeOffset` | The time when the file is considered expired and should be deleted |
| `FileAccess` | `Enum` | `Anonymous`, `Authorized` |
| `FileName` | `String` | Name without extension |
| `FileSize` | `long` | Size in bytes |
| `OriginalFileSize` | `long` | The size in bytes of the original uploaded file before any encoding or compression |
| `FileType` | `Enum` | Example: `Image`, `Document`, `Video`, `Audio` |
| `MimeType` | `String` | Example: `text/plain`, `image/png` |
| `OriginalMimeType` | `String` | The type of the original uploaded file before any encoding or compression |
| `FileExtension` | `String` | Example: `.pdf`, `.png` |
| `OriginalFileExtension` | `String` | The extension of the original uploaded file before any encoding or compression |
| `Application` | `String` | Example: Check |
| `Tenant` | `String` | Example: Dev |
| `Module` | `String` | Example: Survey |
| `Entity` | `String` | Example: Answers |
| `EntityId` | `String` | Example: `102`, `ceba03fc-9261-4179-a8d9-b8e49b3d2119` |
| `FileStorageProvider` | `String` | This value should contain a key used to detect which storage provider is used to store this file in case of having multiple storage configured on the app |
| `FileStorageIdentifier` | `(String\|JSON)` | The identifier used to access the file in the distributed storage provider such as NFS file path or bucket and directory in MinIO (*The value structure is dynamic and depends on the provider*) |
| `UserInformation` | TBD (Future) | When we implement the authentication we will add user information to the model, we will support two static meta-users`Anonymous`, `System` |
| `Labels/Tags` | TBD (Future) | We should be able to mark the files with special labels or tags which could be used in search, filters and reports |
| `Description` | `String` | This value should store some description of the file content if it was provided by the user |
| `ThumbnailSize` | `long` | Size in bytes |
| `ThumbnailStorageProvider` | `String` | This value should contain a key used to detect which storage provider is used to store this file in case of having multiple storage configured on the app |
| `ThumbnailStorageIdentifier` | `(String\|JSON)` | The identifier used to access the file in the distributed storage provider such as NFS file path or bucket and directory in MinIO (*The value structure is dynamic and depends on the provider*) |
## Settings Aggregate
- we will use app settings for now, but in the future release we will store the settings, modules, ...etc in the database