---
title: K-Notes — Hexagonal Architecture + DDD
---
graph TB
subgraph Binaries["Binaries (Composition Root)"]
BOOTSTRAP["bootstrap
Axum HTTP server
Routes, Handlers, SPA serving,
OpenAPI docs (/docs, /scalar)"]
WORKER["worker
Event consumer
NoteEventHandler,
Semaphore(8), graceful shutdown"]
end
subgraph Wiring["wiring (Assembly)"]
CTX_BUILD["build_context()
Reads env vars, connects DB,
wires adapters into AppContext"]
end
subgraph Application["Application Layer"]
direction TB
CTX["AppContext
Repositories + Services + AppConfig"]
subgraph UseCases["Use Cases (CQRS)"]
UC_AUTH["auth
register, login"]
UC_NOTES["notes
create, update, delete, get,
list, search, pin, archive,
add_tag, remove_tag,
get_versions, get_related,
export, import"]
UC_TAGS["tags
create (get-or-create),
delete, rename, list"]
UC_SMART["smart
process_note, delete_vectors"]
end
WORKER_SVC["WorkerService
EventConsumer + EventHandler[]
Semaphore(8), JoinSet,
shutdown watch channel"]
end
subgraph Domain["Domain Layer (0 dependencies)"]
direction TB
subgraph Contexts["Business Contexts"]
D_NOTE["note/
Note, NoteId, NoteVersion,
NoteLink, NoteFilter,
NoteTitle, NoteColor"]
D_TAG["tag/
Tag, TagId, TagName"]
D_USER["user/
User, UserId, Email,
Password, PasswordHash"]
D_SMART["smart/
EmbeddingGenerator port
VectorStore port"]
end
subgraph Ports["Port Traits"]
P_REPOS["NoteRepository
TagRepository
UserRepository
LinkRepository"]
P_AUTH["PasswordHasher"]
P_EVENTS["EventPublisher
EventConsumer
EventHandler"]
end
EVENTS["DomainEvent
NoteCreated, NoteUpdated,
NoteDeleted
EventEnvelope (ack / nack)"]
end
subgraph ApiTypes["api-types (0 domain deps)"]
DTO["DTOs
NoteResponse, TagResponse,
UserResponse, AuthResponse,
BackupData, ConfigResponse,
ErrorResponse, ..."]
end
subgraph Adapters["Adapters (implement Port Traits)"]
direction TB
subgraph Storage["Storage"]
A_SQLITE["sqlite
SQLiteNoteRepository
SqliteTagRepository
SqliteUserRepository
SqliteLinkRepository
Migrations (FTS5)"]
end
subgraph Auth["Auth"]
A_AUTH["auth
Argon2PasswordHasher
JwtValidator (HS256)
OidcService (optional)"]
end
subgraph Messaging["Messaging"]
A_NATS["nats
JetStream publisher + consumer
Explicit ack/nack, backoff,
DLQ via max_deliver advisory"]
A_MEM["event-publisher-memory
Broadcast bus for dev/test"]
A_PAYLOAD["event-payload
DomainEvent ↔ JSON wire format"]
end
subgraph Smart["Smart Features"]
A_FASTEMBED["fastembed
FastEmbedGenerator
AllMiniLML6V2 (384-dim)"]
A_QDRANT["qdrant
QdrantVectorStore
upsert, find_similar, delete"]
end
end
%% Dependency arrows
BOOTSTRAP -->|"uses"| Wiring
BOOTSTRAP -->|"maps to"| ApiTypes
WORKER -->|"uses"| Wiring
Wiring -->|"assembles"| Application
Wiring -->|"constructs"| Adapters
Application -->|"depends on"| Domain
Adapters -.->|"implements"| Ports
%% Key flows
BOOTSTRAP ===|"JWT Bearer"| DTO
WORKER ===|"DomainEvent"| EVENTS
classDef domain fill:#1a1a2e,stroke:#e94560,color:#fff
classDef app fill:#16213e,stroke:#0f3460,color:#fff
classDef adapter fill:#0f3460,stroke:#533483,color:#fff
classDef binary fill:#533483,stroke:#e94560,color:#fff
classDef api fill:#2a2a4a,stroke:#e94560,color:#fff
classDef wiring fill:#0d2137,stroke:#22c55e,color:#fff
class Domain domain
class Application app
class Adapters adapter
class Binaries binary
class ApiTypes api
class Wiring wiring