# Project export: ASET – Academic Safety and Evidencing Truth

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: UC Berkeley AI Hackathon 2026
- Tagline: ASET verifies scientific claims using evidence from 1.2M+ research papers, helping users detect misinformation and AI hallucinations with trusted, literature-backed insights.
- Devpost: https://devpost.com/software/aideas-finalist-aset-academic-safety-and-evidencing-truth
- GitHub: https://github.com/Cyberexe1/ASET_Berkley
- Demo: https://www.aset-ai.tech/
- Video: https://www.youtube.com/embed/Y4bQ_cyvoH0?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 1 GitHub contributor(s) — Vikas Tiwari (5 commits)

## Devpost submission (written by the team)

### Inspiration

Artificial intelligence has transformed how people access and consume information. Students use AI to assist with assignments, researchers use it to accelerate literature reviews, and content creators rely on it to generate educational content at scale. However, the same systems that increase productivity can also generate fabricated citations, unsupported claims, and scientifically inaccurate information that appears highly convincing. We were inspired by a simple but important question: How can users trust the information they receive in an AI-driven world? Existing academic tools are excellent at helping researchers discover papers, but they are not designed to verify the information people are already consuming. A student watching a YouTube lecture, a journalist reviewing a report, or an educator grading assignments does not want to manually search through hundreds of research papers. They simply want to know whether a claim is supported by credible scientific evidence. This challenge motivated us to build ASET (Academic Safety and Evidencing Truth), a platform that bridges the gap between information consumption and scientific verification. Our goal is to make evidence-based verification accessible, transparent, and practical for everyone. What it Does ASET is an AI-powered scientific claim verification engine that evaluates the credibility of information using evidence from over 1.2 million indexed peer-reviewed research papers. The platform accepts information from multiple sources, including direct text input, PDF documents, DOCX files, images, webpages, and YouTube videos. Once content is submitted, ASET automatically extracts factual claims, identifies the relevant scientific domain, retrieves supporting research, and generates a detailed verification report. Instead of simply providing search results, ASET analyzes the available evidence and produces a trust score, confidence assessment, supporting references, contradicting evidence, and a concise explanation of its findings. The platform is designed for students, educators, researchers, journalists, content creators, and everyday users who need a reliable way to verify scientific information before trusting or sharing it. ASET also includes a browser extension that allows users to verify claims directly from webpages without leaving their existing workflow. This transforms ASET from a standalone application into a browser-native trust layer for online information. How We Built It ASET was developed as a full-stack AI application that combines large-scale research retrieval with AI-powered reasoning. The frontend was built using React and Vite to create a responsive and intuitive user experience. The backend was developed using Node.js and Express and serves as the central orchestration layer for claim extraction, verification, retrieval, and report generation. To support large-scale scientific verification, we constructed a research corpus containing more than 1.2 million papers collected from trusted academic sources. These papers span multiple scientific disciplines including medicine, biology, chemistry, physics, engineering, computer science, and space science. The verification workflow consists of several stages: Claim Extraction Domain Identification Research Retrieval Evidence Analysis Trust Score Generation Verification Report Creation Large Language Models are used to analyze the retrieved evidence and determine whether a claim is supported, contradicted, or lacks sufficient evidence. The final result is presented in a transparent format that allows users to understand both the verdict and the reasoning behind it. To improve accessibility and usability, we also developed a browser extension that integrates directly with webpages, enabling real-time verification without disrupting the user's browsing experience. Challenges We Ran Into One of the most significant challenges was designing a system that could differentiate itself from traditional academic search engines and research discovery platforms. Many existing tools focus on helping researchers locate papers. Our challenge was fundamentally different: helping users verify information they are already consuming. This required us to rethink the user journey and build workflows centered around verification rather than discovery. Another challenge involved scaling retrieval across a research corpus exceeding one million papers while maintaining fast response times. Verification systems must provide results quickly enough to remain useful, particularly when processing documents containing multiple claims. Handling multiple content formats also presented technical difficulties. Text, PDFs, images, webpages, and videos all require different extraction and preprocessing techniques before claims can be analyzed consistently. Finally, one of our most important design considerations was transparency. We wanted users to trust the platform's conclusions, which meant presenting supporting evidence, confidence scores, and citations rather than producing opaque AI-generated answers. Accomplishments That We're Proud Of We are proud that ASET evolved from a simple scientific verification concept into a comprehensive evidence-based trust platform. Some of our key accomplishments include: Building a verification system powered by over 1.2 million indexed research papers. Supporting verification across multiple input formats including text, PDFs, images, webpages, and YouTube videos. Developing a browser extension that enables real-time verification directly within a user's workflow. Creating a scalable retrieval and verification pipeline capable of handling large scientific datasets. Designing transparent trust scores supported by evidence and citations. Expanding beyond a single scientific domain into a multidisciplinary verification platform. Achieving recognition as a Top 50 Finalist in the AWS AIdeas Competition. Most importantly, we built a platform that empowers users to make informed decisions in an era where information can be generated instantly but trust must still be earned. What We Learned Throughout the development of ASET, we learned that misinformation is not merely a technical challenge; it is fundamentally a challenge of trust. Users do not necessarily want access to more information. Instead, they want confidence that the information they already have is accurate and supported by credible evidence. We also learned that transparency is critical for AI systems operating in high-trust environments. Users are more likely to trust conclusions when they can see the evidence, sources, and reasoning process behind them. From a technical perspective, we gained valuable experience in large-scale information retrieval, AI-assisted reasoning, claim extraction, evidence synthesis, and designing systems that combine retrieval and generation in meaningful ways. Most importantly, we learned that building useful AI products requires focusing on real user workflows rather than simply showcasing advanced technology. What's Next for ASET Our long-term vision is to establish ASET as a universal trust layer for scientific information. Future development will focus on expanding our research corpus, improving verification accuracy, supporting additional languages, and introducing more advanced multi-agent reasoning workflows. We also plan to enhance browser-based verification capabilities and develop dedicated tools for educational institutions, researchers, and media organizations. As AI-generated content continues to grow across every industry, the need for trustworthy verification systems will become increasingly important. We believe ASET can play a significant role in ensuring that evidence remains at the center of how people consume, evaluate, and share information. Our mission is simple: transform scientific evidence into accessible trust for everyone.

