CalibAI Frontend is the client application for CalibAI, an AI assistant that routes every prompt to one of seven specialized agents β general chat, coding, web search, image generation, PDF generation, slide decks, and PDF question-answering.
It is a single-page React application built for a chat-first workspace: a collapsible conversation sidebar, a markdown/code message stream, and a right-hand artifact panel where generated code projects open in a Monaco editor with a sandboxed live HTML preview.
Companion repo:
CalibAI-Backendβ Express 5 microservices behind an API gateway, LangGraph multi-agent orchestrator, Redis sessions, and Razorpay billing.
- 7-agent routing β
Auto Β· Chat Β· Coding Β· Search Β· Image Β· PDF Β· PPTselectable per message from a chip selector; the backend router decides the final agent when set toAuto. - Streaming-style UX β optimistic message append, an
isAnsweringlock that disables inputs, and a cycling status shimmer (Thinking β Analyzing β Searching β Processing β Generating). - Rich markdown β
react-markdown+remark-gfmwith a full custom component map: headings, lists, GFM tables, annotated external links, and clickable images. - Syntax-highlighted code blocks β Prism
oneDarktheme, language label, one-click copy, inline vs. block detection. - Generated image gallery β 3-column grid opening a keyboard-navigable lightbox (
Esc/β/β, counter, backdrop blur).
- Right-hand panel with file tabs and a Monaco editor (
vs-dark, minimap when expanded). - Live preview: sibling
.cssand.jsfiles are inlined into the HTML and rendered inside asandbox="allow-scripts allow-modals"iframe β no build step, no network calls. - Copy-to-clipboard, language detection by file extension, Framer Motion width interpolation between 100% / 60% / 40%, and a spring slide-over drawer on mobile.
- History list with active-state highlighting, inline rename (Enter / Escape / blur, 100-char cap, optimistic update), and delete with a reusable confirm dialog.
- Auto-titles a "New Chat" to the first prompt.
- URL-as-state routing: the active conversation id lives in the pathname (
/chat/:id), synced withnavigate()and<Link>.
- Voice input via the Web Speech API β continuous interim results transcribed live into the composer, with permission/network error handling.
- File uploads β PDF and images up to 10 MB, thumbnail preview with a remove chip, sent as
multipart/form-data.
- Firebase Google sign-in (
signInWithPopup) β ID token exchanged once at the API β session held in an httpOnly cookie. No tokens are persisted inlocalStorage. - Granular popup error mapping (
auth/popup-closed-by-user,auth/popup-blocked, 401, 5xx, network) with inline error UI.
- Plans drawer with a live credits progress bar β Free, Starter βΉ199/mo β 500 credits, Pro βΉ399/mo β 1000 credits.
- Razorpay Checkout: order created server-side β
window.Razorpay(...).open()β signature verified server-side β credits refresh in the UI. - Credits decrement in near-real-time after each AI response.
- Tailwind CSS v4 CSS-first
@themedesign tokens (dark indigo/violet palette) consumed as utilities β no runtime JS config. - Hand-built components with
lucide-reacticons,react-hot-toastthemed to match, thin custom scrollbars, and Framer Motion panel choreography.
| Layer | Choice |
|---|---|
| Build | Vite 8, @vitejs/plugin-react |
| UI | React 19, TypeScript ~6.0 (strict) |
| State | Redux Toolkit 2 β user, conversation, message slices |
| Routing | React Router v7 (BrowserRouter, URL-as-state) |
| Styling | Tailwind CSS 4 (@theme tokens), Framer Motion 13 |
| Auth | Firebase Authentication (Google) β httpOnly session cookie |
| HTTP | Axios (single instance, withCredentials) + service-per-endpoint modules |
| Editor | @monaco-editor/react |
| Markdown | react-markdown, remark-gfm, react-syntax-highlighter |
| Speech | Web Speech API (SpeechRecognition) |
| Payments | Razorpay Checkout |
| Feedback | react-hot-toast |
| QA | ESLint 10 flat config, tsc -b type-check on build |
| Deploy | Vercel (SPA rewrite) |
- Node.js 20+ and npm
- A running
CalibAI-Backend(or setVITE_SERVER_URLto the deployed gateway) - A Firebase project with Google provider enabled
- A Razorpay account (test keys are fine) β optional for local UI work
git clone https://github.com/Regestrac/CalibAI-Frontend.git
cd CalibAI-Frontend
npm installcp .env.example .env| Variable | Description |
|---|---|
VITE_FIREBASE_API_KEY |
Firebase web app config |
VITE_FIREBASE_AUTH_DOMAIN |
Firebase web app config |
VITE_FIREBASE_PROJECT_ID |
Firebase web app config |
VITE_FIREBASE_STORAGE_BUCKET |
Firebase web app config |
VITE_FIREBASE_MESSAGING_SENDER_ID |
Firebase web app config |
VITE_FIREBASE_APP_ID |
Firebase web app config |
VITE_SERVER_URL |
Base URL of the backend API gateway (e.g. http://localhost:8000) |
VITE_RAZORPAY_KEY_ID |
Razorpay checkout key |
npm run dev # http://localhost:5173npm run build # tsc -b && vite build
npm run lint # ESLint 10 flat config
npm run preview # serve the production buildsrc/
βββ App.tsx # bootstraps current-user fetch, auth gate
βββ main.tsx # Redux Provider + BrowserRouter + Toaster
βββ index.css # Tailwind v4 @theme design tokens
β
βββ components/
β βββ ChatArea.tsx # message stream shell
β βββ ChatInput.tsx # composer: agent chips, voice, uploads
β βββ MessageList.tsx # markdown + code + image rendering
β βββ Artifact.tsx # Monaco editor + live preview panel
β βββ CodeBlock.tsx # syntax highlighting + copy
β βββ Lightbox.tsx # keyboard-navigable image viewer
β βββ FileUpload.tsx # PDF/image attachment chip
β βββ VoiceInput.tsx # Web Speech API dictation
β βββ Sidebar.tsx / Nav.tsx / ConfirmDialog.tsx
β βββ sidebar/ # ConversationList, PlansDrawer, AccountDetails
β
βββ pages/ # Home (workspace), SignupPage (auth gate)
βββ redux/ # store, userSlice, conversationSlice, messageSlice
βββ services/ # 10 API modules (one function per endpoint)
βββ hooks/ # typed Redux hooks, useMediaQuery
βββ helpers/ # agents constants, shared types
βββ utils/ # axios instance, firebase, buildPreview, toasts
Every request goes through one Axios instance bound to VITE_SERVER_URL with withCredentials: true, then through a small service module that catches errors, fires a toast, and returns a safe default:
| Service | Endpoint |
|---|---|
getCurrentUser |
GET /api/me |
logout |
POST /api/auth/logout |
createConversation |
GET /api/chat/create-conversation |
getConversations |
GET /api/chat/get-conversations |
getMessages |
GET /api/chat/get-messages/:chatId |
updateConversation |
POST /api/chat/update-conversation |
deleteConversation |
DELETE /api/chat/delete-conversation/:id |
sendMessage |
POST /api/agent/chat (multipart) |
createOrder |
POST /api/billing/create |
verifyPayment |
POST /api/billing/verify |
- Fork the repository
- Create a feature branch β
git checkout -b feature/amazing-thing - Commit your changes β
git commit -m "Add amazing thing" - Run
npm run lintandnpm run buildbefore pushing - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.