# bahaaalweisy/filestorageservice architecture

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

- Interactive diagram: https://gitdiagram.com/bahaaalweisy/filestorageservice
- Repository: https://github.com/bahaaalweisy/filestorageservice

## Overview

File Storage Service provides an Angular file-management UI backed by an ASP.NET Core API, SQL Server metadata, and local filesystem content. Users sign in with a demo role, upload files normally or in resumable chunks, then list, preview, download, and soft-delete files; admins can inspect and permanently remove deleted files. The README documents audit logging, health checks, and storage/database reconciliation as additional capabilities. API wiring and several implementation links are based on sampled source; documented but unsampled internals are represented at their enclosing paths.

Main entry points: [`src/FileStorage.Application/Files/UseCases/UploadFileService.cs`](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Files/UseCases/UploadFileService.cs) (File upload use case), [`src/FileStorage.Infrastructure/Persistence/StoredObjectRepository.cs`](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/StoredObjectRepository.cs) (File metadata repository), [`src/FileStorage.Infrastructure/Storage/FileSystemStorage.cs`](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Storage/FileSystemStorage.cs) (Filesystem content store), [`src/FileStorage.Application/Uploads/ResumableUploadService.cs`](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Uploads/ResumableUploadService.cs) (Resumable upload workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Angular frontend"]
  node_login["Login screen<br/>[login.component.ts]"]
  node_authui["Session and auth"]
  node_storagepage["Storage page"]
  node_filelist["File list and preview"]
  node_uploadui["Upload UI"]
  node_filesclient["Files API client<br/>[files.service.ts]"]
  node_resumableclient["Resumable upload client"]
end

subgraph group_api["API and identity"]
  node_authapi["Auth controller<br/>[AuthController.cs]"]
  node_filesapi["Files controller<br/>[FilesController.cs]"]
  node_uploadendpoint["Streaming upload endpoint"]
  node_sessionsapi["Upload sessions controller"]
  node_auditapi["Audit log controller"]
  node_authcore["JWT and current user<br/>[Auth]"]
end

subgraph group_application["Application workflows"]
  node_uploaduse["File upload use case"]
  node_fileuse["List, access, delete<br/>[UseCases]"]
  node_resumableuse["Resumable upload workflow"]
  node_audituse["Audit query and writing<br/>[Audit]"]
  node_domain["File and session model<br/>[FileStorage.Domain]"]
end

subgraph group_infrastructure["Persistence and storage"]
  node_filerepo["File metadata repository"]
  node_sessionrepo["Upload session repository"]
  node_db[("SQL Server<br/>[AppDbContext.cs]")]
  node_filestorage["Filesystem content store"]
  node_filesystem[("Storage root")]
  node_auditinfra["Audit persistence<br/>[Audit]"]
  node_auditdb[("Audit records<br/>[AppDbContext.cs]")]
end

subgraph group_operations["Operations"]
  node_reconcile["Reconciliation workflow"]
  node_reconcilecmd["Reconcile command"]
  node_inventory["Filesystem inventory"]
  node_health["Readiness checks"]
end

node_person(("User / admin"))

node_person -->|"chooses role"| node_login
node_login -->|"signs in"| node_authui
node_authui -->|"requests token"| node_authapi
node_authapi -->|"issues JWT"| node_authcore
node_person -->|"manages files"| node_storagepage
node_storagepage -->|"shows files"| node_filelist
node_storagepage -->|"offers upload"| node_uploadui
node_filelist -->|"loads and acts"| node_filesclient
node_uploadui -->|"uploads files"| node_filesclient
node_uploadui -->|"uploads chunks"| node_resumableclient
node_filesclient -->|"requests files"| node_filesapi
node_resumableclient -->|"manages sessions"| node_sessionsapi
node_filesapi -->|"lists and accesses"| node_fileuse
node_filesapi -->|"deletes files"| node_uploaduse
node_uploadendpoint -->|"stores upload"| node_uploaduse
node_sessionsapi -->|"runs workflow"| node_resumableuse
node_uploaduse -->|"persists metadata"| node_filerepo
node_uploaduse -->|"stages content"| node_filestorage
node_uploaduse -->|"creates file model"| node_domain
node_fileuse -->|"reads and updates"| node_filerepo
node_fileuse -->|"reads or deletes"| node_filestorage
node_resumableuse -->|"tracks sessions"| node_sessionrepo
node_resumableuse -->|"appends and commits"| node_filestorage
node_resumableuse -->|"saves finalized file"| node_filerepo
node_filerepo -->|"reads and writes"| node_db
node_sessionrepo -->|"reads and writes"| node_db
node_filestorage -->|"stores content"| node_filesystem
node_auditapi -->|"queries audit"| node_audituse
node_audituse -->|"reads or writes"| node_auditinfra
node_auditinfra -->|"persists records"| node_auditdb
node_reconcilecmd -->|"runs reconciliation"| node_reconcile
node_reconcile -->|"enumerates content"| node_inventory
node_reconcile -->|"compares metadata"| node_filerepo
node_inventory -->|"scans content"| node_filesystem
node_health -->|"probes storage"| node_filestorage

click node_login "https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/login/login.component.ts"
click node_authui "https://github.com/bahaaalweisy/filestorageservice/tree/master/frontend/src/app/core/auth"
click node_storagepage "https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/storage/storage-page.component.ts"
click node_filelist "https://github.com/bahaaalweisy/filestorageservice/tree/master/frontend/src/app/storage/list"
click node_uploadui "https://github.com/bahaaalweisy/filestorageservice/tree/master/frontend/src/app/storage/upload"
click node_filesclient "https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/storage/services/files.service.ts"
click node_resumableclient "https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/storage/services/resumable-upload.service.ts"
click node_authapi "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/AuthController.cs"
click node_filesapi "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/FilesController.cs"
click node_uploadendpoint "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Files/FileUploadEndpoint.cs"
click node_sessionsapi "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/UploadSessionsController.cs"
click node_auditapi "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/AuditLogController.cs"
click node_authcore "https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Api/Auth"
click node_uploaduse "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Files/UseCases/UploadFileService.cs"
click node_fileuse "https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Application/Files/UseCases"
click node_resumableuse "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Uploads/ResumableUploadService.cs"
click node_audituse "https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Application/Audit"
click node_domain "https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Domain"
click node_filerepo "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/StoredObjectRepository.cs"
click node_sessionrepo "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/UploadSessionRepository.cs"
click node_db "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/AppDbContext.cs"
click node_filestorage "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Storage/FileSystemStorage.cs"
click node_auditinfra "https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Infrastructure/Audit"
click node_auditdb "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/AppDbContext.cs"
click node_reconcile "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Maintenance/ReconciliationService.cs"
click node_reconcilecmd "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Maintenance/ReconcileCommand.cs"
click node_inventory "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Storage/FileSystemStorageInventory.cs"
click node_health "https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/HealthChecks/FilesystemHealthCheck.cs"

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_login,node_authui,node_storagepage,node_filelist,node_uploadui,node_filesclient,node_resumableclient,node_person toneBlue
class node_authapi,node_filesapi,node_uploadendpoint,node_sessionsapi,node_auditapi,node_authcore toneAmber
class node_uploaduse,node_fileuse,node_resumableuse,node_audituse,node_domain toneMint
class node_filerepo,node_sessionrepo,node_db,node_filestorage,node_filesystem,node_auditinfra,node_auditdb toneRose
class node_reconcile,node_reconcilecmd,node_inventory,node_health toneIndigo
```

## Components

### Angular frontend

- [Login screen](https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/login/login.component.ts): `frontend/src/app/login/login.component.ts`
- [Session and auth](https://github.com/bahaaalweisy/filestorageservice/tree/master/frontend/src/app/core/auth): `frontend/src/app/core/auth`
- [Storage page](https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/storage/storage-page.component.ts): `frontend/src/app/storage/storage-page.component.ts`
- [File list and preview](https://github.com/bahaaalweisy/filestorageservice/tree/master/frontend/src/app/storage/list): `frontend/src/app/storage/list`
- [Upload UI](https://github.com/bahaaalweisy/filestorageservice/tree/master/frontend/src/app/storage/upload): `frontend/src/app/storage/upload`
- [Files API client](https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/storage/services/files.service.ts): `frontend/src/app/storage/services/files.service.ts`
- [Resumable upload client](https://github.com/bahaaalweisy/filestorageservice/blob/master/frontend/src/app/storage/services/resumable-upload.service.ts): `frontend/src/app/storage/services/resumable-upload.service.ts`

### API and identity

- [Auth controller](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/AuthController.cs): `src/FileStorage.Api/Controllers/AuthController.cs`
- [Files controller](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/FilesController.cs): `src/FileStorage.Api/Controllers/FilesController.cs`
- [Streaming upload endpoint](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Files/FileUploadEndpoint.cs): `src/FileStorage.Api/Files/FileUploadEndpoint.cs`
- [Upload sessions controller](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/UploadSessionsController.cs): `src/FileStorage.Api/Controllers/UploadSessionsController.cs`
- [Audit log controller](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Controllers/AuditLogController.cs): `src/FileStorage.Api/Controllers/AuditLogController.cs`
- [JWT and current user](https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Api/Auth): `src/FileStorage.Api/Auth`

### Application workflows

- [File upload use case](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Files/UseCases/UploadFileService.cs): `src/FileStorage.Application/Files/UseCases/UploadFileService.cs`
- [List, access, delete](https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Application/Files/UseCases): `src/FileStorage.Application/Files/UseCases`
- [Resumable upload workflow](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Uploads/ResumableUploadService.cs): `src/FileStorage.Application/Uploads/ResumableUploadService.cs`
- [Audit query and writing](https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Application/Audit): `src/FileStorage.Application/Audit`
- [File and session model](https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Domain): `src/FileStorage.Domain`

### Persistence and storage

- [File metadata repository](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/StoredObjectRepository.cs): `src/FileStorage.Infrastructure/Persistence/StoredObjectRepository.cs`
- [Upload session repository](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/UploadSessionRepository.cs): `src/FileStorage.Infrastructure/Persistence/UploadSessionRepository.cs`
- [SQL Server](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/AppDbContext.cs): `src/FileStorage.Infrastructure/Persistence/AppDbContext.cs`
- [Filesystem content store](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Storage/FileSystemStorage.cs): `src/FileStorage.Infrastructure/Storage/FileSystemStorage.cs`
- **Storage root**
- [Audit persistence](https://github.com/bahaaalweisy/filestorageservice/tree/master/src/FileStorage.Infrastructure/Audit): `src/FileStorage.Infrastructure/Audit`
- [Audit records](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Persistence/AppDbContext.cs): `src/FileStorage.Infrastructure/Persistence/AppDbContext.cs`

### Operations

- [Reconciliation workflow](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Application/Maintenance/ReconciliationService.cs): `src/FileStorage.Application/Maintenance/ReconciliationService.cs`
- [Reconcile command](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/Maintenance/ReconcileCommand.cs): `src/FileStorage.Api/Maintenance/ReconcileCommand.cs`
- [Filesystem inventory](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Infrastructure/Storage/FileSystemStorageInventory.cs): `src/FileStorage.Infrastructure/Storage/FileSystemStorageInventory.cs`
- [Readiness checks](https://github.com/bahaaalweisy/filestorageservice/blob/master/src/FileStorage.Api/HealthChecks/FilesystemHealthCheck.cs): `src/FileStorage.Api/HealthChecks/FilesystemHealthCheck.cs`

### Other components

- **User / admin**

## Connections

- User / admin → Login screen: chooses role
- Login screen → Session and auth: signs in
- Session and auth → Auth controller: requests token
- Auth controller → JWT and current user: issues JWT
- User / admin → Storage page: manages files
- Storage page → File list and preview: shows files
- Storage page → Upload UI: offers upload
- File list and preview → Files API client: loads and acts
- Upload UI → Files API client: uploads files
- Upload UI → Resumable upload client: uploads chunks
- Files API client → Files controller: requests files
- Resumable upload client → Upload sessions controller: manages sessions
- Files controller → List, access, delete: lists and accesses
- Files controller → File upload use case: deletes files
- Streaming upload endpoint → File upload use case: stores upload
- Upload sessions controller → Resumable upload workflow: runs workflow
- File upload use case → File metadata repository: persists metadata
- File upload use case → Filesystem content store: stages content
- File upload use case → File and session model: creates file model
- List, access, delete → File metadata repository: reads and updates
- List, access, delete → Filesystem content store: reads or deletes
- Resumable upload workflow → Upload session repository: tracks sessions
- Resumable upload workflow → Filesystem content store: appends and commits
- Resumable upload workflow → File metadata repository: saves finalized file
- File metadata repository → SQL Server: reads and writes
- Upload session repository → SQL Server: reads and writes
- Filesystem content store → Storage root: stores content
- Audit log controller → Audit query and writing: queries audit
- Audit query and writing → Audit persistence: reads or writes
- Audit persistence → Audit records: persists records
- Reconcile command → Reconciliation workflow: runs reconciliation
- Reconciliation workflow → Filesystem inventory: enumerates content
- Reconciliation workflow → File metadata repository: compares metadata
- Filesystem inventory → Storage root: scans content
- Readiness checks → Filesystem content store: probes storage