## README (from the GitHub repository)

<div align="center">

<svg width="80" height="80" fill="none" xmlns="http://www.w3.org/2000/svg">
<ellipse cx="0.30304" cy="2.42612" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="5.75226" cy="2.42612" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="11.2132" cy="2.42612" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="16.662" cy="2.42783" rx="1.81824" ry="1.81846" fill="white"/>
<ellipse cx="22.1135" cy="2.42622" rx="2.12128" ry="2.12153" fill="white"/>
<ellipse cx="27.5767" cy="2.42461" rx="2.42432" ry="2.42461" fill="white"/>
<ellipse cx="0.30304" cy="7.88511" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="5.75226" cy="7.88511" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="11.2066" cy="7.87476" rx="1.5152" ry="1.51538" fill="white"/>
<ellipse cx="16.662" cy="7.88291" rx="1.81824" ry="1.81846" fill="white"/>
<ellipse cx="22.1135" cy="7.88325" rx="2.12128" ry="2.12153" fill="white"/>
<ellipse cx="27.5783" cy="7.88325" rx="2.12128" ry="2.12153" fill="white"/>
<ellipse cx="0.30304" cy="13.3402" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="5.75226" cy="13.3402" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="11.2122" cy="13.3354" rx="1.21216" ry="1.2123" fill="white"/>
<ellipse cx="16.6715" cy="13.3318" rx="1.5152" ry="1.51538" fill="white"/>
<ellipse cx="22.1229" cy="13.3321" rx="1.81824" ry="1.81846" fill="white"/>
<ellipse cx="27.5721" cy="13.3321" rx="1.81824" ry="1.81846" fill="white"/>
<ellipse cx="0.30304" cy="18.7914" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="5.75452" cy="18.7937" rx="0.606081" ry="0.606152" fill="white"/>
<ellipse cx="11.2138" cy="18.794" rx="0.909121" ry="0.909228" fill="white"/>
<ellipse cx="16.6614" cy="18.7904" rx="1.21216" ry="1.2123" fill="white"/>
<ellipse cx="22.1207" cy="18.7888" rx="1.5152" ry="1.51538" fill="white"/>
<ellipse cx="27.5765" cy="18.7914" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="0.30304" cy="24.2406" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="5.75452" cy="24.2487" rx="0.606081" ry="0.606152" fill="white"/>
<ellipse cx="11.2076" cy="24.2487" rx="0.606081" ry="0.606152" fill="white"/>
<ellipse cx="16.6624" cy="24.2406" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="22.1234" cy="24.2406" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="27.5765" cy="24.2406" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="0.30304" cy="29.6976" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="5.75226" cy="29.6976" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="11.2132" cy="29.6976" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="16.6624" cy="29.6976" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="22.1234" cy="29.6976" rx="0.30304" ry="0.303076" fill="white"/>
<ellipse cx="27.5765" cy="29.6976" rx="0.30304" ry="0.303076" fill="white"/>
</svg>

