Developing a Forum Mobile Application
A forum in a mobile app is a hierarchical structure: sections → threads → posts. The main technical challenge is proper pagination in multi-level lists, thread sorting (by activity, date, rating), and displaying nested quotes without breaking readability on a small screen.
Data Structure
boards (id, slug, name, parent_board_id, position) -- forum sections
threads (id, board_id, author_id, title, views, replies_count, last_reply_at, is_pinned, is_locked)
posts (id, thread_id, author_id, content_html, quote_post_id, created_at, updated_at, is_deleted)
last_reply_at in threads is key for sorting by activity. Updates with each new post. Index (board_id, is_pinned DESC, last_reply_at DESC) for standard thread list queries.
replies_count is denormalized, incremented via trigger. Don't recalculate COUNT(*) each time.
Thread List: Pagination and Sorting
On mobile, thread list is UITableView (iOS) or LazyColumn (Android). Sort options: "New," "Active," "Popular." Toggle via SegmentedControl or TabRow.
Cursor-based pagination for "New" and "Active":
- "New": cursor by
created_at - "Active": cursor by
(is_pinned, last_reply_at)—pinned always first
For "Popular" (by views or weekly rating)—offset pagination is acceptable since the list is stable.
Pinned threads (is_pinned = true) always appear at top regardless of sort. On iOS use DiffableDataSourceSnapshot with two sections: pinned and regular.
Thread: Nested Posts and Quotes
Posts in a thread are a flat list with quote_post_id (not a tree like Reddit). When quoting, display a nested block:
┌─ Quote from author X: ┐
│ "Quote text" │
└────────────────────────────┘
Reply to quote...
iOS: custom UIView inside post cell with backgroundColor(.systemGray6), layer.cornerRadius = 8, layer.borderWidth = 1. Tap on quote scrolls to the original post (similar to reply in chat).
Render HTML content via WKWebView (complex formatting) or UILabel with NSAttributedString from NSAttributedString(data:options:[.documentType: NSAttributedString.DocumentType.html]). WKWebView is heavier but more correct. On Compose use AndroidView with WebView or HtmlText from Accompanist.
Section Navigation
Multi-level sections: boards with parent_board_id. Navigation is a stack: main section list → subsection → thread list → thread.
iOS: UINavigationController with push. Breadcrumbs at top—horizontal UIScrollView with buttons "Section → Subsection." Android: NavHost with NavController, TopAppBar with back icon.
Post Editor
Minimum: UITextView with bold, italic, code support. Toolbar above keyboard with formatting buttons—inputAccessoryView on iOS, Composable above TextField on Android with AnimatedVisibility.
Quoting when replying: selected text or "Quote" button under post inserts quote block in input. Draft saved locally on each change (1 sec debounce)—UserDefaults / DataStore.
Search
Forum search: GET /search?q=...&board_id=...&page=.... Full-text via PostgreSQL tsvector/GIN or Elasticsearch. Mobile: search screen with UISearchBar / SearchBar composable, results—threads and individual posts, grouped by type.
Unread Threads and Badges
Table thread_reads (user_id, thread_id, last_read_post_id, read_at). Thread is "unread" if last_reply_at > thread_reads.read_at. Unread section count—badge on section icon.
Update thread_reads on thread open: POST when reaching end of list or on screen close via viewWillDisappear (iOS) / DisposableEffect (Compose).
Work Phases
Design section structure and DB schema → API (sections, threads, posts, search) → mobile UI for main screens → editor with formatting → notifications on subscribed thread updates → testing.
Timeline
MVP (sections, thread list, thread, simple editor): 2–3 weeks. Full forum with search, unread tracking, subscriptions, moderation: 1–3 months. Pricing calculated individually after requirements analysis.







