Skip to content

taezeem14/Spectrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

549 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


PWA Offline Deploy Framework Math Backend Models Storage Memory Voice


Deploy Status Commits Last Commit Repo Size Stars


๐ŸŒ Live Demo

Link Description
๐Ÿš€ spectrix.netlify.app Primary deployment
โšก spectrix-ai.vercel.app Vercel deployment (better long streamed responses)
๐ŸŒ taezeem.is-a.dev/spectrix Custom domain mirror

โšก Local-first by default. Sign in with Google to unlock cloud backup + real-time multi-device sync.


๐Ÿ”ฅ What is Spectrix AI?

Spectrix AI is a high-performance, PWA-first AI chatbot engineered for students, developers, and power users.

Built from scratch โ€” zero frameworks, zero bloat โ€” it combines:

  • ๐Ÿค– Multi-model AI routing via OpenRouter (Stepfun, Qwen, Nemotron, and more)
  • โšก Edge-speed backend on Cloudflare Workers with smart key rotation
  • ๐Ÿงฎ Full LaTeX math rendering via KaTeX + MathJax with copy-to-clipboard
  • ๐Ÿ“ก Offline-first architecture with IndexedDB local persistence
  • ๐ŸŽค Voice I/O โ€” speak to it, hear it speak back
  • ๐Ÿง  Persistent AI Memory โ€” remembers you automatically, across sessions
  • ๐ŸŒ Web search mode โ€” real-time answers via Firecrawl + OpenRouter
  • ๐Ÿ–ผ๏ธ Image + Video generation โ€” /img and /vid commands
  • ๐Ÿ”’ Incognito mode โ€” zero trace, zero persistence, zero cloud
  • โ˜๏ธ Firebase Auth + Firestore โ€” Google Sign-In, profile management, cloud chat backup

Short version: it cooks. consistently. ๐Ÿ”ฅ


๐Ÿ“Š By The Numbers

Stat Value
๐Ÿ—“๏ธ Build Duration 3+ months
๐Ÿ” Commits 530+
๐Ÿš€ Deployments 280+
๐Ÿ“ฆ Framework None (Vanilla JS)
โš™๏ธ Backend Cloudflare Workers
๐Ÿ“ฑ Architecture Single-file PWA (index.html)

Iteration cycle: build โ†’ test โ†’ deploy โ†’ refine โ†’ repeat


โšก Core Features

๐Ÿค– AI Engine

  • Real-time SSE streaming via /chat/stream โ€” no waiting for full output
  • Legacy simulated streamer kept commented in index.html as fallback reference
  • Animated Thinking... state appears instantly while stream is warming up
  • Multi-model routing via OpenRouter โ€” switch models from the header
  • Smart API key rotation โ€” maximizes uptime and handles rate limits gracefully
  • Rate-limit UX โ€” friendly in-app message, not a dead crash
  • Web search mode โ€” powered by Firecrawl via OpenRouter (Ctrl+Shift+S to toggle)
  • Auto-titled chats โ€” AI names your conversations after the first exchange
  • Retry + Edit โ€” re-run any response or tweak your message mid-conversation

๐Ÿง  AI Memory

  • Persistent memory across conversations โ€” the AI knows who you are
  • Auto-extraction โ€” silently learns your name, preferences, goals, and tech stack
  • Manual memory โ€” add facts yourself via the ๐Ÿง  panel
  • Categorized โ€” personal, preference, technical, interest, context, general
  • Full control โ€” view all memories, delete individually, or wipe clean
  • Toggle on/off โ€” disable auto-learning anytime
  • Cooldown-throttled โ€” extraction runs max once every 5 minutes, no spam
  • Deduplication โ€” near-identical facts are never saved twice
  • IndexedDB-powered โ€” 100% local, private, zero server dependency

๐ŸŽค Voice & Interaction

  • Voice input via Web Speech API โ€” tap ๐ŸŽค, speak, done
  • Text-to-Speech output โ€” AI responses read aloud via the ๐Ÿ”Š toggle
  • TTS audio unlock โ€” mobile-compatible auto-unlock on first user interaction
  • Voice confirmation โ€” audible "Voice enabled" on toggle so you know it works
  • Keyboard shortcuts:
    • Ctrl+B / Cmd+B โ†’ New chat
    • Ctrl+F / Cmd+F โ†’ Search messages in chat
    • Ctrl+Shift+S โ†’ Toggle web search
    • Ctrl+/ โ†’ Focus history search

