# m4tc0des/westmarchbook architecture

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

- Interactive diagram: https://gitdiagram.com/m4tc0des/westmarchbook
- Repository: https://github.com/m4tc0des/westmarchbook

## Overview

WestmarchBook manages a literary catalog and reader accounts through a .NET backend and a MAUI desktop application. The main workflow is an operator using the desktop interface to manage books and readers; the API exposes corresponding catalog, account, and authentication operations. Application use cases separate requests from persistence, with EF Core providing storage. The tree also shows rent registration and publisher/author management. Several use-case implementations and desktop networking details were not excerpted, so those internal links are omitted or marked unverified rather than inferred as confirmed calls.

Main entry points: [`src/Backend/WestmarchBook.Domain/Repositories`](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Domain/Repositories) (Repository contracts), [`src/Backend/WestmarchBook.Api/Program.cs`](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Program.cs) (API routing), [`src/Backend/WestmarchBook.Api/Controllers/AuthenticationController.cs`](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/AuthenticationController.cs) (Authentication), [`src/Backend/WestmarchBook.Application/UseCases/User`](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/User) (User workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop application"]
  node_desktopui["Desktop interface<br/>[MainWindow.xaml.cs]"]
  node_desktopvm["Catalog and readers<br/>[MainViewModel.cs]"]
  node_loginvm["Desktop login<br/>[LoginViewModel.cs]"]
  node_desktop_token["Desktop token"]
end

subgraph group_api["REST API"]
  node_api_routes["API routing<br/>[Program.cs]"]
  node_auth["Authentication"]
  node_books_api["Book endpoints<br/>[BooksController.cs]"]
  node_users_api["User endpoints<br/>[UsersController.cs]"]
  node_authors_api["Author endpoints"]
  node_readers_api["Reader endpoints"]
end

subgraph group_application["Application workflows"]
  node_catalog_cases["Catalog use cases<br/>[Book]"]
  node_author_cases["Author use cases<br/>[Author]"]
  node_publisher_cases["Publisher use cases<br/>[Publisher]"]
  node_reader_cases["Reader use cases<br/>[Readers]"]
  node_rent_cases["Rent registration<br/>[Rent]"]
  node_user_cases["User workflows<br/>[User]"]
end

subgraph group_domain["Domain contracts"]
  node_book_domain["Book model<br/>[Book.cs]"]
  node_user_domain["User model<br/>[User.cs]"]
  node_repository_contracts["Repository contracts<br/>[Repositories]"]
end

subgraph group_persistence["Persistence"]
  node_ef_repositories["EF repositories<br/>[Repositories]"]
  node_dbcontext[("EF data context")]
  node_jwt["JWT handler<br/>[JwtTokenHandler.cs]"]
end

node_operator(("Library operator"))

node_operator -->|"uses"| node_desktopui
node_desktopui -->|"displays"| node_desktopvm
node_desktopvm -->|"clears token"| node_desktop_token
node_operator -.->|"API client"| node_api_routes
node_api_routes -->|"maps controllers"| node_auth
node_api_routes -->|"maps controllers"| node_books_api
node_api_routes -->|"maps controllers"| node_users_api
node_books_api -->|"executes"| node_catalog_cases
node_authors_api -->|"executes"| node_author_cases
node_readers_api -->|"executes"| node_reader_cases
node_users_api -->|"executes"| node_user_cases
node_auth -->|"executes"| node_user_cases
node_catalog_cases -.->|"uses"| node_repository_contracts
node_author_cases -.->|"uses"| node_repository_contracts
node_publisher_cases -.->|"uses"| node_repository_contracts
node_reader_cases -.->|"uses"| node_repository_contracts
node_rent_cases -.->|"uses"| node_repository_contracts
node_user_cases -.->|"uses"| node_repository_contracts
node_repository_contracts -.->|"implemented by"| node_ef_repositories
node_ef_repositories -->|"queries and writes"| node_dbcontext
node_dbcontext -->|"maps entity"| node_book_domain
node_api_routes -->|"checks token user"| node_repository_contracts
node_auth -.->|"issues token"| node_jwt
node_loginvm -.->|"stores token"| node_desktop_token

click node_desktopui "https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/Views/MainWindow.xaml.cs"
click node_desktopvm "https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/ViewModels/MainViewModel.cs"
click node_loginvm "https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/ViewModels/LoginViewModel.cs"
click node_desktop_token "https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/Services/DesktopTokenProvider.cs"
click node_api_routes "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Program.cs"
click node_auth "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/AuthenticationController.cs"
click node_books_api "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/BooksController.cs"
click node_users_api "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/UsersController.cs"
click node_authors_api "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/AuthorsController.cs"
click node_readers_api "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/ReadersController.cs"
click node_catalog_cases "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Book"
click node_author_cases "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Author"
click node_publisher_cases "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Publisher"
click node_reader_cases "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Readers"
click node_rent_cases "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Rent"
click node_user_cases "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/User"
click node_book_domain "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Domain/Entities/Book.cs"
click node_user_domain "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Domain/Entities/User.cs"
click node_repository_contracts "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Domain/Repositories"
click node_ef_repositories "https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Infrastructure/DataAccess/Repositories"
click node_dbcontext "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Infrastructure/DataAccess/WestmarchBookDbContext.cs"
click node_jwt "https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Infrastructure/Security/Tokens/Access/JwtTokenHandler.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_desktopui,node_desktopvm,node_loginvm,node_desktop_token toneBlue
class node_api_routes,node_auth,node_books_api,node_users_api,node_authors_api,node_readers_api toneAmber
class node_catalog_cases,node_author_cases,node_publisher_cases,node_reader_cases,node_rent_cases,node_user_cases toneMint
class node_book_domain,node_user_domain,node_repository_contracts toneRose
class node_ef_repositories,node_dbcontext,node_jwt,node_operator toneIndigo
```

## Components

### Desktop application

- [Desktop interface](https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/Views/MainWindow.xaml.cs): `src/Frontend/WestmarchBook.Desktop/Views/MainWindow.xaml.cs`
- [Catalog and readers](https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/ViewModels/MainViewModel.cs): `src/Frontend/WestmarchBook.Desktop/ViewModels/MainViewModel.cs`
- [Desktop login](https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/ViewModels/LoginViewModel.cs): `src/Frontend/WestmarchBook.Desktop/ViewModels/LoginViewModel.cs`
- [Desktop token](https://github.com/m4tc0des/westmarchbook/blob/master/src/Frontend/WestmarchBook.Desktop/Services/DesktopTokenProvider.cs): `src/Frontend/WestmarchBook.Desktop/Services/DesktopTokenProvider.cs`

### REST API

- [API routing](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Program.cs): `src/Backend/WestmarchBook.Api/Program.cs`
- [Authentication](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/AuthenticationController.cs): `src/Backend/WestmarchBook.Api/Controllers/AuthenticationController.cs`
- [Book endpoints](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/BooksController.cs): `src/Backend/WestmarchBook.Api/Controllers/BooksController.cs`
- [User endpoints](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/UsersController.cs): `src/Backend/WestmarchBook.Api/Controllers/UsersController.cs`
- [Author endpoints](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/AuthorsController.cs): `src/Backend/WestmarchBook.Api/Controllers/AuthorsController.cs`
- [Reader endpoints](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Api/Controllers/ReadersController.cs): `src/Backend/WestmarchBook.Api/Controllers/ReadersController.cs`

### Application workflows

- [Catalog use cases](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Book): `src/Backend/WestmarchBook.Application/UseCases/Book`
- [Author use cases](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Author): `src/Backend/WestmarchBook.Application/UseCases/Author`
- [Publisher use cases](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Publisher): `src/Backend/WestmarchBook.Application/UseCases/Publisher`
- [Reader use cases](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Readers): `src/Backend/WestmarchBook.Application/UseCases/Readers`
- [Rent registration](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/Rent): `src/Backend/WestmarchBook.Application/UseCases/Rent`
- [User workflows](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Application/UseCases/User): `src/Backend/WestmarchBook.Application/UseCases/User`

### Domain contracts

- [Book model](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Domain/Entities/Book.cs): `src/Backend/WestmarchBook.Domain/Entities/Book.cs`
- [User model](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Domain/Entities/User.cs): `src/Backend/WestmarchBook.Domain/Entities/User.cs`
- [Repository contracts](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Domain/Repositories): `src/Backend/WestmarchBook.Domain/Repositories`

### Persistence

- [EF repositories](https://github.com/m4tc0des/westmarchbook/tree/master/src/Backend/WestmarchBook.Infrastructure/DataAccess/Repositories): `src/Backend/WestmarchBook.Infrastructure/DataAccess/Repositories`
- [EF data context](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Infrastructure/DataAccess/WestmarchBookDbContext.cs): `src/Backend/WestmarchBook.Infrastructure/DataAccess/WestmarchBookDbContext.cs`
- [JWT handler](https://github.com/m4tc0des/westmarchbook/blob/master/src/Backend/WestmarchBook.Infrastructure/Security/Tokens/Access/JwtTokenHandler.cs): `src/Backend/WestmarchBook.Infrastructure/Security/Tokens/Access/JwtTokenHandler.cs`

### Other components

- **Library operator**

## Connections

- Library operator → Desktop interface: uses (evidence: `src/Frontend/WestmarchBook.Desktop/Views/MainWindow.xaml.cs`)
- Desktop interface → Catalog and readers: displays (evidence: `src/Frontend/WestmarchBook.Desktop/Views/MainWindow.xaml.cs`)
- Catalog and readers → Desktop token: clears token (evidence: `src/Frontend/WestmarchBook.Desktop/ViewModels/MainViewModel.cs`)
- Library operator → API routing: API client
- API routing → Authentication: maps controllers (evidence: `src/Backend/WestmarchBook.Api/Program.cs`)
- API routing → Book endpoints: maps controllers (evidence: `src/Backend/WestmarchBook.Api/Program.cs`)
- API routing → User endpoints: maps controllers (evidence: `src/Backend/WestmarchBook.Api/Program.cs`)
- Book endpoints → Catalog use cases: executes (evidence: `src/Backend/WestmarchBook.Api/Controllers/BooksController.cs`)
- Author endpoints → Author use cases: executes (evidence: `src/Backend/WestmarchBook.Api/Controllers/AuthorsController.cs`)
- Reader endpoints → Reader use cases: executes (evidence: `src/Backend/WestmarchBook.Api/Controllers/ReadersController.cs`)
- User endpoints → User workflows: executes (evidence: `src/Backend/WestmarchBook.Api/Controllers/UsersController.cs`)
- Authentication → User workflows: executes (evidence: `src/Backend/WestmarchBook.Api/Controllers/AuthenticationController.cs`)
- Catalog use cases → Repository contracts: uses
- Author use cases → Repository contracts: uses
- Publisher use cases → Repository contracts: uses
- Reader use cases → Repository contracts: uses
- Rent registration → Repository contracts: uses
- User workflows → Repository contracts: uses
- Repository contracts → EF repositories: implemented by (evidence: `src/Backend/WestmarchBook.Infrastructure/DataAccess/Repositories/AuthorRepository.cs`)
- EF repositories → EF data context: queries and writes (evidence: `src/Backend/WestmarchBook.Infrastructure/DataAccess/Repositories/AuthorRepository.cs`)
- EF data context → Book model: maps entity (evidence: `src/Backend/WestmarchBook.Infrastructure/DataAccess/WestmarchBookDbContext.cs`)
- API routing → Repository contracts: checks token user (evidence: `src/Backend/WestmarchBook.Api/Program.cs`)
- Authentication → JWT handler: issues token
- Desktop login → Desktop token: stores token (evidence: `src/Frontend/WestmarchBook.Desktop/ViewModels/LoginViewModel.cs`)
