Before You Start
ThinkEx is a production application, not a demo or template. Contributions should prioritize:- Reliability: Changes should not introduce bugs or break existing functionality
- Maintainability: Code should be clean, well-documented, and follow existing patterns
- User Value: Features should solve real user problems, not just be “nice to have”
Development Setup
Prerequisites
Make sure you have the following installed:Node.js 20+
Required for Next.js 16. Download from nodejs.org
pnpm
Fast package manager. Install:
npm install -g pnpmPostgreSQL 12+
Local installation or Docker. See setup below.
Git
Version control. Download from git-scm.com
Quick Setup (Recommended)
The easiest way to get started is using our interactive setup script:What does the setup script do?
What does the setup script do?
- Checks prerequisites (Node.js, pnpm, Docker)
- Creates
.envfile from template - Generates
BETTER_AUTH_SECRETautomatically - Starts PostgreSQL in Docker (or uses local if Docker unavailable)
- Configures database connection
- Installs dependencies with
pnpm install - Initializes database schema with
pnpm db:push - Starts development server with
pnpm dev
Manual Setup
If you prefer to set up manually: 1. Clone and install dependenciesUsing Docker (Recommended)
Using Docker (Recommended)
localhost:5432 with:- Database:
thinkex - User:
thinkex - Password:
thinkex_password_change_me
Using Local PostgreSQL
Using Local PostgreSQL
If you have PostgreSQL installed locally:
.env and configure:
Required API Keys:
GOOGLE_GENERATIVE_AI_API_KEY- Get from Google AI StudioASSISTANT_API_KEY- Get from Assistant Cloud
GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET- For OAuth login- Supabase credentials - If using Supabase storage instead of local
Development Workflow
Project Structure
Making Changes
1. Create a feature branchfeature/- New featuresfix/- Bug fixesdocs/- Documentation updatesrefactor/- Code refactoring
Code Style
Code Style
- Use TypeScript for all new code
- Follow existing naming conventions (camelCase for variables, PascalCase for components)
- Use Prettier for formatting:
pnpm format - Use ESLint for linting:
pnpm lint - Add JSDoc comments for complex functions
Component Guidelines
Component Guidelines
- Prefer server components by default
- Use client components only when needed (interactivity, hooks, browser APIs)
- Co-locate component files (MyComponent.tsx, MyComponent.module.css)
- Use Shadcn UI components for consistency
- Keep components small and focused (< 200 lines)
Database Changes
Database Changes
- Edit
src/lib/db/schema.tsto modify schema - Generate migration:
pnpm db:generate - Apply migration:
pnpm db:push - Test migration on fresh database
- Add RLS policies for new tables
Event Sourcing Changes
Event Sourcing Changes
- Add new event types to
src/lib/workspace/events.ts - Update reducer in
src/lib/workspace/event-reducer.ts - Ensure reducer is pure (no side effects)
- Test event replay with sample data
All checks must pass before submitting a PR. CI will automatically run these checks.
feat:- New featurefix:- Bug fixdocs:- Documentationstyle:- Formatting, no code changerefactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks
PR Checklist
PR Checklist
- Clear title describing the change
- Description explaining what and why
- Screenshots/videos for UI changes
- All tests passing
- No merge conflicts
- Linked to related issue (if applicable)
Development Commands
Common Commands
Database Commands
Docker Commands
Testing Guidelines
Manual Testing
Before submitting a PR, test:Core Functionality
- Create/edit/delete workspaces
- Add different card types
- Drag and resize cards
- Chat with AI
Collaboration
- Open workspace in multiple tabs
- Verify real-time updates
- Test conflict resolution
- Invite collaborators
Edge Cases
- Slow network conditions
- Large workspaces (100+ cards)
- Browser back/forward
- Page refresh
Browser Support
- Chrome/Edge (Chromium)
- Firefox
- Safari (if available)
- Mobile browsers
Automated Testing
ThinkEx currently does not have automated tests (contributions welcome!). When adding tests:- Use Vitest for unit tests
- Use Playwright for E2E tests
- Test event reducers (pure functions)
- Test API routes with mock data
Architecture Guidelines
Event Sourcing Principles
When working with workspace state:- All changes must be events - Never mutate state directly
- Events are immutable - Once created, events cannot be modified
- Reducers must be pure - Same events always produce same state
- Include user context - Events should track who made the change
- Use timestamps - Events must have monotonically increasing timestamps
State Management Best Practices
- Use TanStack Query for server state (API data)
- Use Zustand for client state (UI state)
- Use event sourcing for workspace state
- Avoid prop drilling - use context or state management
- Keep components unaware of how state is persisted
Performance Considerations
Avoid Expensive Operations in Render
Avoid Expensive Operations in Render
- Move calculations to useMemo/useCallback
- Virtualize long lists with TanStack Virtual
- Lazy load components with React.lazy()
Optimize Event Replay
Optimize Event Replay
- Use snapshots to reduce replay time
- Batch multiple events when possible
- Avoid creating events on every keystroke
Database Query Optimization
Database Query Optimization
- Use indexes for common queries
- Paginate large result sets
- Select only needed columns
- Use database-level filtering (RLS)
Community & Support
GitHub Discussions
Ask questions and discuss ideas
Issue Tracker
Report bugs and request features
Documentation
Read the full docs
Reporting Issues
When reporting a bug, include:- Description: What happened vs. what you expected
- Steps to Reproduce: Numbered list of steps
- Environment: OS, browser, Node.js version
- Screenshots: If UI-related
- Logs: Console errors or server logs
- Related Code: Link to relevant code if known
Feature Requests
When suggesting a feature:- Search existing issues - Someone may have suggested it already
- Explain the problem - What user need does this solve?
- Describe the solution - How should it work?
- Consider alternatives - Are there other ways to solve this?
- Show examples - Screenshots or mockups help
Code Review Process
After submitting a PR:- Automated checks run - CI runs linting, type checking, and build
- Maintainer review - A maintainer will review your code
- Address feedback - Make requested changes
- Approval - Once approved, PR is merged
- Deployment - Changes deploy to production after merge
Related Documentation
- System Architecture - Understand how ThinkEx works
- Tech Stack - Learn about the technologies used
- Self-Hosting Guide - Deploy your own instance