A real-time collaborative text editor.
- Real-time collaboration: Multiple users can edit simultaneously
- Word-level editing: Click on any word to edit or click between words to add text
- 30-second cooldown: Prevents spam and encourages thoughtful edits
- Markdown support: Full markdown rendering with live preview
- Document outline: Automatic table of contents from headers
- Change history: Track all edits with user attribution
- Link blocking: Prevents users from adding links to maintain content quality
- User presence: See who's online and editing
- Frontend: Next.js 15 with TypeScript, Tailwind CSS, Zustand for state management, and Heroicons
- Backend: Go with Gin, WebSocket support, and PostgreSQL
- Database: PostgreSQL with automatic migrations
- Real-time: WebSocket connections for live collaboration
- Node.js 18+
- Go 1.21+
- PostgreSQL 14+
- Navigate to the backend directory:
cd backend- Install Go dependencies:
go mod tidy- Create a
.envfile:
cp .env.example .env- Update the
.envfile with your database credentials:
DATABASE_URL=postgres://username:password@localhost:5432/storychain?sslmode=disable
FRONTEND_URL=http://localhost:3000
PORT=8080- Create the database:
CREATE DATABASE storychain;- Run the backend server:
go run main.goThe backend will automatically run migrations on startup.
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Configure API/WebSocket endpoints (optional; defaults to localhost:8080):
cd frontend
echo "NEXT_PUBLIC_API_BASE_URL=http://localhost:8080" > .env.local
echo "NEXT_PUBLIC_WS_URL=ws://localhost:8080/api/ws" >> .env.local- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
- Editing: Click on any word to edit it, or click between words to add new text
- Cooldown: After making an edit, you'll have a 30-second cooldown before you can edit again
- Preview: Toggle between edit and preview modes using the button in the top-right
- Navigation: Use the outline sidebar to jump to different sections
- History: View recent changes in the right sidebar, hover to highlight, click to navigate
GET /api/document/:id- Get document contentPUT /api/document/:id- Update document with a changeGET /api/changes/:documentId- Get change historyGET /api/stats- Get statistics (edits, users, online count)WS /api/ws- WebSocket connection for real-time updates
user_presence- User joined/left notificationstext_change- Real-time text modificationsstats_update- Live statistics updates
documents- Document content and metadatausers- User information and sessionschanges- Edit history with user attributionuser_cooldowns- Cooldown tracking per user
- Backend changes go in
backend/internal/ - Frontend components go in
frontend/src/components/ - Shared utilities in
frontend/src/lib/ - State management in
frontend/src/stores/
# Backend
cd backend
go test ./...
# Frontend
cd frontend
npm test# Backend
cd backend
go build -o storychain-server
# Frontend
cd frontend
npm run build- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details