Full-stack AI chat application with authentication, chat sessions, realtime assistant messages, mobile-friendly UI, and dynamic prompt suggestions.
New Chat AI/
Backend/ # Express + MongoDB + Socket.IO API
frontend/ # React + Vite client
Frontend:
- React 19 + TypeScript
- Vite
- Redux Toolkit
- Tailwind CSS
- Socket.IO Client
Backend:
- Node.js + Express
- MongoDB + Mongoose
- JWT auth (access/refresh)
- Socket.IO
- OpenRouter API integration
- Register/login/logout with protected routes
- Persistent chat sessions and message history
- AI response generation via backend
- Realtime assistant delivery through Socket.IO
- Session token usage indicator
- News-powered prompt suggestions
- Mobile-optimized chat interface
- Node.js 18+
- npm 9+
- MongoDB database
- OpenRouter API key
- NewsData API key (for suggestion cards)
cd Backend
npm install
Create env file:
- Copy
Backend/.env.exampletoBackend/.env - Fill real values
Required backend env keys:
PORT=4000
NODE_ENV=development
MONGO_URI=mongodb://127.0.0.1:27017/nexus_ai
JWT_SECRET=replace_with_strong_secret
FRONTEND_ORIGIN=http://localhost:5173
OPENROUTER_API_KEY=your_openrouter_api_key
OPENROUTER_MODEL=gpt-4o-mini
OPENROUTER_API_URL=https://openrouter.ai/api/v1/chat/completions
Run backend:
npm run dev
Backend default URL: http://localhost:4000
cd ../frontend
npm install
Create env file:
- Copy
frontend/.env.exampletofrontend/.env - Fill real values
Required frontend env keys:
VITE_API_BASE_URL=http://localhost:4000/api/v1
VITE_SOCKET_URL=http://localhost:4000
VITE_NEWSDATA_API_KEY=your_newsdata_api_key
Run frontend:
npm run dev
Frontend default URL: http://localhost:5173
Base path: /api/v1
Auth:
POST /auth/registerPOST /auth/loginPOST /auth/refreshPOST /auth/logoutGET /auth/me
Chat:
GET /chat/sessionsPOST /chat/messagesGET /chat/:idDELETE /chat/session/:id
AI:
POST /ai/ask(auth required)
- Backend emits
newMessageevents via Socket.IO. - Assistant responses are persisted to chat session when
sessionIdis provided.
Dashboard suggestions use NewsData directly from frontend:
- Endpoint:
https://newsdata.io/api/1/latest - Filters:
country=in,cn,au,wolanguage=ta,en,mlcategory=technology,education,food,health,lifestyle
Backend (Backend folder):
npm run devnpm start
Frontend (frontend folder):
npm run devnpm run buildnpm run previewnpm run lint
- Do not commit
.envfiles with real secrets. - Rotate secrets immediately if they are ever exposed.
- Keep only placeholder values in
*.env.example.
- Backend details:
Backend/README.md - Frontend details:
frontend/README.md