A complete React application that integrates StreamChat with the Kabila backend, providing a modern user interface for sending messages, creating chat groups, and managing users in real-time.
- Modern React interface with responsive design
- Complete integration with StreamChat
- Real-time chat with instant messages
- Group creation with intuitive interface
- User management with authentication
- Backend service for integration with Kabila
- TypeScript with strict typing
- Centralized configuration and easy to use
kabila-streamchat-frontend-demo/
βββ src/
β βββ components/
β β βββ LoginForm.tsx # Login form
β β βββ CreateGroupModal.tsx # Modal to create groups
β βββ hooks/
β β βββ useStreamChat.ts # Custom hook for StreamChat
β βββ services/
β β βββ BackendService.ts # HTTP calls to backend
β β βββ StreamChatService.ts # StreamChat management
β β βββ UserService.ts # User management
β β βββ KabilaBackendService.ts # Specific Kabila service
β βββ types/
β β βββ index.ts # TypeScript interfaces
β βββ App.tsx # Main React component
β βββ main.tsx # React entry point
β βββ index.css # Global styles
β βββ demo.ts # Complete functional demo
β βββ index.ts # Entry point
βββ index.html # Main HTML
βββ vite.config.ts # Vite configuration
βββ package.json
βββ tsconfig.json
βββ src/config.ts # Centralized configuration
βββ README.md
-
Clone the repository
git clone <repository-url> cd kabila-streamchat-frontend-demo
-
Install dependencies
npm install
-
Configure credentials
Edit the
src/config.tsfile with your credentials:export const CONFIG = { // Backend Configuration backend: { baseUrl: "http://localhost:5004/api", // Your backend URL apiKey: "1234", // Your backend API key }, // StreamChat Configuration streamChat: { apiKey: "your_stream_api_key_here", // Your StreamChat API key apiSecret: "your_stream_api_secret_here", // Your StreamChat API secret }, // ... rest of configuration };
npm run react:devThe application will automatically open at http://localhost:3000
npm run react:dev # Development with hot reload
npm run react:build # Build for production
npm run react:preview # Preview of the build
npm run demo # Console demo (Node.js)
npm run start # Console application
npm run dev # Console development mode
npm run build # Compile TypeScriptHandles all HTTP calls to the Kabila backend using exact endpoints:
GET /plazas/:plazaId/chat_groups- Get all groupsGET /plazas/:plazaId/chat_groups/:id- Get specific groupPOST /plazas/:plazaId/chat_groups- Create new groupPATCH /plazas/:plazaId/chat_groups/:id- Update groupDELETE /plazas/:plazaId/chat_groups/:id- Delete groupPOST /plazas/:plazaId/login- User login (returns token)
Manages StreamChat integration:
- Create users in StreamChat
- Generate authentication tokens
- Connect users
- Create and manage channels
- Send messages
- Manage members
Handles user management:
- User registration
- Profile updates
- Authentication
- Data validation
- Conversion to StreamChat format
The demo executes the following steps:
- Connectivity verification - Verifies backend and StreamChat
- User registration - Creates a user in the system
- Group creation - Creates a chat group in the backend
- StreamChat configuration - Configures user in StreamChat
- Channel creation - Creates channel in StreamChat
- Conversation simulation - Sends test messages
- Final statistics - Shows demo summary
The demo includes detailed logging to facilitate debugging:
- β Successful operations
β οΈ Warnings and fallbacks- β Detailed errors
- π Statistics and metrics
- Automatic fallback when backend is not available
- Data simulation to continue the demo
- Robust handling of network errors
- Detailed logging for debugging
| Variable | Description | Required |
|---|---|---|
BACKEND_BASE_URL |
Kabila backend URL | Yes |
BACKEND_API_KEY |
Backend API key | Yes |
STREAM_API_KEY |
StreamChat API key | Yes |
STREAM_API_SECRET |
StreamChat API secret | Yes |
DEMO_PLAZA_ID |
Plaza ID for the demo | No |
DEMO_USER_ID |
User ID for the demo | No |
DEMO_USER_NAME |
User name for the demo | No |
DEMO_USER_EMAIL |
User email for the demo | No |
LOG_LEVEL |
Logging level | No |
The project uses TypeScript with strict configuration:
- Strict types enabled
- Type checking at compile time
- Well-defined interfaces
- Typed error handling
β οΈ Backend not available, continuing in simulation mode
Solution: Verify that the backend is running and the URL is correct.
β Error initializing StreamChat: Invalid API key
Solution: Verify that StreamChat credentials are correct.
error TS2307: Cannot find module 'stream-chat'
Solution: Run npm install to install dependencies.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License. See the LICENSE file for more details.
For support and questions:
- π§ Email: support@kabila.com
- π± Discord: Kabila Community
- π Documentation: docs.kabila.com
- StreamChat for the excellent chat API
- TypeScript for the type system
- Node.js for the JavaScript runtime
Enjoy building with Kabila! π