# ordreflow/ordreflow-backend architecture

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

- Interactive diagram: https://gitdiagram.com/ordreflow/ordreflow-backend
- Repository: https://github.com/ordreflow/ordreflow-backend

## Overview

This is a .NET backend for managing users, orders and tasks, and employee time registration with manager review. The principal workflow is an HTTP request entering an endpoint, being dispatched to an application handler, applying domain rules, and using repository abstractions backed by persistence. Separate capabilities include user administration, work assignment, weekly time views, review and export, and top-orders reporting. Relationships below follow the README and shown endpoint/domain evidence; unsampled handler and persistence links are marked unverified where appropriate.

Main entry points: [`Backend/Application/Handlers`](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers) (Action handlers), [`Backend/WebApi/Endpoints`](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/WebApi/Endpoints) (HTTP endpoints), [`Backend/Domain/Aggregate/TimeEntry.cs`](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/TimeEntry.cs) (Time entry lifecycle), [`Backend/Domain/Entities/Task.cs`](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Entities/Task.cs) (Task lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_endpoints["HTTP endpoints"]
  node_auth["Authorization"]
  node_mapping["API mapping<br/>[ObjectMapper.cs]"]
end

subgraph group_app["Application actions"]
  node_dispatcher["Command dispatch<br/>[Dispatcher.cs]"]
  node_handlers["Action handlers"]
  node_queries["Query handlers"]
  node_useradmin["User administration"]
  node_work["Orders and tasks"]
  node_registration["Time registration"]
  node_review["Time review"]
  node_reporting["Reports and export"]
end

subgraph group_domain["Domain model"]
  node_users["User aggregate<br/>[User.cs]"]
  node_order["Order aggregate<br/>[Order.cs]"]
  node_task["Task lifecycle<br/>[Task.cs]"]
  node_timeentry["Time entry lifecycle<br/>[TimeEntry.cs]"]
  node_reviewdomain["Review rules"]
  node_contracts["Repository contracts"]
  node_results["Operation results<br/>[Result.cs]"]
end

subgraph group_infra["Persistence and services"]
  node_repositories["Repositories"]
  node_context["EF Core context<br/>[AppDbContext.cs]"]
  node_database[("PostgreSQL")]
  node_tokens["JWT tokens"]
end

node_client(("API client"))

node_client -->|"sends HTTP"| node_endpoints
node_endpoints -->|"checks policy"| node_auth
node_endpoints -->|"dispatches command"| node_dispatcher
node_endpoints -.->|"maps models"| node_mapping
node_dispatcher -->|"resolves handler"| node_handlers
node_handlers -.->|"applies user rules"| node_users
node_handlers -.->|"applies order rules"| node_order
node_handlers -.->|"applies task rules"| node_task
node_handlers -.->|"applies entry rules"| node_timeentry
node_handlers -.->|"uses repositories"| node_contracts
node_queries -.->|"queries repositories"| node_contracts
node_useradmin -.->|"enforces permissions"| node_users
node_work -.->|"manages orders"| node_order
node_work -.->|"manages tasks"| node_task
node_registration -.->|"creates and edits"| node_timeentry
node_review -.->|"reviews entries"| node_timeentry
node_review -.->|"applies review rules"| node_reviewdomain
node_reporting -.->|"requests report data"| node_repositories
node_contracts -.->|"implemented by"| node_repositories
node_repositories -.->|"reads and writes"| node_context
node_context -.->|"persists data"| node_database
node_endpoints -.->|"authenticates users"| node_tokens
node_handlers -.->|"returns outcomes"| node_results
node_timeentry -->|"validates transitions"| node_results
node_task -->|"validates lifecycle"| node_results

click node_endpoints "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/WebApi/Endpoints"
click node_auth "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/WebApi/Authentication/AuthorizationPolicies.cs"
click node_mapping "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/ObjectMapper/ObjectMapper.cs"
click node_dispatcher "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Application/Dispatcher.cs"
click node_handlers "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers"
click node_queries "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers"
click node_useradmin "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/UserHandlers"
click node_work "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/TaskHandlers"
click node_registration "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/TimeEntryHandlers"
click node_review "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/TimeEntryHandlers"
click node_reporting "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Application/Handlers/GetTopOrdersHandler.cs"
click node_users "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/User.cs"
click node_order "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/Order.cs"
click node_task "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Entities/Task.cs"
click node_timeentry "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/TimeEntry.cs"
click node_reviewdomain "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Services/TimeEntryReviewDomainService.cs"
click node_contracts "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Domain/Interfaces"
click node_repositories "https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Persistence/Repositories"
click node_context "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Persistence/AppDbContext.cs"
click node_tokens "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/WebApi/Authentication/JwtTokenGenerator.cs"
click node_results "https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/OperationResultPattern/Result.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_endpoints,node_auth,node_mapping,node_client toneBlue
class node_dispatcher,node_handlers,node_queries,node_useradmin,node_work,node_registration,node_review,node_reporting toneAmber
class node_users,node_order,node_task,node_timeentry,node_reviewdomain,node_contracts,node_results toneMint
class node_repositories,node_context,node_database,node_tokens toneRose
```

## Components

### HTTP API

- [HTTP endpoints](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/WebApi/Endpoints): `Backend/WebApi/Endpoints`
- [Authorization](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/WebApi/Authentication/AuthorizationPolicies.cs): `Backend/WebApi/Authentication/AuthorizationPolicies.cs`
- [API mapping](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/ObjectMapper/ObjectMapper.cs): `Backend/ObjectMapper/ObjectMapper.cs`

### Application actions

- [Command dispatch](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Application/Dispatcher.cs): `Backend/Application/Dispatcher.cs`
- [Action handlers](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers): `Backend/Application/Handlers`
- [Query handlers](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers): `Backend/Application/Handlers`
- [User administration](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/UserHandlers): `Backend/Application/Handlers/UserHandlers`
- [Orders and tasks](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/TaskHandlers): `Backend/Application/Handlers/TaskHandlers`
- [Time registration](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/TimeEntryHandlers): `Backend/Application/Handlers/TimeEntryHandlers`
- [Time review](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Application/Handlers/TimeEntryHandlers): `Backend/Application/Handlers/TimeEntryHandlers`
- [Reports and export](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Application/Handlers/GetTopOrdersHandler.cs): `Backend/Application/Handlers/GetTopOrdersHandler.cs`

### Domain model

- [User aggregate](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/User.cs): `Backend/Domain/Aggregate/User.cs`
- [Order aggregate](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/Order.cs): `Backend/Domain/Aggregate/Order.cs`
- [Task lifecycle](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Entities/Task.cs): `Backend/Domain/Entities/Task.cs`
- [Time entry lifecycle](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Aggregate/TimeEntry.cs): `Backend/Domain/Aggregate/TimeEntry.cs`
- [Review rules](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Domain/Services/TimeEntryReviewDomainService.cs): `Backend/Domain/Services/TimeEntryReviewDomainService.cs`
- [Repository contracts](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Domain/Interfaces): `Backend/Domain/Interfaces`
- [Operation results](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/OperationResultPattern/Result.cs): `Backend/OperationResultPattern/Result.cs`

### Persistence and services

- [Repositories](https://github.com/ordreflow/ordreflow-backend/tree/main/Backend/Persistence/Repositories): `Backend/Persistence/Repositories`
- [EF Core context](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/Persistence/AppDbContext.cs): `Backend/Persistence/AppDbContext.cs`
- **PostgreSQL**
- [JWT tokens](https://github.com/ordreflow/ordreflow-backend/blob/main/Backend/WebApi/Authentication/JwtTokenGenerator.cs): `Backend/WebApi/Authentication/JwtTokenGenerator.cs`

### Other components

- **API client**

## Connections

- API client → HTTP endpoints: sends HTTP (evidence: `README.md`)
- HTTP endpoints → Authorization: checks policy (evidence: `Backend/WebApi/Endpoints/Users/AssignManager.cs`)
- HTTP endpoints → Command dispatch: dispatches command (evidence: `Backend/WebApi/Endpoints/Users/AssignManager.cs`)
- HTTP endpoints → API mapping: maps models (evidence: `README.md`)
- Command dispatch → Action handlers: resolves handler (evidence: `README.md`)
- Action handlers → User aggregate: applies user rules
- Action handlers → Order aggregate: applies order rules
- Action handlers → Task lifecycle: applies task rules (evidence: `Backend/Application/Handlers/TimeEntryHandlers/GetTimeEntryReviewsHandler.cs`)
- Action handlers → Time entry lifecycle: applies entry rules (evidence: `Backend/Application/Handlers/TimeEntryHandlers/GetManagerTimeEntriesHandler.cs`)
- Action handlers → Repository contracts: uses repositories (evidence: `README.md`)
- Query handlers → Repository contracts: queries repositories (evidence: `README.md`)
- User administration → User aggregate: enforces permissions
- Orders and tasks → Order aggregate: manages orders
- Orders and tasks → Task lifecycle: manages tasks
- Time registration → Time entry lifecycle: creates and edits (evidence: `Backend/Application/Handlers/TimeEntryHandlers/GetManagerTimeEntriesHandler.cs`)
- Time review → Time entry lifecycle: reviews entries (evidence: `Backend/Application/Handlers/TimeEntryHandlers/GetManagerTimeEntriesHandler.cs`)
- Time review → Review rules: applies review rules
- Reports and export → Repositories: requests report data
- Repository contracts → Repositories: implemented by (evidence: `README.md`)
- Repositories → EF Core context: reads and writes (evidence: `README.md`)
- EF Core context → PostgreSQL: persists data (evidence: `README.md`)
- HTTP endpoints → JWT tokens: authenticates users
- Action handlers → Operation results: returns outcomes (evidence: `README.md`)
- Time entry lifecycle → Operation results: validates transitions (evidence: `Backend/Domain/Aggregate/TimeEntry.cs`)
- Task lifecycle → Operation results: validates lifecycle (evidence: `Backend/Domain/Entities/Task.cs`)
