{"slug": "reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot", "title": "Reviving TruthGuard AI: From Zero History to Full CRUD with GitHub Copilot", "summary": "The author revived \"TruthGuard AI,\" a fake news detection tool, from a prototype into a production-ready application using GitHub Copilot. Copilot assisted in adding critical features like SQLite database persistence, environment configuration, unit tests, and a polished Streamlit user interface, generating most of the new infrastructure code. The project, built with Streamlit, LangChain, Tavily, and Groq's Llama 3.3-70B, was submitted for the GitHub Finish-Up-A-Thon Challenge.", "body_md": "This is a submission for the [GitHub Finish-Up-A-Thon Challenge](https://dev.to/challenges/github-2026-05-21).\n\n## 🛡️ What I Built\n\n**TruthGuard AI** is an enterprise-grade fake news detection and fact-checking tool that combines real-time web search with advanced LLM analysis. Users can paste any claim, news excerpt, or social media post, and the tool:\n\n- Searches the live web using Tavily's search API\n- Analyzes evidence using Groq's Llama 3.3-70B model\n- Provides a structured verdict with veracity score (0-100%)\n- Identifies logical fallacies and emotional manipulation\n- Offers a follow-up chat to interrogate the evidence\n\nThe application is built with **Streamlit** for the frontend, **LangChain** for LLM orchestration, **Tavily** for live web search, and **Groq's Llama 3.3-70B** for fast, high-quality inference.\n\nThis project started as a hackathon prototype where I had the core verification logic working, but it lacked persistence, testing, proper environment configuration, and a polished user experience. It was functional but incomplete — perfect for this challenge.\n\n## Demo\n\n🔗 **GitHub Repository:** [https://github.com/Awaisranahmad/AI-Based-Content-Verification-Tool](https://github.com/Awaisranahmad/AI-Based-Content-Verification-Tool)\n\n**GitHub Copilot in Action:**\n\n## 📸 Before vs After — The Comeback Story\n\n### Where It Was (The \"Before\")\n\nThe original version of TruthGuard AI was a working prototype that proved the concept but had significant gaps:\n\n| Issue | Impact |\n|---|---|\n| ❌ No history persistence | Results disappeared on page refresh |\n| ❌ No .env support | API keys only worked via Streamlit secrets; local development required manual editing |\n| ❌ No unit tests | Zero test coverage — fragile to API changes |\n| ❌ No delete or load functionality | History items stuck forever |\n| ❌ No \"New Chat\" option | No way to reset session |\n❌ Deprecated `st.experimental_rerun()`\n|\nCaused AttributeError in newer Streamlit versions |\n\n**The code worked for me, but nobody else could use it reliably.** There was no proper database setup, no environment configuration, and no way to revisit past verifications.\n\n### What Changed (The \"After\")\n\nI transformed TruthGuard AI from a prototype into a production-ready application with **GitHub Copilot** writing most of the new infrastructure.\n\n| Feature | Before | After |\n|---|---|---|\n| History | ❌ None | ✅ SQLite database with timestamps |\n| Load old claims | ❌ Not possible | ✅ One-click load with full report |\n| Delete history | ❌ Not possible | ✅ Delete button per item |\n| New chat | ❌ No reset | ✅ Reset all session state |\n| Environment | ❌ Hardcoded/st.secrets only | ✅ `.env` + st.secrets fallback |\n| Unit tests | ❌ 0 tests | ✅ 3 passing tests |\n| API calls on load | ❌ N/A | ✅ Load uses saved report (no re-verification) |\n| Deprecated code | ❌ `experimental_rerun`\n|\n✅ `rerun`\n|\n\n#### New Files Added\n\nDuring the revival, I added 6 new files to the repository:\n\n-\n`history_manager.py`\n\n— SQLite database operations (init_db, save_history, get_all_history, delete_history) -\n`tests/test_history_manager.py`\n\n— Unit tests with 3 passing tests -\n`.env.example`\n\n— Environment variable template -\n`.gitignore`\n\n— Python-appropriate ignores (.env,**pycache**, *.db) - Updated\n`requirements.txt`\n\n— Added pytest and python-dotenv - Updated\n`app.py`\n\n— Integrated history, .env support, and new UI buttons\n\n### Verdict Summary Extraction Logic\n\nOne of the more interesting additions was the extraction of structured data from the LLM's markdown output. The `extract_verdict_summary()`\n\nand `extract_veracity_score()`\n\nfunctions now cleanly parse the Groq Llama 3.3 response into database-friendly fields — something Copilot helped generate in a single prompt.\n\n## My Experience with GitHub Copilot\n\nThis was my first time using GitHub Copilot for a serious revival project, and it completely changed how I approach incomplete work. Here's exactly how Copilot helped me:\n\n### 1. Copilot Built the Entire `history_manager.py`\n\nModule\n\n**My prompt:**\n\n\"Create a Python module with SQLite database functions to store fact-check history. Columns: id, timestamp, claim, verdict_summary, veracity_score, full_report_text. Include functions: init_db(), save_history(), get_all_history(), delete_history().\"\n\n**Copilot generated:** All 6 database functions with proper error handling, SQL injection prevention (using parameterized queries), and connection management. I didn't write a single line of SQL manually.\n\n### 2. Copilot Added .env Support with Fallbacks\n\n**My prompt:**\n\n\"Add code to load .env file using python-dotenv, then fallback to st.secrets and os.getenv for API keys.\"\n\n**Copilot generated:** The complete environment loading chain, handling local development and Streamlit Cloud deployment seamlessly.\n\n### 3. Copilot Wrote All 3 Unit Tests\n\n**My prompt:**\n\n\"Write pytest unit tests for history_manager.py – test init_db, save_history, get_all_history, delete_history. Use temporary file for database.\"\n\n**Copilot generated:** Complete test file with fixtures and assertions. All 3 tests passed on first run.\n\n### 4. Copilot Added the \"New Chat\" and \"Delete\" Buttons\n\n**My prompt:**\n\n\"In the sidebar history section, next to each history item, add a small delete button. Also add a 'New Chat' button that clears the session and reruns.\"\n\n**Copilot generated:** The full Streamlit UI code with proper column layouts and session state management.\n\n### 5. Copilot Fixed the Deprecated `experimental_rerun`\n\nI ran into the `AttributeError: module 'streamlit' has no attribute 'experimental_rerun'`\n\nerror. Instead of searching Stack Overflow, I asked Copilot:\n\n\"What replaces experimental_rerun in newer Streamlit versions?\"\n\n**Copilot answered:** `st.rerun()`\n\nand replaced all occurrences automatically.\n\n### Key Copilot Patterns I Learned\n\n| Pattern | How I Used It |\n|---|---|\nComment-driven prompts |\nWriting detailed comments before implementation guides Copilot to generate exactly what's needed |\nFunction signature first |\nTyping `def save_history(` and letting Copilot infer the schema |\nIterative refinement |\nAccepting suggestions, then asking \"Add error handling\" or \"Use parameterized queries\" to improve them |\nTest generation |\nAsking Copilot to write tests before implementing the function (test-driven development with AI) |\n\nThe biggest surprise:Copilot didn't just autocomplete — it understood the project structure (Streamlit, SQLite, pytest) and generated context-aware code that integrated seamlessly with my existing logic.\n\n## 🛠️ Technical Stack\n\n| Component | Technology |\n|---|---|\n| Frontend | Streamlit (Python) |\n| LLM | Groq API (Llama 3.3-70B-Versatile) |\n| Search | Tavily Search API |\n| Orchestration | LangChain |\n| Database | SQLite |\n| Environment | python-dotenv |\n| Testing | pytest |\n| Dev Assistant | GitHub Copilot |\n\n## 🔍 Judging Criteria Reflection\n\n| Criterion | How TruthGuard AI Addresses It |\n|---|---|\nUse of underlying technology |\nCombines Groq's LPU (sub-second inference), Tavily's real-time search, and LangChain for structured prompting |\nUsability & UX |\nGlassmorphism UI, progress indicators, chat-based follow-ups, one-click report downloads, persistent history |\nOriginality & Creativity |\nLLM-powered fact-checking with structured verdicts (Veracity Score + Final Verdict + Bias detection) is not a basic chatbot wrapper — it's a purpose-built misinformation tool |\nCompletion Arc |\nClear \"before\" vs \"after\" transformation: from prototype to database-backed, tested, environment-aware application |\n\n## 📦 How to Run Locally\n\n```\nbash\n# Clone the repository\ngit clone https://github.com/Awaisranahmad/AI-Based-Content-Verification-Tool.git\ncd AI-Based-Content-Verification-Tool\n\n# Create virtual environment\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install dependencies\npip install -r requirements.txt\n\n# Create .env file with your API keys\ncp .env.example .env\n# Edit .env with your GROQ_API_KEY and TAVILY_API_KEY\n\n# Run the application\nstreamlit run app.py\n```\n\n", "url": "https://wpnews.pro/news/reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot", "canonical_source": "https://dev.to/awaisranahmad/reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot-42kl", "published_at": "2026-05-22 05:20:29+00:00", "updated_at": "2026-05-22 05:35:01.013586+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "large-language-models", "developer-tools", "open-source"], "entities": ["TruthGuard AI", "GitHub Copilot", "Streamlit", "LangChain", "Tavily", "Groq", "Llama 3.3-70B", "Awaisranahmad"], "alternates": {"html": "https://wpnews.pro/news/reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot", "markdown": "https://wpnews.pro/news/reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot.md", "text": "https://wpnews.pro/news/reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot.txt", "jsonld": "https://wpnews.pro/news/reviving-truthguard-ai-from-zero-history-to-full-crud-with-github-copilot.jsonld"}}