# bariskisir/onionnet architecture

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

- Interactive diagram: https://gitdiagram.com/bariskisir/onionnet
- Repository: https://github.com/bariskisir/onionnet

## Overview

OnionNet is a .NET API for JWT authentication and user-scoped notes, exposing the same domain operations through REST, gRPC, and JSON WebSocket messages. The main flow is client request → protocol handler → application service → repositories/unit of work → SQLite, with a response returned through the originating protocol. The graph includes the documented database-backed logging and startup migration capabilities. WebSocket message-processing internals and several infrastructure details were not sampled, so those links are limited to documented behavior.

Main entry points: [`src/OnionNet.Infrastructure/Repositories/UnitOfWork.cs`](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/UnitOfWork.cs) (Unit of work), [`src/OnionNet.Application/Services/AuthService.cs`](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Application/Services/AuthService.cs) (Auth service), [`src/OnionNet.Application/Services/NoteService.cs`](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Application/Services/NoteService.cs) (Notes service), [`src/OnionNet.Infrastructure/Repositories/Repository.cs`](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/Repository.cs) (Generic repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Protocol entry points"]
  node_restauth["Auth REST<br/>[AuthController.cs]"]
  node_restnotes["Notes REST<br/>[NotesController.cs]"]
  node_grpcauth["Auth gRPC<br/>[AuthGrpcService.cs]"]
  node_grpcnotes["Notes gRPC"]
  node_wshandler["WebSocket handler"]
  node_wsprocessor["Message processor"]
end

subgraph group_application["Application services"]
  node_authservice["Auth service<br/>[AuthService.cs]"]
  node_noteservice["Notes service<br/>[NoteService.cs]"]
  node_authdomain["Auth state<br/>[User.cs]"]
  node_refreshdomain["Refresh tokens<br/>[RefreshToken.cs]"]
  node_notedomain["Notes<br/>[Note.cs]"]
end

subgraph group_persistence["Persistence and logging"]
  node_uow["Unit of work<br/>[UnitOfWork.cs]"]
  node_userrepo["User repository<br/>[UserRepository.cs]"]
  node_tokenrepo["Token repository"]
  node_noterepo["Note repository<br/>[NoteRepository.cs]"]
  node_genericrepo["Generic repository<br/>[Repository.cs]"]
  node_dbcontext["EF context<br/>[AppDbContext.cs]"]
  node_sqllogger["SQLite logger"]
end

subgraph group_runtime["Runtime setup"]
  node_program["API startup<br/>[Program.cs]"]
end

node_client(("API clients"))
node_sqlite[("SQLite database")]
node_externaldb[("Database file")]

node_client -->|"sends REST"| node_restauth
node_client -->|"sends REST"| node_restnotes
node_client -->|"calls gRPC"| node_grpcauth
node_client -->|"calls gRPC"| node_grpcnotes
node_client -->|"opens socket"| node_wshandler
node_wshandler -->|"processes messages"| node_wsprocessor
node_restauth -->|"calls"| node_authservice
node_grpcauth -->|"calls"| node_authservice
node_wsprocessor -.->|"dispatches auth"| node_authservice
node_restnotes -->|"calls"| node_noteservice
node_grpcnotes -->|"calls"| node_noteservice
node_wsprocessor -.->|"dispatches notes"| node_noteservice
node_authservice -->|"reads and saves"| node_uow
node_noteservice -->|"reads and saves"| node_uow
node_uow -.->|"coordinates"| node_userrepo
node_uow -.->|"coordinates"| node_tokenrepo
node_uow -.->|"coordinates"| node_noterepo
node_userrepo -->|"inherits"| node_genericrepo
node_tokenrepo -->|"inherits"| node_genericrepo
node_noterepo -->|"inherits"| node_genericrepo
node_genericrepo -->|"queries"| node_dbcontext
node_dbcontext -->|"reads and writes"| node_externaldb
node_program -->|"runs migrations"| node_dbcontext
node_program -->|"maps socket route"| node_wshandler
node_program -.->|"configures logging"| node_sqllogger
node_sqllogger -.->|"writes logs"| node_externaldb

click node_restauth "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/Controllers/AuthController.cs"
click node_restnotes "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/Controllers/NotesController.cs"
click node_grpcauth "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/GrpcServices/AuthGrpcService.cs"
click node_grpcnotes "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/GrpcServices/NotesGrpcService.cs"
click node_wshandler "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/WebSockets/NotificationWebSocketHandler.cs"
click node_wsprocessor "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/WebSockets/Services/WebSocketMessageProcessor.cs"
click node_authservice "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Application/Services/AuthService.cs"
click node_noteservice "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Application/Services/NoteService.cs"
click node_authdomain "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Domain/Entities/User.cs"
click node_refreshdomain "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Domain/Entities/RefreshToken.cs"
click node_notedomain "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Domain/Entities/Note.cs"
click node_uow "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/UnitOfWork.cs"
click node_userrepo "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/UserRepository.cs"
click node_tokenrepo "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/RefreshTokenRepository.cs"
click node_noterepo "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/NoteRepository.cs"
click node_genericrepo "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/Repository.cs"
click node_dbcontext "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Data/AppDbContext.cs"
click node_sqllogger "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Logging/SqliteLoggerProvider.cs"
click node_program "https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/Program.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_restauth,node_restnotes,node_grpcauth,node_grpcnotes,node_wshandler,node_wsprocessor,node_client toneBlue
class node_authservice,node_noteservice,node_authdomain,node_refreshdomain,node_notedomain,node_sqlite,node_externaldb toneAmber
class node_uow,node_userrepo,node_tokenrepo,node_noterepo,node_genericrepo,node_dbcontext,node_sqllogger toneMint
class node_program toneRose
```

## Components

### Protocol entry points

- [Auth REST](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/Controllers/AuthController.cs): `src/OnionNet.API/Controllers/AuthController.cs`
- [Notes REST](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/Controllers/NotesController.cs): `src/OnionNet.API/Controllers/NotesController.cs`
- [Auth gRPC](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/GrpcServices/AuthGrpcService.cs): `src/OnionNet.API/GrpcServices/AuthGrpcService.cs`
- [Notes gRPC](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/GrpcServices/NotesGrpcService.cs): `src/OnionNet.API/GrpcServices/NotesGrpcService.cs`
- [WebSocket handler](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/WebSockets/NotificationWebSocketHandler.cs): `src/OnionNet.API/WebSockets/NotificationWebSocketHandler.cs`
- [Message processor](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/WebSockets/Services/WebSocketMessageProcessor.cs): `src/OnionNet.API/WebSockets/Services/WebSocketMessageProcessor.cs`

### Application services

- [Auth service](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Application/Services/AuthService.cs): `src/OnionNet.Application/Services/AuthService.cs`
- [Notes service](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Application/Services/NoteService.cs): `src/OnionNet.Application/Services/NoteService.cs`
- [Auth state](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Domain/Entities/User.cs): `src/OnionNet.Domain/Entities/User.cs`
- [Refresh tokens](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Domain/Entities/RefreshToken.cs): `src/OnionNet.Domain/Entities/RefreshToken.cs`
- [Notes](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Domain/Entities/Note.cs): `src/OnionNet.Domain/Entities/Note.cs`

### Persistence and logging

- [Unit of work](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/UnitOfWork.cs): `src/OnionNet.Infrastructure/Repositories/UnitOfWork.cs`
- [User repository](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/UserRepository.cs): `src/OnionNet.Infrastructure/Repositories/UserRepository.cs`
- [Token repository](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/RefreshTokenRepository.cs): `src/OnionNet.Infrastructure/Repositories/RefreshTokenRepository.cs`
- [Note repository](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/NoteRepository.cs): `src/OnionNet.Infrastructure/Repositories/NoteRepository.cs`
- [Generic repository](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Repositories/Repository.cs): `src/OnionNet.Infrastructure/Repositories/Repository.cs`
- [EF context](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Data/AppDbContext.cs): `src/OnionNet.Infrastructure/Data/AppDbContext.cs`
- [SQLite logger](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.Infrastructure/Logging/SqliteLoggerProvider.cs): `src/OnionNet.Infrastructure/Logging/SqliteLoggerProvider.cs`

### Runtime setup

- [API startup](https://github.com/bariskisir/onionnet/blob/master/src/OnionNet.API/Program.cs): `src/OnionNet.API/Program.cs`

### Other components

- **API clients**
- **SQLite database**
- **Database file**

## Connections

- API clients → Auth REST: sends REST
- API clients → Notes REST: sends REST
- API clients → Auth gRPC: calls gRPC
- API clients → Notes gRPC: calls gRPC
- API clients → WebSocket handler: opens socket
- WebSocket handler → Message processor: processes messages
- Auth REST → Auth service: calls
- Auth gRPC → Auth service: calls
- Message processor → Auth service: dispatches auth
- Notes REST → Notes service: calls
- Notes gRPC → Notes service: calls
- Message processor → Notes service: dispatches notes
- Auth service → Unit of work: reads and saves
- Notes service → Unit of work: reads and saves
- Unit of work → User repository: coordinates
- Unit of work → Token repository: coordinates
- Unit of work → Note repository: coordinates
- User repository → Generic repository: inherits
- Token repository → Generic repository: inherits
- Note repository → Generic repository: inherits
- Generic repository → EF context: queries
- EF context → Database file: reads and writes
- API startup → EF context: runs migrations
- API startup → WebSocket handler: maps socket route
- API startup → SQLite logger: configures logging
- SQLite logger → Database file: writes logs
