How I Built an Open-Source Bilingual AI Social PWA with FastAPI, pgvector & QLoRA Qwen
Most social feeds optimize for outrage and endless scrolling. I wanted to build the opposite: a calm, bilingual (EN/ES) space where people share pure thoughts, cross ideas semantically with other thinkers like neurons, a
Most social feeds optimize for outrage and endless scrolling. I wanted to build the opposite: a calm, bilingual (EN/ES) space where people share pure thoughts, cross ideas semantically with other thinkers like neurons, and synthesize perspectives with AIβwithout addictive algorithms.
That became Think it (Live App Β· MIT GitHub Repo).
Rather than just shipping prompts in a wrapper, I focused on the system design, database isolation, and cloud/local AI parity behind it.
1. 3-Layer Decoupled Architecture
[React 19 + TypeScript + Tailwind v4 PWA (Vercel)]
β HTTPS + JWT + FormData
βΌ
[Async FastAPI + SQLAlchemy (Render)]
βββ /api/auth -> JWT, bcrypt, server-enforced is_demo blocks
βββ /api/thoughts -> Feeds, private Daily Think, pgvector HNSW RAG
βββ /api/interactions -> Sparks, Bounces, Neurons, Follows
βββ /api/messages -> 1-on-1 DMs with privacy enforcement
β
βββββββββββββββ΄ββββββββββββββ
βΌ βΌ
[Groq / QLoRA Qwen .gguf] [Supabase PostgreSQL 16 + pgvector]
- Hard-Won Production Lessons
Async SQLAlchemy + PgBouncer (statement_cache_size=0)
Deploying async FastAPI (asyncpg) behind managed PostgreSQL transaction pooling (PgBouncer) immediately breaks prepared statements unless statement_cache_size=0 is explicitly configured in the async engine connect args. Catching and enforcing that early keeps pooled serverless connections stable under load.
Dual Cloud / Local AI Parity (THINKIT_AI_PROVIDER)
During development, I fine-tuned Qwen 2.5 7B via QLoRA (Unsloth) and quantized it to q4_k_m.gguf running locally in Ollama for 5 synthesis lenses (Perspective Spark, Critical Contrast, Micro-Steps, Synthesis Quote, Open Question). For zero-GPU cloud production, a single environment switch routes the exact same lens prompts through Groqβwhile semantic crossing uses pgvector HNSW cosine similarity over 384d embeddings.
Server-Enforced Demo Isolation & Rate Limiting
Interactive demo accounts (is_demo) let visitors test the live app safely without polluting real users' DMs or mutating restricted account settingsβall blocked server-side in FastAPI dependencies alongside sliding-window rate limiting.
Packaging Reproducible Rules in SKILL.md
To avoid losing architectural context between iterations, I documented the deployment topology, pooler constraints, test gates (pytest, tsc --noEmit, oxlint, ruff), and launch policies in .skills/thinkit-lifecycle/SKILL.md.
Try It & Inspect the Code
- Live Web & Installable PWA: thinkit-saas.vercel.app
- Full Source Code + 30s Demo Video: github.com/abmserrut/thinkit-saas
- LinkedIn: Abraham Moreno
Would love feedback from fellow Python, FastAPI, and React engineers on the architecture trade-offs!
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.