A ChatGPT-like application
ThreadBuddy is a simple AI chat application built for the class assignment. It supports multiple users and AI providers.
Read the short walkthrough for your instructor, then open the technical details if asked.
ThreadBuddy is a simple AI chat application built for the class assignment. It supports multiple users and AI providers.
Each learner signs up with a username and password. Chats belong to that account, not to other users.
Write a message. The application sends the current chat context to a selected AI model through its API.
Messages remain available after signing out. Select an old chat to continue from where you stopped.
The right sidebar lists earlier user questions. Click one to jump straight to that spot, without scrolling forever.
Save a useful message as memory. These pins can help future AI replies remember what the user explicitly chose.
Pick starting and ending prompts. The app prepares a mail draft; the user reviews and sends it in their email client.
Download the entire conversation as a readable Markdown file. Export memories and chats together in JSON.
Summarize a thread, save the result, copy it, email it or download it. If no API key exists, a clearly labelled demo summary is available.
An administrator manages keys, models and usage allowances. The app works in labelled demo mode before a paid key is connected.
These sections describe the implemented MVP, not proposed future features.
Single Bun/JavaScript Railway Function with server-side API routes and static HTML, CSS and JavaScript assets. JSON data is kept on a persistent Railway volume. It is intentionally a small demonstration, not a production SaaS architecture.
Users register with unique usernames and scrypt password hashes. Login creates a random server-side session with an HttpOnly cookie. Every chat, summary, memory and export endpoint checks account ownership. There is no email verification or password reset by email in the MVP.
Claude uses Anthropic's Messages API; Gemini uses Google's generateContent API; OpenRouter uses an OpenAI-compatible chat-completions interface. A common application function adapts requests and extracts the text response, preserving message history when changing providers.
Each user has private stored chats, messages, saved summaries and explicitly pinned memories. For an AI response, the app sends recent chat messages plus the saved summary and selected pinned facts. It does not transmit the entire chat history each time. A vector database and automatic semantic retrieval are deferred.
The frontend builds a list of user prompts from stored messages. Each prompt corresponds to a message DOM element; pressing it scrolls to that exact location. This is navigation, not AI regeneration or branching from an old prompt.
Selected passages are constructed between two user messages, then copied or passed to a mailto link that opens the user's email client; messages are not automatically emailed. Full-chat Markdown and per-user memory JSON are generated by authenticated server endpoints. Direct Google Drive integration is deferred to avoid OAuth complexity.
When AI is configured and limits permit, a short summarization request generates main topics, decisions, open questions and next steps; the summary is saved in the conversation. Without a provider, a clearly labelled basic demo summary reflects the last user prompts, not an invented AI answer.
AI keys are AES-256-GCM encrypted at rest using a server key. Passwords use scrypt hashes. Sessions use HttpOnly, SameSite cookies; same-origin checks protect mutations. User data is owner-scoped. Browser rendering uses text content to avoid injecting chat HTML. This is demonstration-grade security; public commercial deployment needs further review.
Admin-set daily call limits apply per user and globally. When live AI is unavailable, the interface displays a demo response rather than pretending it came from an AI model. Current state is a single JSON file, not PostgreSQL. Chat history is limited to 200 messages per thread, and memory pins are limited for the MVP. There is no web search, attachments, streaming responses, direct email sending or Drive OAuth.
Public: /api/health, /api/me. Authentication: /api/auth/register, /api/auth/login and /api/auth/logout. Chats: /api/chats, /api/chats/new, /api/chats/:id, /message, /summary, /rename, /delete, /export. Memory: /api/memory/pin, /delete, /export. Admin: /api/admin/login, /config, /save, /models, /remove-key and /password.
Managed PostgreSQL, email verification, robust billing safeguards, OAuth-based Google Drive export, editable summaries, threaded branching from prompt jump points, semantic memory retrieval, and side-by-side multi-model comparisons. These are deliberately excluded from the homework MVP.