๐Ÿงฎ Math & Code

  • KaTeX + MathJax dual-engine โ€” renders inline $...$, display $$...$$, and complex environments
  • Lazy math engine loading โ€” KaTeX + MathJax load only when math is detected
  • Auto-rescue โ€” bare LaTeX commands wrapped in delimiters automatically
  • Copy LaTeX button โ€” hover any math block to copy the raw TeX
  • Code blocks โ€” syntax highlighting via Highlight.js, copy button, collapse toggle
  • Markdown โ€” full support: tables, blockquotes, headings, bold, italic, lists, images

๐Ÿ–ผ๏ธ Media Generation

  • /img <prompt> โ€” generates images using your selected model:
    • Imagen 4 Ultra / Fast
    • Nano Banana (Gemini Image)
    • FLUX.2 Max
    • GPT Image 1.5
  • /vid <prompt> โ€” generates short looping videos via ByteDance Seedance
  • Saved locally โ€” generated media persisted in IndexedDB as Blobs

๐Ÿ“ฑ App Experience

  • Installable PWA โ€” install on mobile or desktop like a native app
  • Offline-ready โ€” service worker caches the app shell
  • iOS install hint โ€” smart banner on Safari/iOS guides install
  • Auto-update โ€” new service worker activates without user action
  • Single-file architecture โ€” monolithic index.html, no build step
  • Dark/light theme โ€” toggle anytime, persists to localStorage
  • Incognito mode โ€” full blackout: no IndexedDB writes, no cloud sync, no memory, no profile persistence
  • Chat pinning โ€” pin important conversations to the top
  • Chat search โ€” fuzzy search across all history titles + message content
  • In-chat message search โ€” highlight matching messages with Ctrl+F
  • Smart auto-scroll follow โ€” sticks to latest while near bottom, pauses when you scroll up
  • Smooth manual jump + high-FPS stream scroll โ€” responsive even during long streaming replies
  • Export/Import โ€” download chats as .md or .json, re-import anytime
  • No browser popups โ€” clean custom modals for all alerts, confirms, and prompts
  • Custom select dropdowns โ€” animated, keyboard-navigable, beautiful

โ˜๏ธ Google Auth + Cloud Sync

  • Google Sign-In via Firebase Auth (popup with redirect fallback)
  • Real-time Firestore sync โ€” chats auto-mirror create/update/delete when logged in
  • Fallback timer sync โ€” polls cloud every 30s if realtime listener is blocked
  • Tombstone system โ€” deleted chats stay deleted across devices, no resurrection
  • Profile control hub โ€” backup, edit name/photo, upload device picture, or sign out
  • Profile injected into memory โ€” name remembered by the AI automatically
  • Ad-blocker resilience โ€” falls back gracefully when Firestore is blocked by extensions

๐Ÿง  AI Memory โ€” How It Works

User sends message
    โ”‚
    โ”œโ”€โ”€ AI responds normally
    โ”‚
    โ””โ”€โ”€ Background: Memory Extraction (throttled, async)
          โ”‚
          โ”œโ”€โ”€ Analyzes conversation for memorable user facts
          โ”œโ”€โ”€ Deduplicates against existing memories (80% word-overlap check)
          โ”œโ”€โ”€ Categorizes: personal / preference / technical / interest / context
          โ””โ”€โ”€ Saves to IndexedDB โ†’ 'memories' store
                โ”‚
                โ””โ”€โ”€ Every future conversation
                      โ”‚
                      โ””โ”€โ”€ Top 30 memories injected into system prompt
                            โ†’ AI uses context naturally, without repeating it back

๐Ÿ”’ All memories stored locally in your browser. Nothing leaves your device unless you're syncing chats โ€” and even then, memories never go to the cloud.


๐Ÿง  AI Models

Mode Model Best For
โšก Quick stepfun/step-3.5-flash:free Everyday use, fast replies
๐Ÿš€ Smart qwen/qwen3.6-plus:free Frontend dev, agentic tasks, fast + smart
๐Ÿง  Reasoning nvidia/nemotron-3-super-120b-a12b:free Deep reasoning, hard problems (slower)

๐Ÿ’พ Model preference saved to localStorage โ†’ Spectrix_text_model and persists across sessions.


๐Ÿ—๏ธ Architecture

