This is the main frontend application for the ChatSphere real-time chat platform. Built with React, TypeScript, and Vite, it provides a modern, responsive user interface for the chat functionality.
- React: UI library
- TypeScript: For type safety
- Vite: Build tool and development server
- TailwindCSS: Utility-first CSS framework
- WebSocket: For real-time communication
- Vitest: Testing framework
main/
├── public/ # Static assets
├── src/
│ ├── api/ # API client utilities
│ │ ├── httpApi.ts # HTTP API client
│ │ └── websocketApi.ts # WebSocket client
│ ├── components/ # React components
│ │ ├── Chat.tsx # Main chat component
│ │ ├── MessageBubble.tsx # Message display component
│ │ └── ...
│ ├── hooks/ # Custom React hooks
│ │ ├── useChat.ts # Chat functionality hook
│ │ └── ...
│ ├── types.ts # TypeScript type definitions
│ ├── App.tsx # Main application component
│ └── main.tsx # Application entry point
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
- Real-time Messaging: Send and receive messages instantly
- Room Management: Create and join chat rooms
- User Authentication: Secure user authentication
- API Token Management: Generate and manage API tokens
- Responsive Design: Works on desktop and mobile devices
-
Install dependencies:
npm install
-
Configuration: The package is pre-configured to connect to the Railway-hosted API and WebSocket servers.
API URL: https://react-live-chatroom-api-production.up.railway.app/api WS URL: wss://react-live-chatroom-api-production.up.railway.app/ws
-
Start the development server:
npm run dev
-
npm run dev
: Start development server -
npm run build
: Build for production -
npm run test
: Run tests -
npm run lint
: Run ESLint -
npm run preview
: Preview production build locally
The frontend integrates with the ChatSphere API server for:
- User Authentication: Login and registration
- Room Management: Creating and joining rooms
- Message Handling: Sending and receiving messages
- Token Management: Generating and revoking API tokens
Real-time messaging is implemented using WebSockets. The useChat
hook manages the WebSocket connection and provides methods for sending and receiving messages.
Tests are written using Vitest and React Testing Library. Run tests with:
npm test
To build the application for production:
npm run build
This will create a dist
directory with the compiled assets.
MIT