# ASET — Academic Safety and Evidencing Truth

### AI-Powered Scientific Claim Verification Platform

[![Status](https://img.shields.io/badge/Status-Production-success)](https://www.aset-ai.tech)
[![Papers](https://img.shields.io/badge/Papers-1.2M+-blue)](https://www.aset-ai.tech)
[![Domains](https://img.shields.io/badge/Domains-8-purple)](https://www.aset-ai.tech)

[Live App](https://www.aset-ai.tech) · [API Spec](https://api.aset-ai.tech/openapi.json)

</div>

---

## What is ASET?

ASET stops AI hallucinations and misinformation by verifying scientific claims against 1.2M+ peer-reviewed papers across 8 domains — in real time.

**The problem:** 46% of AI-generated citations are fabricated. Students, teachers, journalists, and content creators unknowingly spread misinformation backed by fake research.

**The solution:** ASET verifies any claim — typed, uploaded, or from a YouTube video — against a pre-indexed database of peer-reviewed papers, returning a trust score and supporting evidence. When no local papers exist, ASET fetches from arXiv + PubMed in real time and permanently stores them — the database grows with every query.

---

## Features

- **Mode 1 — Single Claim**: Type any scientific claim, verified in under 200ms
- **Mode 2 — YouTube**: Paste a YouTube URL — transcript extracted, every claim verified
- **Mode 3 — Document**: Upload PDF, DOCX, or image (OCR) — all claims identified and verified
- **Multi-Agent Pipeline**: 4 specialized agents (Research → Verification → Citation → Report) coordinated via Band Protocol
- **Self-Growing DB**: Fetches from arXiv + PubMed when no local papers found, stores permanently
- **Paper Search**: Search 1.2M+ papers by title/author/keyword — no login required
- **8 Scientific Domains**: Space Science, Biology, Medicine, Chemistry, Physics, CS, Engineering + more
- **1.2M+ Papers**: Pre-indexed with FTS5 for sub-200ms search
- **Browser Extension**: Highlight any text on any webpage and verify instantly
- **Email OTP**: Password reset via Nodemailer
- **Citation Export**: APA, MLA, and IEEE formatted citations for every verification

---

## Architecture

```
React Frontend (Vite)            Node.js Backend (Express)
Google Cloud Run                 Google Cloud Run
https://aset-ai.tech             https://api.aset-ai.tech
        │                                 │
        └────────── HTTPS API ────────────┘
                                          │
                       Container images — Google Artifact Registry
                       Secrets — Google Secret Manager
                                          │
                            ┌─────────────────────────┐
                            │     Agent Pipeline       │
                            │  ResearchAgent           │
                            │  VerificationAgent       │
                            │  CitationAgent           │
                            │  ReportAgent             │
                            │  (Band Protocol bus)     │
                            └─────────────────────────┘
                                          │
                               Turso (libSQL/SQLite + FTS5)
                               1.2M papers · 72 topics · 28 domains
                                          │
                               Redis — agent memory, research cache,
                               verification history, rate limiting
                                          │
                               Google Gemini API
                               Claim extraction + verification
                                          │
                               Arize Phoenix — LLM observability,
                               hallucination tracking, quality monitoring
                                          │
                               Browserbase — managed browser sessions
                               for web evidence extraction
                                          │
                               arXiv OAI-PMH + PubMed E-utilities
                               Self-growing database
```

---

## Tech Stack

| Layer | Technology |
|-------|-----------|
| Frontend | React 19, Vite 7, globe.gl |
| Backend | Node.js 22, Express |
| Deployment | Google Cloud Run, Artifact Registry, Secret Manager |
| Database | Turso (libSQL/SQLite) with FTS5 |
| Cache & Memory | Redis — research cache, agent memory, verification history |
| AI | Google Gemini API (multi-key rotation) |
| Agent Framework | Fetch.ai Agentverse (uAgents) |
| Message Bus | Band Protocol (inter-agent relay) |
| Observability | Arize Phoenix — LLM tracing, hallucination detection |
| Web Fetch | Browserbase — managed browser sessions |
| Auth | JWT + bcrypt + Email OTP |
| Document Processing | pdf-parse, mammoth, tesseract.js |
| YouTube | Multi-method transcript extraction (3 fallback strategies) |
| Extension | Chrome Manifest V3 |

---

## Multi-Agent Pipeline

ASET uses a 4-agent pipeline where each agent has a single responsibility and agents communicate via the Band Protocol message bus:

```
User Claim
    │
    ▼
ResearchAgent        — searches

[README truncated for size]

## Detected evidence (automated analysis)

Indexed codebase: 86 recognized source files, 615 KB.
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- React (technology) — detected in the code
- Redis (technology) — detected in the code
- AWS (technology) — claimed on Devpost, not found in the code
- Node.js (technology) — claimed on Devpost, not found in the code
- Python (language) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (111 of 111)

```
.dockerignore
.env.example
.gcloudignore
.github/workflows/deploy-backend.yml
.github/workflows/deploy-frontend.yml
.gitignore
ASET frontend/.dockerignore
ASET frontend/.gitignore
ASET frontend/cloudbuild.yaml
ASET frontend/Dockerfile
ASET frontend/eslint.config.js
ASET frontend/index.html
ASET frontend/nginx.conf
ASET frontend/package.json
ASET frontend/public/robots.txt
ASET frontend/public/sitemap.xml
ASET frontend/README.md
ASET frontend/src/App.css
ASET frontend/src/App.jsx
ASET frontend/src/assects/fonts/neuroxa-futuristic-font/iFonts-License.txt
ASET frontend/src/assects/fonts/neuroxa-futuristic-font/neuroxa.otf
ASET frontend/src/assects/fonts/sesbania-font-1762946819-0/info.txt
ASET frontend/src/assects/fonts/sesbania-font-1762946819-0/sesbania-italic_fontlot91b4.otf
ASET frontend/src/assects/fonts/sesbania-font-1762946819-0/sesbania-regular_fontlotc6e7.otf
ASET frontend/src/components/AgentPipelineDemo.jsx
ASET frontend/src/components/ChatArea.jsx
ASET frontend/src/components/DocumentVerifier.jsx
ASET frontend/src/components/EditChatModal.jsx
ASET frontend/src/components/ForgotPassword.jsx
ASET frontend/src/components/HistoryView.jsx
ASET frontend/src/components/index.js
ASET frontend/src/components/LandingPage.jsx
ASET frontend/src/components/Login.jsx
ASET frontend/src/components/MessagesArea.jsx
ASET frontend/src/components/PaperCard.jsx
ASET frontend/src/components/PaperSearchPage.jsx
ASET frontend/src/components/PasswordInput.jsx
ASET frontend/src/components/ProfilePage.jsx
ASET frontend/src/components/Register.jsx
ASET frontend/src/components/SearchResults.jsx
ASET frontend/src/components/SettingsPage.jsx
ASET frontend/src/components/Sidebar.jsx
ASET frontend/src/components/TrendingPage.jsx
ASET frontend/src/components/UserDropdown.jsx
ASET frontend/src/components/VerificationResults.jsx
ASET frontend/src/components/WelcomeScreen.jsx
ASET frontend/src/context/AuthContext.jsx
ASET frontend/src/hooks/useChatState.js
ASET frontend/src/hooks/useSidebar.js
ASET frontend/src/index.css
ASET frontend/src/main.jsx
ASET frontend/src/services/api.js
ASET frontend/src/services/chatService.js
ASET frontend/src/services/reportGenerator.js
ASET frontend/src/services/spaceDigestService.js
ASET frontend/src/services/youtubeTranscript.js
ASET frontend/src/styles/auth.css
ASET frontend/src/styles/chat.css
ASET frontend/src/styles/landing.css
ASET frontend/src/styles/searchResults.css
ASET frontend/src/styles/trending.css
ASET frontend/vite.config.js
aset-extension/background.js
aset-extension/content.css
aset-extension/content.js
aset-extension/icons/create-icons.js
aset-extension/icons/generate.js
aset-extension/manifest.json
aset-extension/popup.html
aset-extension/README.md
aset-key.pem
backend/agents/agent-pipeline.js
backend/agents/band-bus.js
backend/agents/citation-agent.js
backend/agents/report-agent.js
backend/agents/research-agent.js
backend/agents/verification-agent.js
backend/ai-provider.js
backend/arize-tracer.js
backend/auth.js
backend/browserbase-fetcher.js
backend/claim-verifier.js
backend/document-processor.js
backend/otp-service.js
backend/paper-fetcher.js
backend/redis-client.js
backend/server-turso.js
cf-config.json
cf-config2.json
cf-update.json
cf-update2.json
DEMO.md
Dockerfile
eng.traineddata
fix-pem.ps1
package.json
README.md
scripts/domains/ingest-biology.js
scripts/domains/ingest-chemistry.js
scripts/domains/ingest-cs.js
scripts/domains/ingest-engineering.js
scripts/domains/ingest-medicine.js
scripts/domains/ingest-physics.js
scripts/ingest-all-domains.js
scripts/lib/arxiv-oai-ingestor.js
scripts/lib/domain-ingestor.js
scripts/lib/pubmed-ingestor.js
scripts/migrate-new-domains.js
scripts/migrate-to-turso-fast.js
scripts/rebuild-fts.js
scripts/test-redis.js
```

### Dependencies

- ASET frontend/package.json: @eslint/js@^9.39.1, @types/react@^19.2.5, @types/react-dom@^19.2.3, @vitejs/plugin-react@^5.1.1, eslint@^9.39.1, eslint-plugin-react-hooks@^7.0.1, eslint-plugin-react-refresh@^0.4.24, globals@^16.5.0, globe.gl@^2.45.2, jspdf@^4.2.1, leaflet@^1.9.4, react@^19.2.0, react-dom@^19.2.0, react-leaflet@^5.0.0, three@^0.182.0, vite@^7.2.4
- package.json: @arizeai/openinference-semantic-conventions@^0.3.0, @distube/ytdl-core@^4.16.12, @libsql/client@^0.15.15, @opentelemetry/exporter-trace-otlp-http@^0.52.1, @opentelemetry/sdk-trace-base@^1.25.1, @opentelemetry/sdk-trace-node@^1.25.1, bcryptjs@^2.4.3, cors@^2.8.5, dotenv@^16.6.1, express@^4.18.2, groq-sdk@^0.37.0, jsonwebtoken@^9.0.2, mammoth@^1.12.0, multer@^2.1.1, nodemailer@^8.0.4, pdf-parse@^1.1.1, redis@^4.7.0, tesseract.js@^7.0.0, youtube-transcript@^1.3.0, youtubei.js@^17.0.1

### Recent commits (newest first)

- Update team section in README
- Merge gcp-migration into main: GCP deployment, README updates
- updates
- merge branch
- updates
- Fix punctuation in ASET description
- ASET — Academic Safety and Evidencing Truth
- feat: agent pipeline UI, Arize OTel, Redis smoke test, demo walkthrough, CI env vars
- updates
- updates

## Key source files (fetched from GitHub, selected and truncated for size)

### DEMO.md

```markdown
# ASET — Hackathon Demo Walkthrough

**Live app:** https://www.aset-ai.tech  
**API:** https://api.aset-ai.tech  
**Repo:** https://github.com/Cyberexe1/ASET_Berkley

---

## What ASET Does in 30 Seconds

ASET verifies scientific claims against 1.2M+ peer-reviewed papers in real time. Paste a claim, get a trust score, verdict, supporting papers, and formatted citations — all backed by a 4-agent AI pipeline.

---

## Sponsor Prize Demo Paths

### 🥇 Redis — Beyond Caching

**What we use it for (not just cache):**
- Agent memory — each agent in the pipeline saves its output to Redis so downstream agents can retrieve context
- Verification history — per-user sorted set of all past verifications (fast, no DB join)
- Research cache — 1-hour TTL cache on paper search results (avoids repeated FTS queries)
- Rate limiting — sliding window per-IP throttle on pipeline and Browserbase endpoints
- Token blacklist — JWT invalidation on logout without touching the database
- Real-time analytics — domain popularity leaderboard, total verification counter

**Demo endpoints:**
```bash
# Live Redis stats (top domains + total verifications)
curl https://api.aset-ai.tech/api/redis/stats

# Expected response:
# {
#   "topDomains": [{"domain": "neuroscience", "count": 42}, ...],
#   "totalVerifications": 156,
#   "redisConnected": true
# }
```

**Run smoke test locally:**
```bash
# Start Redis
docker run -d -p 6379:6379 redis:alpine

# Run all Redis tests
node scripts/test-redis.js
```

---

### 🥇 Fetch.ai Agentverse — Multi-Agent Workflow

**4 agents, each with a single responsibility:**

| Agent | Role | Band channel |
|-------|------|-------------|
| ResearchAgent | Search 1.2M+ papers | research.request → research.results |
| VerificationAgent | LLM stance classification | research.results → verification.done |
| CitationAgent | APA/MLA/IEEE formatting | verification.done → citations.ready |
| ReportAgent | Assemble final report | citations.ready → report.complete |

**Demo — trigger the full pipeline:**
```bash
curl -X POST https://api.aset-ai.tech/api/agents/pipeline \
  -H "Content-Type: application/json" \
  -d '{"claim": "CRISPR-Cas9 can permanently edit the human germline genome"}'

# Returns: reportId, verdict, score, keyFindings, citations (APA/MLA/IEEE), pipeline timing
```

**Check agent status + message log:**
```bash
curl https://api.aset-ai.tech/api/agents/status
```

**Frontend demo:** Open https://www.aset-ai.tech → click **🤖 Agent Pipeline** tab → enter any scientific claim → watch all 4 agents activate in sequence with real-time status updates.

---

### 🥈 Band Protocol — Inter-Agent Message Bus

**How it works:**
- All 4 agents communicate via named Band Protocol channels (`research.request`, `research.results`, `verification.done`, `citations.ready`, `report.complete`)
- Local mode: in-process EventEmitter (zero latency, no external dependency)
- On-chain mode: set `BAND_MNEMONIC` → each channel publish submits an oracle data request to the B
[truncated — 4719 more characters]
```

### Dockerfile

```
FROM node:22-alpine

WORKDIR /app

# Copy package files
COPY package.json package-lock.json ./

# Install production dependencies only
RUN npm ci --omit=dev

# Copy backend source
COPY backend/ ./backend/

# Create uploads directory
RUN mkdir -p uploads

EXPOSE 3001

CMD ["node", "backend/server-turso.js"]

```

### package.json

```
{
  "name": "appendix-retrieval-engine",
  "version": "1.0.0",
  "description": "Module 2: Appendix-Based Retrieval Engine for Scientific Claim Verification",
  "main": "backend/server.js",
  "scripts": {
    "start": "node backend/server-turso.js",
    "start:old": "node backend/server.js",
    "migrate": "node scripts/migrate-to-turso.js",
    "ingest:arxiv": "node scripts/ingest-arxiv.js",
    "ingest:nasa": "node scripts/ingest-nasa-ads.js",
    "build": "node scripts/build-index.js"
  },
  "keywords": [
    "scientific",
    "claim",
    "verification",
    "appendix",
    "retrieval"
  ],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@arizeai/openinference-semantic-conventions": "^0.3.0",
    "@distube/ytdl-core": "^4.16.12",
    "@libsql/client": "^0.15.15",
    "@opentelemetry/exporter-trace-otlp-http": "^0.52.1",
    "@opentelemetry/sdk-trace-base": "^1.25.1",
    "@opentelemetry/sdk-trace-node": "^1.25.1",
    "bcryptjs": "^2.4.3",
    "cors": "^2.8.5",
    "dotenv": "^16.6.1",
    "express": "^4.18.2",
    "groq-sdk": "^0.37.0",
    "jsonwebtoken": "^9.0.2",
    "mammoth": "^1.12.0",
    "multer": "^2.1.1",
    "nodemailer": "^8.0.4",
    "pdf-parse": "^1.1.1",
    "redis": "^4.7.0",
    "tesseract.js": "^7.0.0",
    "youtube-transcript": "^1.3.0",
    "youtubei.js": "^17.0.1"
  }
}

```

### ASET frontend/package.json

```
{
  "name": "aset-frontend",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "globe.gl": "^2.45.2",
    "jspdf": "^4.2.1",
    "leaflet": "^1.9.4",
    "react": "^19.2.0",
    "react-dom": "^19.2.0",
    "react-leaflet": "^5.0.0",
    "three": "^0.182.0"
  },
  "devDependencies": {
    "@eslint/js": "^9.39.1",
    "@types/react": "^19.2.5",
    "@types/react-dom": "^19.2.3",
    "@vitejs/plugin-react": "^5.1.1",
    "eslint": "^9.39.1",
    "eslint-plugin-react-hooks": "^7.0.1",
    "eslint-plugin-react-refresh": "^0.4.24",
    "globals": "^16.5.0",
    "vite": "^7.2.4"
  }
}

```

### ASET frontend/Dockerfile

```
# ── Build stage ──────────────────────────────────────────────────────────────
FROM node:22-alpine AS build

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .

# Injected at build time via --build-arg (see cloudbuild step)
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL

RUN npm run build

# ── Serve stage ──────────────────────────────────────────────────────────────
FROM nginx:1.27-alpine

COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8080

CMD ["nginx", "-g", "daemon off;"]

```

### ASET frontend/src/main.jsx

```javascript
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'

// Track page visit — fire and forget, non-blocking
fetch('/api/track-visit', { method: 'POST' }).catch(() => {});

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>,
)

```

### ASET frontend/src/App.jsx

```javascript
import React from 'react';
import { AuthProvider, useAuth } from './context/AuthContext';
import Sidebar from './components/Sidebar';
import ChatArea from './components/ChatArea';
import LandingPage from './components/LandingPage';
import TrendingPage from './components/TrendingPage';
import Login from './components/Login';
import Register from './components/Register';
import { useSidebar } from './hooks/useSidebar';
import { chatService } from './services/chatService';
import './styles/chat.css';
import './styles/searchResults.css';
import './styles/auth.css';
import './styles/landing.css';
import './styles/trending.css';

function AppContent() {
  const { isAuthenticated, loading, user } = useAuth();
  const [showAuth, setShowAuth] = React.useState(false);
  const [showRegister, setShowRegister] = React.useState(false);
  const [showLanding, setShowLanding] = React.useState(false); // logged-in user viewing landing
  const { isExpanded, activeItem, toggleSidebar, setActive } = useSidebar();
  const [currentView, setCurrentView] = React.useState('welcome');
  const [messages, setMessages] = React.useState([]);
  const [chatName, setChatName] = React.useState('New Chat');
  const [currentChatId, setCurrentChatId] = React.useState(null);

  // Add/remove chat-mode class based on authentication
  React.useEffect(() => {
    if (isAuthenticated) {
      document.body.classList.add('chat-mode');
    } else {
      document.body.classList.remove('chat-mode');
    }
    return () => {
      document.body.classList.remove('chat-mode');
    };
  }, [isAuthenticated]);

  // Auto-save chat when messages change (only if authenticated)
  React.useEffect(() => {
    if (messages.length > 0 && isAuthenticated) {
      const saveChat = async () => {
        try {
          if (currentChatId) {
            // Update existing chat
            await chatService.updateChat(currentChatId, {
              messages: messages,
              messageCount: messages.length,
              name: chatName
            });
          } else {
            // Create new chat
            const firstUserMessage = messages.find(m => m.type === 'user')?.content || 'New Chat';
            const result = await chatService.createChat(firstUserMessage, messages);
            if (result.success) {
              setCurrentChatId(result.chatId);
            }
          }
        } catch (error) {
          console.error('Failed to save chat:', error);
        }
      };
      saveChat();
    }
  }, [messages, chatName, currentChatId, isAuthenticated]);

  const handleItemClick = (item) => {
    setActive(item);

    if (item === 'history') {
      setCurrentView('history');
    } else if (item === 'current-chat') {
      if (messages.length > 0) {
        setCurrentView('messages');
      } else {
        setCurrentView('welcome');
      }
    } else if (item === 'trending') {
      setCurrentView('trending');
    } else if (item === 'profile') {
      setCurrentView('profile');
    } else if (item === 'settings') {
      setCurrentView('settings');
    } else if (item === 'home') {
      setShowLanding(true);
      document.body.classList.remove('chat-mode');
    }
  };

  const handleNewChat = () => {
    setMessages([]);
    setChatName('New Chat');
    setCurrentChatId(null);
    setCurrentView('welcome');
    setActive('current-chat');
  };

  const handleLoadChat = async (chatId) => {
    const result = await chatService.loadChatMessages(chatId);
    if (result.success) {
      setMessages(result.messages);
      setChatName(result.chatName || 'Chat');
      setCurrentChatId(chatId);
      setCurrentView('messages');
      setActive('current-chat');
    }
  };

  const handleGetStarted = () => {
    setShowAuth(true);
  };

  if (loading) {
    return <div className="loading-screen">Loading...</div>;
  }

  // Authenticated user viewing landing page
  if (isAuthenticated && showLanding) {
    // Remove chat-mode so landing page can scroll
    document.body.classList.remove('chat-mode');
    return <LandingPage onGetStarted={() => setShowLanding(false)} isLoggedIn={true} onGoToApp={() => setShowLanding(false)} />;
  }

  if (!isAuthenticated) {
    if (!showAuth) {
      return <LandingPage onGetStarted={handleGetStarted} />;
    }
    
    return showRegister ? (
      <Register onSwitchToLogin={() => setShowRegister(false)} />
    ) : (
      <Login onSwitchToRegister={() => setShowRegister(true)} />
    );
  }

  if (currentView === 'trending') {
    return (
      <div className="app-container">
        <Sidebar isExpanded={isExpanded} onToggle={toggleSidebar} activeItem={activeItem} onItemClick={handleItemClick} onNewChat={handleNewChat} />
        <TrendingPage />
      </div>
    );
  }

  return (
    <div className="app-container">
      <Sidebar
        isExpanded={isExpanded}
        onToggle={toggleSidebar}
        activeItem={activeItem}
        onItemClick={handleItemClick}
        onNewChat={handleNewChat}
      />
      <ChatArea 
        userName={user?.name || user?.email || 'User'}
        currentView={currentView}
        setCurrentView={setCurrentView}
        messages={messages}
        setMessages={setMessages}
        chatName={chatName}
        setChatName={setChatName}
        onLoadChat={handleLoadChat}
      />
    </div>
  );
}

function App() {
  return (
    <AuthProvider>
      <AppContent />
    </AuthProvider>
  );
}

export default App;

```

### ASET frontend/src/components/index.js

```javascript
export { default as Sidebar } from './Sidebar';
export { default as ChatArea } from './ChatArea';
export { default as WelcomeScreen } from './WelcomeScreen';
export { default as MessagesArea } from './MessagesArea';
export { default as HistoryView } from './HistoryView';
export { default as UserDropdown } from './UserDropdown';
export { default as EditChatModal } from './EditChatModal';
export { default as TrendingPage } from './TrendingPage';
export { default as LandingPage } from './LandingPage';
export { default as Login } from './Login';
export { default as Register } from './Register';

```

### ASET frontend/cloudbuild.yaml

```yaml
steps:
  - name: 'gcr.io/cloud-builders/docker'
    args:
      - 'build'
      - '--build-arg'
      - 'VITE_API_URL=${_VITE_API_URL}'
      - '-t'
      - '${_IMAGE}'
      - '.'
images:
  - '${_IMAGE}'

```

### ASET frontend/vite.config.js

```javascript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    proxy: {
      '/api': 'http://localhost:3001',
      '/health': 'http://localhost:3001'
    }
  }
})

```

[75 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]