System Architecture
The forum system uses a layered architecture with clear separation of concerns:Database Schema
The forum system uses PostgreSQL with Prisma ORM and follows a multi-tenant architecture where each DAO has its own data isolation throughdao_slug.
Core Entities
- Categories
- Topics
- Posts
- Reactions
admin_only_topics flag restricts topic creation to admins. The is_duna flag marks categories used for DUNA quarterly reports.Entity Relationships
Key Design Decisions
Multi-Tenant Architecture
Multi-Tenant Architecture
Every table includes
dao_slug for tenant isolation. This enables:- Complete data separation between DAOs
- Easy data export and migration per DAO
- Simplified permission checking
- Independent configuration per tenant
Post-Centric Design
Post-Centric Design
All user interactions (votes, reactions) are post-specific rather than topic-specific:
- Reactions on individual posts, not just topics
- Granular engagement tracking
- Better comment threading support
- More accurate analytics
Soft Deletion
Soft Deletion
Content supports both soft and hard deletion:
deleted_atanddeleted_byfields track soft deletions- Content can be restored by admins
- Maintains audit trail
- Protects against accidental deletion
NSFW Detection
NSFW Detection
Automatic content moderation with NSFW flagging:
- Uses OpenAI moderation API
- Flagged content hidden from public view
- Admin review workflow
- Protects community standards
Data Flow
Creating a Topic
File Locations
Performance Considerations
Pagination
All list queries use limit/offset pagination to handle large datasets efficiently
Indexing
Composite indexes on
(dao_slug, category_id) and (dao_slug, topic_id) for fast queriesCaching
Redis overlay for view counts reduces database load for high-traffic topics
Async Operations
Search indexing and moderation run asynchronously to not block user responses
Next Steps
Topics & Posts
Learn how to create and manage forum content
Search
Implement full-text search for forum content