A modern React-based chat interface for interacting with an AI assistant. This application provides a clean, responsive UI for chatting with an AI assistant that supports both streaming and non-streaming responses, interactive charts, markdown rendering, and a professional dark theme.
- π― Real-time Streaming Chat: Experience live responses as the AI generates them
- π Interactive Charts: Automatically renders charts and graphs from AI responses
- π Markdown Support: Full markdown rendering with syntax highlighting and tables
- π¬ Multi-line Input: Auto-resizing textarea with support for multiple lines
- π Auto-focus Input: Automatically focuses input after AI responses for seamless conversation flow
- π± Responsive Design: Works seamlessly on desktop and mobile devices
- π Dark Theme: Professional dark theme with dark grey accents
- π Left Navigation: Dashboard and Assistant sections with clean navigation
- πΎ Conversation History: View and maintain chat history across sessions
- π Connection Status: Visual indicator showing server connection status
β οΈ Error Handling: Graceful error handling with user-friendly messages- π¨ Modern UI: Clean, accessible interface with smooth animations
- Node.js (version 14 or higher)
- The AI Assistant API server running on
localhost:5000
-
Clone the repository (if not already done)
-
Install dependencies:
npm install
This will install all required dependencies including:
- React and React DOM
- Chart.js and react-chartjs-2 for interactive charts
- react-markdown and remark-gfm for markdown rendering
- React Scripts for development
-
Start the development server:
npm start
-
Open your browser at
http://localhost:3000
This UI connects to the AI Assistant API running on localhost:5000. The following endpoints are used:
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/api/chat/stream |
POST | Streaming chat responses |
/api/chat |
POST | Non-streaming chat responses |
/api/history |
GET | Get conversation history |
/api/clear |
POST | Clear conversation history |
- Navigate to Assistant: Click "Assistant" in the left menu
- Type your message: Use the multi-line input field
- Send message: Press Enter or click the send button
- View responses: AI responses appear in real-time with typing indicators
The application supports full markdown rendering including:
- Headers (H1, H2, H3)
- Bold and italic text
- Code blocks and
inline code - Lists (ordered and unordered)
- Tables
- Blockquotes
- Links (open in new tab)
- GitHub Flavored Markdown (GFM) features
Example markdown content:
# Main Heading
This is a **bold** statement with *italic* text.
## Code Example
```javascript
function hello() {
console.log("Hello, World!");
}- Item 1
- Item 2
- Item 3
| Name | Age | City |
|---|---|---|
| John | 25 | NYC |
| Jane | 30 | LA |
### Interactive Charts
The application automatically detects and renders charts when the AI includes chart data in its responses.
**Supported Chart Types:**
- **Line Charts**: For trends and time series data
- **Bar Charts**: For comparisons and categorical data
- **Doughnut Charts**: For proportions and percentages
**Chart Data Format**: The AI should return data in this format:
```json
{
"type": "chart",
"chartType": "line",
"chartData": {
"title": "Sales Performance",
"labels": ["Jan", "Feb", "Mar", "Apr", "May"],
"datasets": [{
"label": "Sales",
"data": [12, 19, 3, 5, 2],
"borderColor": "rgb(75, 192, 192)",
"backgroundColor": "rgba(75, 192, 192, 0.2)"
}]
}
}
- Dashboard: Overview page with quick actions and recent activity
- Assistant: Main chat interface for AI conversations
src/
βββ components/
β βββ LeftMenu.js # Navigation sidebar
β βββ LeftMenu.css # Sidebar styles
β βββ Dashboard.js # Dashboard component
β βββ Dashboard.css # Dashboard styles
β βββ ChatInterface.js # Main chat component
β βββ ChatInterface.css # Chat interface styles
β βββ MessageList.js # Message display component
β βββ MessageList.css # Message list styles
β βββ MessageInput.js # Input component
β βββ MessageInput.css # Input styles
β βββ ChartMessage.js # Chart rendering component
β βββ ChartMessage.css # Chart styles
β βββ MarkdownRenderer.js # Markdown rendering component
β βββ MarkdownRenderer.css # Markdown styles
βββ services/
β βββ apiService.js # API integration service
βββ utils/
β βββ chartUtils.js # Chart data processing utilities
βββ App.js # Main app component
βββ App.css # Global styles
βββ index.js # Application entry point
npm start- Runs the app in development modenpm build- Builds the app for productionnpm test- Launches the test runnernpm eject- Ejects from Create React App (one-way operation)
- Background:
#1a1a1a(dark gray/black) - Secondary Background:
#2a2a2a(lighter dark gray) - Accent Color:
#4b5563(dark grey) - Text:
#e5e5e5(light gray/white) - Borders:
#404040(medium gray)
- Font Family: System fonts (San Francisco, Segoe UI, etc.)
- Font Weights: 400 (normal), 500 (medium), 600 (semibold)
- Left Menu: Fixed sidebar with navigation items
- Message Bubbles: User messages (dark grey), Assistant messages (dark background)
- Charts: Dark theme compatible with professional styling
- Markdown: Syntax highlighting and formatted content
- Input Field: Auto-resizing textarea with send button
- Uses Server-Sent Events (SSE) for real-time communication
- Shows typing indicators and streaming cursor
- Automatically scrolls to new messages
- Full GitHub Flavored Markdown (GFM) support
- Syntax highlighting for code blocks
- Responsive tables and lists
- Dark theme compatible styling
- Automatically focuses the input field after AI responses
- Enables seamless conversation flow without clicking
- 100ms delay ensures UI stability
- Auto-resizing textarea that grows with content
- Enter to send, Shift+Enter for new lines
- Maximum height with scrolling for very long messages
- Comprehensive error logging to browser console
- User-friendly error messages in the UI
- Connection status indicators
- Graceful fallbacks for API failures
This application works in all modern browsers including:
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Desktop: Full sidebar with 250px width
- Tablet: Reduced sidebar to 200px width
- Mobile: Sidebar becomes horizontal at top
- Charts: Responsive and touch-friendly
- Markdown: Optimized for all screen sizes
- Connection Error: Ensure the API server is running on
localhost:5000 - Charts Not Rendering: Check that chart data follows the correct JSON format
- Markdown Not Rendering: Ensure markdown content is properly formatted
- Styling Issues: Clear browser cache and restart the development server
- Open browser Developer Tools (F12)
- Check the Console tab for detailed error logs
- Network tab shows API request/response details
This project is open source and available under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review the browser console for errors
- Ensure the API server is running and accessible
- Verify all dependencies are installed correctly