Academigo
Study companion with a React + HeroUI front end, a small Django API that keeps the Langflow token server-side, a Botpress chat surface, browser-side history and light and dark themes.
Overview
A study companion: you ask a question, an AI assistant answers. The web app is a React front end; the model side is a Langflow flow hosted on DataStax Astra, reached either through a small Django API or through an embedded Botpress webchat.
- Front end
- React 18 + Vite
- API
- Django + DRF
- AI flow
- Langflow on Astra
- Themes
- Light + dark
It started as a team hackathon-style project and the repo shows it: two ways of talking to a model, a typed client for features the server never got, and a lot of the polish in the chat experience on the browser side. The sections below describe what is actually in the code.
Architecture
Three pieces, deliberately thin. The front end owns the experience; Django exists to keep the Langflow token off the browser.
React (Vite, :5173)
│ POST /api/get-response { prompt }
▼
Django + DRF (:8000) ── CORS allowlist ──► reads LANGFLOW_TOKEN from .env
│ POST …/lf/<flow>/api/v1/run/<id> { input_value, chat in / out }
▼
Langflow flow on DataStax Astra
│ JSON: outputs[0].outputs[0].results.message.data.text
▼
{ "message": "Response Generated", "response": "<text>" }
Chat page: React ──► @botpress/webchat widget (hosted bot, no Django hop)| Layer | Choice | Why |
|---|---|---|
| UI | React 18, Vite, TypeScript, HeroUI, Tailwind 4 | Fast dev loop, accessible components, themeable out of the box |
| Routing | react-router-dom 6 | Home, chat, docs, pricing, blog, about; vercel.json rewrites everything to the SPA |
| API | Django REST framework | Two endpoints, SQLite, no models yet; its job is to proxy |
| AI | Langflow on Astra | Flow edited visually and called over HTTP, so prompt changes need no deploy |
| Chat widget | @botpress/webchat | A hosted chat surface with its own bot, used on the chat page |
The AI flow
The Django side is intentionally small: take a prompt, call the flow, return the text.
- Endpoint · POST /api/get-response takes { prompt } and returns 400 when it is empty.
- Secrets · The Langflow application token is read from the environment with python-dotenv and sent as a Bearer header, so it never reaches the browser.
- Payload · input_value plus chat input and output types, which is what the Langflow run API expects for a chat flow.
- Failure · Network and JSON errors are caught; the endpoint answers with the error text instead of a 500, so the chat UI can show something.
response = lf.get_response(prompt)
text = response['outputs'][0]['outputs'][0]['results']['message']['data']['text']Front end
A HeroUI + Tailwind 4 single-page app with a landing page, a chat page and the usual product pages.
| Route | What it does |
|---|---|
| / | Landing: "Learn Smarter, not Harder", Get Started and GitHub buttons |
| /chat | Sidebar with features and tips plus the chat area; opens the Botpress webchat from a welcome screen or a floating button |
| /docs, /pricing, /blog, /about | Product pages on the shared default layout and navbar |
react-markdown renders assistant replies, so code blocks and lists from the model look right instead of arriving as one long string.
Chat history
History is kept in the browser. There is no account and no database, so a conversation costs nothing to store and is private by default.
- Storage · One JSON document in localStorage: messages (role, content, timestamp), lastUpdated and a session id that is preserved across saves.
- Autosave · Writes are debounced to one second so typing and streaming do not hammer storage, and a forced save runs before the page unloads.
- Actions · New chat, export to a JSON file and import from one. Importing replaces the session and is saved immediately.
- Safety · Every read and write is wrapped in try/catch, so a full or blocked store degrades to an empty chat instead of a crash.
Light & dark
Both themes are first-class, including the parts that are not mine.
- App theme · HeroUI's theme hook drives a navbar switch (sun / moon) that toggles the light and dark class for every component.
- No flash · The switch renders a placeholder until it mounts, so server and client markup match and there is no hydration mismatch.
- Third-party widget · The Botpress webchat does not follow the app theme, so the chat page listens to the OS prefers-color-scheme setting separately and passes it through.
Status & next
What is built, and what is described but not wired up yet.
- Built · Landing and chat UI, light and dark themes, Langflow proxy endpoint, Botpress chat, browser-side history with export and import, SPA deploy config.
- Ahead of the backend · The front end has typed clients for server-side sessions (create, list, send, delete, rename). The Django app has no models yet, so these are not used.
- Roadmap · Quizzes, a Telegram bot, multi-PDF upload and calendar or Notion integration are listed in the README as the next layer.
- To harden · Move the API base URL and Langflow flow ids into environment config, and validate the flow response instead of indexing into it.
Deep dive
Bugs that cost real time, with what the symptom looked like, the actual cause, and the fix.
Context
The flow returns the answer five levels down (outputs, outputs, results, message, data, text), and any change to the flow can move it.
Decision
The extraction lives in one place and is wrapped so a malformed reply becomes an error message in the response rather than a server error. The next step is validating the shape (a small serializer) so a flow change fails loudly in tests, not in front of a user.