Backend Architecture
Single ASP.NET Core (.NET 8) API that serves both the social Frontend and the Admin Panel, plus separate worker processes.
Bellamy Book is a self-hosted social network: one API deployment per community instance.
Technology stack
| Layer | Choice |
|---|---|
| Runtime | .NET 8 / C# |
| API | ASP.NET Core, JWT, FluentValidation, Prometheus |
| Patterns | Clean Architecture, MediatR (CQRS-style), DDD modules |
| SQL | EF Core 8 + PostgreSQL (primary + readonly) |
| Document | MongoDB (comments, chat, notifications, push tokens) |
| Cache | Redis |
| Events | Kafka (social / analytics / search sync) |
| Queues | RabbitMQ (chat, notifications, push, moderation, AI blog) |
| Graph | Neo4j |
| Search | Elasticsearch |
| Storage | MinIO or Cloudflare R2 |
| Media | ImageSharp, FFmpeg |
| Jobs | Quartz.NET (API + BlogAutoGenerationWorker) |
| Calls | LiveKit |
Chat and notification hubs run on ChatWorker and WebSocketWorker, not inside the API process.
Solution layout (Src/backend/)
| Project | Role |
|---|---|
API | REST controllers, middleware, Quartz host |
Application | MediatR commands/queries/handlers |
Domain | Aggregates, domain events |
Infrastructure | EF, Mongo, Kafka, RabbitMQ, Neo4j, ES, MinIO/R2 |
Shared | DTOs, messaging contracts, constants |
SharedWorker | Worker base + Kafka helpers |
DatabaseApplication | Migrations / seeding |
| Workers (13) | See Workers |
Dependency direction: API → Application → Domain; Infrastructure implements Application contracts.
Controllers (domains)
Auth, User, Post, Story, Comment, Blog, Media, Chat, Call, Friendship, Follow, Notification, Announcement, Search, Sitemap, Admin (dashboard, backup, content-alerts, elasticsearch, search-analytics), License, AiAgent, Tickets, EmailCampaign, ApplicationSettings, Moderation, Push subscriptions, Health, …
Many features use Read/Write controller splits and MediatR handlers under Application/Modules/.
Middleware (typical order)
Error handling → security headers → CORS → host validation → rate limiting → authentication/authorization → license enforcement → controllers → metrics.
Buses
| Bus | Used for | Consumers |
|---|---|---|
| Kafka | user_interacted, content_created/updated/deleted, … | Interaction, Scoring, Trending, Graph, Hashtag, ES Sync |
| RabbitMQ | Chat, friendship, notifications, push, moderation, blog generation | ChatWorker, WebSocketWorker, Web/Expo push, ContentModeration, BlogAutoGen |
| Polling | Pending MediaFile rows | MediaProcessingWorker |