User Browser
    โ”‚
    โ”œโ”€โ”€ PWA (Single HTML file โ€” HTML/CSS/Vanilla JS)
    โ”‚     โ”œโ”€โ”€ IndexedDB ['chats']    โ†’ Chat history (primary source of truth)
    โ”‚     โ”œโ”€โ”€ IndexedDB ['memories'] โ†’ AI Memory (persistent user context)
    โ”‚     โ”œโ”€โ”€ IndexedDB ['media']    โ†’ Generated image/video blobs
    โ”‚     โ”œโ”€โ”€ Service Worker         โ†’ Offline caching + auto-update
    โ”‚     โ”œโ”€โ”€ Web Speech API         โ†’ Voice input + TTS output
    โ”‚     โ”œโ”€โ”€ KaTeX + MathJax        โ†’ Dual-engine math rendering
    โ”‚     โ”œโ”€โ”€ Firebase Auth          โ†’ Google Sign-In
    |     โ”œโ”€โ”€ Image/Video model endpoints โ†’ Puter.js
    โ”‚     โ””โ”€โ”€ Firebase Firestore     โ†’ Cloud chat backup + real-time sync
    โ”‚
    โ””โ”€โ”€ Cloudflare Workers (Edge Backend)
          โ”œโ”€โ”€ API key rotation
          โ”œโ”€โ”€ Rate limit handling
          โ”œโ”€โ”€ SSE stream relay (`/chat/stream`)
          โ”œโ”€โ”€ Request proxying
          โ””โ”€โ”€ OpenRouter  โ†’  Multi-model AI routing
                              โ”œโ”€โ”€ Stepfun 3.5 Flash (Quick)
                              โ”œโ”€โ”€ Qwen 3.6 Plus (Smart)
                              โ”œโ”€โ”€ Nemotron 3 Super 120B (Reasoning)
                              โ””โ”€โ”€ Firecrawl (Web Search)


๐Ÿš€ Quick Start

# Option 1 โ€” npx serve
npx serve .

# Option 2 โ€” Python
python -m http.server 5500

# Option 3 โ€” VS Code Live Server
# Right-click index.html โ†’ Open with Live Server

Then open:

http://127.0.0.1:5500

No build step. No npm install. No config files. No .env. Just open and run. โšก


๐Ÿ’ป Tech Stack

Layer Tech
Frontend HTML, CSS, Vanilla JavaScript
Local Storage IndexedDB (chats + memories + media)
Cloud Sync Firebase Firestore
Auth Firebase Auth (Google Sign-In)
PWA Service Workers + Web App Manifest
Voice Web Speech API (STT + TTS)
Math KaTeX + MathJax (dual-engine)
Markdown Marked.js (with custom math extension)
Code Highlight.js
Backend Cloudflare Workers
AI Routing OpenRouter
Web Search Firecrawl (via OpenRouter plugins)
Image Gen Imagen 4, FLUX.2, GPT Image, Gemini Image
Video Gen ByteDance Seedance 1.0

๐ŸŽฏ Use Cases

  • ๐Ÿ“š Students โ€” math rendering, clean explanations, persistent context across sessions
  • ๐Ÿ’ป Developers โ€” debug code, agentic tasks, syntax-highlighted responses
  • ๐Ÿง  Researchers โ€” web search + reasoning mode for deep-dive topics
  • โšก Power Users โ€” voice I/O, keyboard shortcuts, multi-model switching, full data control

๐Ÿ“ธ Screenshots

Interface Math Rendering
Main UI Math
โšก Real-time streaming + dark mode ๐Ÿงฎ KaTeX + MathJax + copy button

๐Ÿ’ก How It Was Built

Spectrix follows an AI-assisted engineering workflow:

Idea  โ†’  AI generates core logic
      โ†’  Manually refined & debugged
      โ†’  Performance + UX optimized
      โ†’  Edge cases hunted down
      โ†’  Deployed & iterated relentlessly

AI is the tool โ€” not the decision-maker. Every architectural choice, every design decision, every UX fix โ€” made by a human. ๐Ÿง  530+ commits. 280+ deployments. Obsessive iteration. That's Spectrix.


๐Ÿ—บ๏ธ Roadmap

  • Folder/tag-based chat organization
  • Cloud memory sync (opt-in)
  • Custom system prompt editor
  • Multi-file upload support
  • Conversation branching

๐Ÿ‘จโ€๐Ÿ’ป Author

Muhammad Taezeem Tariq Matta

Built with AI. Refined with intent. Shipped with ๐Ÿ”ฅ


โญ Support

If Spectrix helped you โ€” drop a โญ on the repo. It means a lot. ๐Ÿ™

Not just another AI wrapper. A system built for speed, control, memory, and real-world use. โšก

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors