🔧 Development
Everything you need to know for contributing to and extending Threadwp.
Database Schema
Database Tables
The plugin creates these database tables for chat functionality
wp_threadwp_message_threads - Chat thread storage
wp_threadwp_messages - Individual messages
wp_threadwp_thread_participants - Thread membership (future)
wp_threadwp_message_reactions - Message reactions (future)Core Tables
- • message_threads - Chat conversations
- • messages - Individual chat messages
Future Extensions
- • thread_participants - Group chat members
- • message_reactions - Emoji reactions
CLI Commands
WP-CLI Integration
Manage the plugin via WordPress command line interface
# Run migrations
wp threadwp migrate:run
# Rollback migrations
wp threadwp migrate:rollback
# Check migration status
wp threadwp migrate:status
# Generate API key
wp threadwp api:generate-key
# Test API connection
wp threadwp api:testDevelopment Workflow
Local Development
Start development servers with hot reload
# Start WordPress development
cd wp-plugin/
bun run dev
# Start Socket.IO server development
cd socket-server/
bun run dev
# Watch for changes and auto-reload
# Frontend: Vite HMR enabled
# Backend: Nodemon for server restartContributing Steps
Follow these steps to contribute to the project
1. Fork the repository
2. Create a feature branch: git checkout -b feature/amazing-feature
3. Make your changes
4. Run tests: npm test
5. Commit changes: git commit -m 'Add amazing feature'
6. Push to branch: git push origin feature/amazing-feature
7. Open a Pull RequestTesting
Test Suites
Run comprehensive tests for all components
# Run PHP tests
composer test
# Run JavaScript tests
npm test
# Run E2E tests
npm run test:e2e
# Code coverage
npm run test:coverageUnit Tests
- • PHP functions
- • React components
- • TypeScript utilities
Integration Tests
- • API endpoints
- • Database operations
- • Socket.IO events
E2E Tests
- • User workflows
- • Real-time messaging
- • Cross-browser testing
Coding Standards
Code Quality
Maintain consistent code style across the project
# PHP - WordPress Coding Standards
composer run phpcs
# JavaScript/TypeScript - ESLint + Prettier
npm run lint
npm run format
# CSS - Tailwind CSS utility classes
npm run lint:css
# Commits - Conventional Commits
git commit -m "feat: add new chat feature"
git commit -m "fix: resolve message ordering issue"
git commit -m "docs: update API documentation"Development Tips
Frontend Development
Hot Module Replacement
Vite provides instant feedback during development with HMR enabled for React components.
TypeScript Support
Full type safety with TypeScript strict mode enabled and proper type definitions.
Component Testing
Use React Testing Library for component testing with proper mocking of Socket.IO.
Backend Development
WordPress Integration
Follow WordPress coding standards and use proper hooks and filters for extensibility.
Database Migrations
Use version-controlled migrations for database schema changes with proper rollback support.
API Security
Implement proper authentication, rate limiting, and input validation for all endpoints.
🏗️ Architecture Decisions
Technology Choices
- • React: Component-based UI with TypeScript
- • Socket.IO: Reliable WebSocket with fallbacks
- • Tailwind: Utility-first CSS for consistency
- • Vite: Fast build tool with HMR
Design Patterns
- • Repository Pattern: Data access abstraction
- • Event-Driven: Decoupled component communication
- • Hook System: WordPress-style extensibility
- • Optimistic UI: Instant user feedback