A real-time multilingual AI-powered chat application built with Go (backend) and React (frontend). The app detects user languages automatically and translates messages using OpenAI GPT models.
- Features
- Screenshot & GIF
- Tech Stack
- Architecture
- Getting Started
- Backend Setup
- Frontend Setup
- Usage
- Folder Structure
- Real-time WebSocket chat communication.
- Automatic language detection for each user’s messages.
- AI-powered message translation per recipient.
- Modern, responsive UI built with React.
- Clear separation of backend and frontend logic for maintainability.
Backend:
- Go 1.21
- Gorilla WebSocket for real-time communication
- OpenAI GPT-3.5 API via Resty client
Frontend:
- React (JavaScript)
- SCSS for styling
- WebSocket API for real-time updates
flowchart LR
A[Client] --> B[Server]
B --> C[Language Detection & Translation]
C --> B
B --> A
Flow:
- Clients connect to Server via WebSocket.
- Backend detects the language of messages using GPT.
- Messages are translated to recipient’s language if needed.
- Messages are broadcasted to all connected clients.
- React frontend renders messages in real-time.
Backend Setup
- Clone the repository:
git clone https://github.com/cjr03/MultilingualChat-AI.git
cd MultilingualChat-AI/backend
- Install Go dependencies:
go mod tidy
- Add environment variables in .env:
OPENAI_API_KEY=your_openai_api_key_here
PORT=9000
- Build frontend:
cd ../frontend
npm install
npm run build
- Run the backend server:
cd ../backend
go run main.go
- Your app will be available at:
http://localhost:9000
Frontend Setup
- Navigate to frontend folder:
cd frontend
- Install dependencies:
npm install
- Start the frontend development server:
npm start
- Runs on http://localhost:3000 by default.
- Connects automatically to backend WebSocket at the same host.
- Open the frontend in a browser.
- Type a message in the input box and hit Enter.
- Messages are automatically detected and translated for other users.
- Real-time updates appear for all connected clients.
MultilingualChat-AI/
├─ backend/
│ ├─ main.go
│ ├─ go.mod
│ ├─ go.sum
│ ├─ pkg/
│ │ ├─ websocket/
│ │ │ ├─ client.go
│ │ │ ├─ pool.go
│ │ │ └─ websocket.go
│ │ └─ ai/
│ │ └─ gpt.go
│ └─ config/
│ └─ config.go
│
├─ frontend/
│ ├─ public/
│ ├─ src/
│ │ ├─ api/
│ │ │ └─ index.js
│ │ ├─ components/
│ │ │ ├─ Header/
│ │ │ ├─ ChatHistory/
│ │ │ ├─ ChatInput/
│ │ │ └─ Message/
│ │ ├─ App.js
│ │ ├─ App.css
│ │ ├─ App.test.js
│ │ ├─ index.css
│ │ ├─ index.js
│ │ └─ reportWebVitals.js
│ └─ package.json
├─ .env
├─ docs/
│ ├─ start.png
│ └─ talk.gif
├─ README.md
└─ .gitignore