How kumarsai12383/chatwithgpt works
ChatWithGPT is a React chat application backed by Express, which forwards prompts and selected Gemini models to Google’s GenAI service. The principal flow is user input and model selection in the chat UI, an API wrapper’s POST to the backend, backend dispatch to Gemini, then response display as Markdown. The UI also persists chat history, validates input, auto-scrolls, and shows loading state; the backend exposes a health check and restricts CORS origins. Unsampled CSS and deployment details are represented only where documented.
Main entry points: App.jsx Chat UI · index.js Express API · api.js Chat API client · chat.js Gemini adapter
Components 12
Chat interface
- Chat UI
frontend/src/App.jsx - Chat API client
frontend/src/api.js - Loading spinner
frontend/src/Loading.jsx - Browser chat history
frontend/src/App.jsx - Markdown responses
frontend/src/App.jsx
Backend API
- Express API
backend/index.js - Health endpoint
backend/index.js - CORS allowlist
backend/index.js
AI generation
- Gemini adapter
backend/chat.js - Google GenAI service
- Gemini model
Other components
- User
Connections 12
- User → Chat UI: enters prompt
README.md - Chat UI → Chat API client: requests response
frontend/src/App.jsx - Chat UI → Loading spinner: renders loading
frontend/src/App.jsx - Chat UI → Browser chat history: reads and writes
frontend/src/App.jsx - Chat UI → Markdown responses: renders response
frontend/src/App.jsx - Chat API client → Express API: POSTs prompt
README.md - Express API → Gemini adapter: calls generator
backend/index.js - Gemini adapter → Google GenAI service: generates content
backend/chat.js - Google GenAI service → Gemini model: uses model
README.md - Express API → Chat API client: returns JSON
README.md - Express API → Health endpoint: serves status
backend/index.js - Express API → CORS allowlist: configures origins
backend/index.js