A modern, secure real-time chat application with advanced messaging features, typing indicators, and end-to-end encryption capabilities.
- JWT-based authentication with refresh tokens
- Secure user registration and login
- Row Level Security (RLS) policies
- API-only database access (no direct client access)
- Input validation and sanitization
- Rate limiting protection
- Instant message delivery with Socket.IO
- Live typing indicators
- Message read receipts
- Auto-scroll to latest messages
- Real-time participant notifications
- Direct messages between users
- Group chat creation and management
- Public/private chat rooms
- Chat search functionality
- User search and discovery
- Join/leave chat rooms
- Modern UI with Ant Design components
- Responsive design for all devices
- Dark/light message themes
- Message bubble styling (sender vs participants)
- Back navigation to home page
- Real-time status indicators
- Browser-compatible E2E encryption service
- Message encryption at rest
- Secure key management
- Device-specific encryption keys
- Database: Supabase PostgreSQL with RLS (Row Level Security)
- Authentication: Supabase Auth with JWT tokens and refresh tokens
- API: TypeScript + Express.js (secure proxy to database)
- Client: React + Ant Design + TypeScript + Zustand
- Real-time: Socket.IO for live messaging and typing indicators
- Security: All database access through API, no direct client access
SailorChat/
βββ database/ # Database schema and migrations
βββ api/ # Express.js API server
β βββ src/
β β βββ controllers/ # Route handlers and business logic
β β βββ middleware/ # Authentication, validation, etc.
β β βββ routes/ # API route definitions
β β βββ services/ # External service integrations
β β βββ utils/ # Helper functions and utilities
βββ client/ # React web application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Application pages/screens
β β βββ stores/ # Zustand state management
β β βββ services/ # API and Socket.IO services
β β βββ types/ # TypeScript type definitions
βββ shared/ # Shared types and utilities
βββ src/
βββ types.ts # Common TypeScript interfaces
βββ utils.ts # Shared utility functions
- Node.js 18+ and npm
- Supabase account and project
- Git
-
Clone the repository
git clone <repository-url> cd SailorChat
-
Set up Supabase project
- Create a new Supabase project
- Copy your project URL and API keys
- Run database migrations (see
/databasefolder)
-
Configure environment variables
- Copy
.env.exampleto.envin bothapi/andclient/directories - Fill in your Supabase credentials and other configuration
- Copy
-
Install dependencies
# Install API dependencies cd api && npm install # Install client dependencies cd ../client && npm install
-
Start the applications
# Start API server (from api/ directory) npm run dev # Start client application (from client/ directory) npm run dev
-
Access the application
- Client: http://localhost:3000
- API: http://localhost:3001
- Swagger API Documentation: http://localhost:3001/api-docs
SailorChat provides comprehensive API documentation through multiple formats:
- URL: http://localhost:3001/api-docs
- Test all endpoints directly in your browser
- Built-in authentication with JWT tokens
- Real-time request/response examples
- Complete schema documentation
- API Guide: See
API_DOCUMENTATION.mdfor complete endpoint documentation - Swagger Setup: See
SWAGGER_DOCUMENTATION.mdfor interactive documentation
- JSON Spec: http://localhost:3001/api-docs.json
- Use for Postman collection generation
- Client SDK generation
- Third-party integrations
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutPOST /api/auth/refresh- Refresh access tokenGET /api/auth/me- Get current user
GET /api/chats- Get user's chatsPOST /api/chats- Create new chatGET /api/chats/:chatId- Get specific chat detailsGET /api/chats/search- Search public chatsPOST /api/chats/:chatId/join- Join a chat room
POST /api/messages- Send messageGET /api/messages/chat/:chatId- Get chat messagesPUT /api/messages/:messageId- Edit messageDELETE /api/messages/:messageId- Delete messagePOST /api/messages/chat/:chatId/read- Mark messages as readPOST /api/messages/direct- Send direct message
GET /api/users/search- Search usersGET /api/users/profile- Get user profilePUT /api/users/profile- Update user profile
join_chat- Join a chat roomleave_chat- Leave a chat roomtyping_start- Start typing indicatortyping_stop- Stop typing indicator
new_message- New message receiveduser_typing- User started typinguser_stopped_typing- User stopped typing
- JWT-based authentication with refresh tokens
- Row Level Security (RLS) policies
- API-only database access
- Message encryption at rest
- Rate limiting
- Input validation and sanitization
- CORS protection
- Helmet security headers
- Runtime: Node.js with TypeScript
- Framework: Express.js
- Database: Supabase (PostgreSQL)
- Authentication: Supabase Auth + JWT
- Real-time: Socket.IO
- Validation: express-validator
- Security: Helmet, CORS, rate limiting
- Framework: React 18 with TypeScript
- UI Library: Ant Design
- State Management: Zustand
- Routing: React Router
- Real-time: Socket.IO Client
- Build Tool: Vite
- Styling: CSS-in-JS with Ant Design themes
- Primary: Supabase PostgreSQL
- Features: Row Level Security, Real-time subscriptions
- Migrations: SQL-based schema management
API Server:
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm run start- Start production servernpm run test- Run test suite
Client Application:
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
-
Database Setup
- Use Supabase production project
- Run all migrations
- Configure RLS policies
-
API Deployment
- Set production environment variables
- Deploy to your preferred platform (Vercel, Railway, etc.)
- Configure CORS for your domain
-
Client Deployment
- Update API URLs for production
- Build the application
- Deploy to static hosting (Vercel, Netlify, etc.)
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email [email protected] or create an issue in the GitHub repository.