Forge your strongest arguments
A platform for good-faith political discussion, where ideas are crafted and honed with the precision of a blacksmith's hammer. ReasonSmith combines editorial discipline with collaborative refinement, featuring AI-powered good-faith analysis, citation management, and transparent revision history.
- Rich Text Editor: Powered by TipTap with full formatting support (bold, italic, lists, headings, code blocks)
- Citation System: Chicago-style citations with automatic formatting and citation network visualization
- Good-Faith Analysis: AI-powered content moderation using Claude and OpenAI to score arguments for constructive discourse
- Auto-Save Drafts: Real-time draft persistence with local storage fallback and network sync
- Writing Styles: Multiple formats (journalistic, academic, quick point) with style-specific requirements
- Anonymous Posting: Optional anonymity for sensitive discussions
- Content Quality Assessment: Automated checks for citations, argument structure, and tone
- XP System: Earn experience points for creating discussions, posting comments, and receiving good-faith scores
- Leveling: Progress through levels with titles (Novice Thinker, Apprentice Analyst, Journeyman Debater, etc.)
- Achievements: Unlock badges for milestones (first post, discussion streaks, quality contributions)
- Activity Streaks: Track consecutive days of participation
- Progress Visualization: Dashboard displays XP progress, current level, and achievements
- Follow System: Follow other contributors to see their discussions and activity
- Collaboration Contacts: Build a network of trusted collaborators with invite system
- User Blocking: Block users to prevent unwanted interactions
- Saved Interests: Save topic tags to personalize your discussion feed
- Networking Dashboard: Dedicated section for managing follows, contacts, and social connections
- Collaboration Invites: Invite other users to collaborate on discussion drafts
- Edit Locks: Automatic locking prevents concurrent editing conflicts
- Collaborator Chat: Real-time messaging between discussion collaborators
- Collaboration Status: Track invite acceptance, pending requests, and active collaborations
- Event Management: Create and manage community events
- Upcoming Events: Dashboard display of upcoming events
- Event Details: Full event pages with descriptions, dates, and details
- Filter Modes: Filter discussions by All, Following (people you follow), or Interests (saved tags)
- Tag System: Tag discussions for categorization and discovery
- Interest-Based Filtering: Personalized feeds based on saved topic interests
- Editor's Desk: Curated featured content selected by site managers
- Discussion Notifications: Updates for mentions, approvals, and discussion activity
- Social Notifications: Alerts for new followers, follow requests, and contact invites
- Collaboration Notifications: Updates for collaboration invites, chat messages, and edit activity
- Real-Time Updates: WebSocket-based notification delivery
- Role-Based Access: Three-tier system (user, site manager, admin) with granular permissions
- Public Showcase: Feature discussions on the public-facing showcase page
- Credits System: Monthly credits with optional purchased credits for good-faith analysis
- User Statistics: Track good-faith rate, source accuracy, and reputation scores
- Citation Networks: Neo4j-powered visualization of argument connections
- Flexible Options: GitHub, Google OAuth, magic links, or email/password
Frontend:
- SvelteKit 2 with TypeScript
- TipTap rich text editor
- Apollo Client for GraphQL
- Vercel deployment
Backend:
- Nhost (Hasura GraphQL + PostgreSQL)
- Neo4j for citation network graphs
- Nhost Auth with GitHub, Google OAuth
AI & Moderation:
- Vercel Serverless Functions
- Anthropic Claude API
- OpenAI API
Additional Libraries:
- isomorphic-dompurify for sanitization
- svelte-tiptap for Svelte integration
- Playwright for E2E testing
- Vitest for unit testing
-
Clone the repo
git clone https://github.com/<your-org>/reasonsmith-web.git cd reasonsmith-web
-
Install dependencies
pnpm install
-
Configure environment variables
Create a
.envfile in the project root with:# Nhost Configuration PUBLIC_NHOST_SUBDOMAIN=<your-subdomain> PUBLIC_NHOST_REGION=<your-region> PUBLIC_SITE_URL=http://localhost:5173 # AI Services OPENAI_API_KEY=<your-openai-api-key> ANTHROPIC_API_KEY=<your-anthropic-api-key> # Neo4j (optional - for citation networks) NEO4J_URI=<your-neo4j-uri> NEO4J_USERNAME=<your-username> NEO4J_PASSWORD=<your-password>
Custom Domains (production):
- Auth: auth.reasonsmith.com
- GraphQL: graphql.reasonsmith.com
- Storage: storage.reasonsmith.com
-
Run the development server
pnpm dev
Server runs at
http://localhost:5173 -
Build for production
pnpm build pnpm preview
reasonsmith-web/
├─ src/
│ ├─ lib/
│ │ ├─ components/
│ │ │ ├─ admin/ # Admin & site manager tools
│ │ │ ├─ citations/ # Citation forms & network viz
│ │ │ ├─ collaboration/ # Collaboration invites, chat, edit locks
│ │ │ ├─ discussion/ # Discussion UI components
│ │ │ ├─ events/ # Event display components
│ │ │ ├─ growth/ # XP, leveling, achievements
│ │ │ ├─ landing/ # Marketing & onboarding
│ │ │ ├─ networking/ # Follow, contacts, blocking
│ │ │ ├─ posts/ # Post/comment components
│ │ │ └─ ui/ # Reusable UI primitives
│ │ ├─ graphql/
│ │ │ └─ queries.ts # GraphQL queries & mutations
│ │ ├─ types/
│ │ │ └─ writingStyle.ts # Style definitions & types
│ │ ├─ utils/
│ │ │ ├─ analysisCache.ts
│ │ │ ├─ contentQuality.ts
│ │ │ ├─ draftAutosave.ts
│ │ │ ├─ editLockManager.ts # Collaboration edit locking
│ │ │ ├─ growthProgression.ts # XP & leveling logic
│ │ │ ├─ notificationHelpers.ts
│ │ │ └─ ...
│ │ ├─ creditUtils.ts # Credits & permissions logic
│ │ ├─ logger.ts # Centralized logging
│ │ ├─ nhostClient.ts # Nhost & auth setup
│ │ ├─ neo4jClient.ts # Citation network client
│ │ └─ permissions.ts # Role-based access control
│ ├─ routes/
│ │ ├─ api/ # Vercel serverless functions
│ │ │ ├─ goodFaith/
│ │ │ ├─ goodFaithClaude/
│ │ │ ├─ goodFaithClaudeFeatured/
│ │ │ ├─ syncCitations/
│ │ │ ├─ audio/[fileId]/
│ │ │ └─ image/[fileId]/
│ │ ├─ discussions/
│ │ │ ├─ +page.svelte # Discussion list with filters
│ │ │ ├─ [id]/+page.svelte # Discussion view
│ │ │ └─ [id]/draft/[draft_id]/ # Draft editor
│ │ ├─ events/ # Events list and details
│ │ ├─ admin/ # Admin dashboard
│ │ ├─ profile/ # User profile & interests
│ │ ├─ public/ # Public showcase page
│ │ ├─ u/[id]/ # Public user profiles
│ │ ├─ resources/ # Documentation pages
│ │ └─ +page.svelte # Dashboard (home)
│ └─ app.html # HTML template
├─ nhost/
│ ├─ migrations/ # Database migrations
│ └─ metadata/ # Hasura permissions & config
├─ static/ # Static assets (logos, icons)
├─ tests/ # E2E and unit tests
├─ .env # Environment variables (not committed)
├─ CLAUDE.md # Architecture documentation for Claude
├─ package.json # Dependencies & scripts
└─ README.md
| Command | Description |
|---|---|
pnpm dev |
Start development server at localhost:5173 |
pnpm build |
Build for production |
pnpm preview |
Preview production build |
pnpm check |
Run SvelteKit type checking |
pnpm check:watch |
Run type checking in watch mode |
pnpm lint |
Check code formatting with Prettier |
pnpm format |
Format code with Prettier |
pnpm test:unit |
Run unit tests with Vitest |
pnpm test:e2e |
Run E2E tests with Playwright |
pnpm test |
Run all tests |
pnpm generate-icons |
Generate optimized icon assets |
ReasonSmith uses Nhost Auth with three role levels:
Default role - can create discussions, post comments, receive monthly analysis credits Site manager - can feature content, manage disputes, moderate posts Root admin - complete system control, unlimited credits
Permissions are managed centrally in src/lib/permissions.ts.
Content moderation uses AI to score posts on constructive discourse:
- Heuristic Pre-check: Fast client-side quality assessment
- AI Analysis: Claude/OpenAI evaluates claims, arguments, and tone
- Score Assignment: 0-1 scale (hostile → questionable → neutral → constructive → exemplary)
- Credit System: Monthly credits + optional purchased credits for analysis
Scoring functions:
/api/goodFaith- OpenAI-based scoring/api/goodFaithClaude- Claude-based scoring (posts)/api/goodFaithClaudeFeatured- Claude-based scoring (discussions)
- User creates discussion draft → auto-saved to localStorage + database
- Optional good-faith analysis before publishing
- Publish → draft becomes current version, old version archived
- Version history maintained in
discussion_versionstable
Auto-save implementation in src/lib/autosaveDraft.ts:
- Debounced saves (800ms delay)
- Minimum interval between network writes (2.5s)
- Offline-first with localStorage
- Automatic retry on connection restore
Chicago-style citations with:
- Manual entry via
CitationForm - Automatic formatting via
formatChicagoCitation() - Neo4j network visualization
- Link citations to specific points in arguments
- Sync citations across draft versions
Monthly credits reset at beginning of each month:
- Track usage in
contributor.analysis_count_used - Reset tracked in
analysis_count_reset_at - Purchased credits available when monthly exhausted
- Admins/site managers have unlimited credits
Implementation: src/lib/creditUtils.ts
XP-based progression with leveling:
- XP Sources: Creating discussions, posting comments, good-faith scores, achievements
- Levels: Novice Thinker → Apprentice Analyst → Journeyman Debater → Expert Rhetorician → Master Logician → Grand Philosopher
- Achievements: Milestone-based badges with XP rewards
- Streaks: Consecutive daily activity tracking
Implementation: src/lib/utils/growthProgression.ts, src/lib/components/growth/
Follow-based social graph:
- Follows: Asymmetric follow relationships
- Contacts: Symmetric collaboration relationships with invite system
- Blocking: User blocking with interaction prevention
- Interests: Saved topic tags for personalized content filtering
Implementation: src/lib/components/networking/
Real-time collaboration features:
- Invites: Invite users to collaborate on discussion drafts
- Edit Locks: Pessimistic locking to prevent concurrent editing conflicts
- Chat: Real-time messaging between collaborators on a discussion
Implementation: src/lib/utils/editLockManager.ts, src/lib/components/collaboration/
Good-Faith Analysis:
POST /api/goodFaith- Score content with OpenAIPOST /api/goodFaithClaude- Score posts with ClaudePOST /api/goodFaithClaudeFeatured- Score featured discussions with Claude
Citation Management:
POST /api/syncCitations- Sync citations to Neo4j network
Media Serving:
GET /api/audio/[fileId]- Serve audio files from Nhost storageGET /api/image/[fileId]- Serve images from Nhost storage
All functions include authentication checks and proper error handling.
-
discussion: Main discussion threads- Links to
discussion_versionsfor versioning - Tracks anonymous status, approval state
- Links to
-
discussion_version: Version history for discussionsversion_type: 'draft' or 'published'- Title, description, tags, citations
- Good-faith scores and analysis
-
post: Comments and responsespost_type: response, counter_argument, supporting_evidence, question- Draft content + published content
- Writing style metadata
- Good-faith scoring fields
-
contributor: User profiles- Display name, handle, bio, social links
- Role (user/slartibartfast/admin)
- Analysis credits tracking
- Reputation scores
interests: Saved topic tags for personalized filtering- XP, level, and streak tracking
-
citation: Citation records- Chicago-style citation fields
- Point supported, relevant quotes
- Links to discussions/posts
-
editors_desk_pick: Featured content- Requires author approval
- Display order and publication status
-
follow: User follow relationshipsfollower_id,following_id- Follow status (active, pending for private accounts)
-
contact: Collaboration contacts- Trusted collaborator relationships
- Contact status
-
contact_request: Pending contact invitations- Request status (pending, accepted, rejected)
-
block: User blocking- Prevents interactions between users
-
collaboration_invite: Discussion collaboration invites- Links collaborators to discussions
- Invite status (pending, accepted, rejected)
-
collaboration_chat_message: Real-time collaborator messaging- Messages between discussion collaborators
-
edit_lock: Concurrent editing prevention- Tracks active editors on discussions
-
achievement: Achievement definitions- Name, description, XP reward, icon
- Unlock criteria
-
contributor_achievement: Earned achievements- Links contributors to unlocked achievements
- Unlock timestamp
event: Community events- Title, description, date/time
- Location, organizer
notification: User notifications- Multiple notification types (discussion, social, collaboration)
- Read status, metadata
ReasonSmith follows a sophisticated, editorial aesthetic inspired by Foreign Affairs and The Atlantic:
- Typography: Display font for headings, sans-serif for body
- Colors: Defined in CSS custom properties (
--color-primary,--color-accent) - Dark Mode: Full theme support via
[data-theme='dark'] - Logo: Available in
static/logo.svgandstatic/logo-dark.svg
Design principles documented in CLAUDE.md.
Unit Tests (Vitest):
pnpm test:unitE2E Tests (Playwright):
pnpm test:e2eTest files located in tests/ and *.test.ts files.
ReasonSmith is deployed on Vercel with:
- Automatic deployments from main branch
- Environment variables configured in Vercel dashboard
- Custom domain with SSL
- Serverless function cold starts optimized
Adapter: @sveltejs/adapter-vercel
Replace console.log/error/warn with the centralized logger:
import { logger } from '$lib/logger';
logger.debug('Debug info'); // Only in development
logger.info('Informational'); // Only in development
logger.warn('Warning'); // Always logged
logger.error('Error'); // Always loggedUse centralized permission utilities:
import { hasAdminAccess, canEdit, canModerate } from '$lib/permissions';
if (hasAdminAccess(contributor)) {
// Admin-only functionality
}
if (canEdit(contributor, resourceOwnerId, userId)) {
// Show edit button
}Components are organized by function:
- ui/: Reusable primitives (buttons, modals, badges, notifications)
- posts/: Post-specific components (composer, item display)
- discussion/: Discussion-specific (header, edit form, references)
- citations/: Citation management (form, list, network)
- growth/: XP display, level badges, achievement cards, streak indicators
- networking/: Follow buttons, contact lists, blocking UI
- collaboration/: Invite management, collaborator chat, edit lock indicators
- events/: Event cards, event lists, event details
- admin/: Admin-only tools, public showcase manager
- landing/: Marketing and onboarding
- CLAUDE.md: Comprehensive architecture documentation for AI assistants
- Community Guidelines:
/resources/community-guidelines - Citation Best Practices:
/resources/citation-best-practices - Good-Faith Arguments:
/resources/good-faith-arguments
This project is licensed under the GNU General Public License v3.0.
See the LICENSE file for the full terms and conditions.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run tests (
pnpm test) - Run type checking (
pnpm check) - Format code (
pnpm format) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Built with ❤️ for constructive discourse