Local Development Setup
Relevant source files
The following files were used as context for generating this wiki page:
The TrueLens project is an AI-powered content verification platform built using Next.js. It provides tools for detecting AI-generated text, verifying document integrity through cryptographic signing, and analyzing domain trust. The local development environment is designed to support both frontend UI development and the integration of backend analysis engines.
This setup enables developers to run the web application, simulate the multi-signal ML pipeline, and interact with the local API endpoints used for scanning URLs, text, and documents.
Sources: truelens-app/README.md:1-5, truelens-app/src/lib/analysis.ts:5-10
Environment Prerequisites
The application is built with Next.js 16 and React 19, requiring a modern JavaScript runtime environment.
| Dependency | Version / Requirement | Source |
|---|---|---|
| Node.js | ^20.0.0 (Recommended) | truelens-app/package.json:44 |
| Package Manager | npm, yarn, pnpm, or bun | truelens-app/README.md:7-15 |
| Next.js | 16.2.6 | truelens-app/package.json:19 |
| React | 19.2.4 | truelens-app/package.json:22 |
| Tailwind CSS | ^4 | truelens-app/package.json:49 |
Installation and Execution
The project follows standard Next.js bootstrapping procedures. After cloning the repository, developers must install dependencies and start the development server.
Start the Development Server
Use one of the following commands based on your preferred package manager:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Sources: truelens-app/README.md:7-15
By default, the application will be accessible at http://localhost:3000. The development server supports Hot Module Replacement (HMR), meaning the page updates automatically as files in app/ are modified.
Sources: truelens-app/README.md:17-21
System Architecture for Development
During local development, the frontend interacts with internal API routes. While the production environment suggests a FastAPI ML service, the local setup includes a simulated analysis engine in src/lib/analysis.ts.
Core Development Components
- Frontend (Next.js App Router): Handles the UI for scanning, dashboard, and developer portal.
- Mock Analysis Engine: Located in
src/lib/analysis.ts, it simulates ML features like stylometry and domain reputation. - API Integration Layer: Components in
scan/,documents/, andverify/communicate with/api/v1/*endpoints.
Data Flow Diagram
The following diagram illustrates how a user request flows through the local development environment from submission to result generation.
Local API Development
Developers can test integrations against several local API endpoints. These endpoints are utilized by the application pages to perform the platform's core functions.
| Endpoint | Method | Purpose | Related File |
|---|---|---|---|
/api/v1/scans | POST | Submit content for AI analysis | truelens-app/src/app/developers/page.tsx:16 |
/api/v1/scans/:id | GET | Retrieve specific scan results | truelens-app/src/app/results/[id]/page.tsx:32 |
/api/v1/documents | POST | Upload files for tamper detection | truelens-app/src/app/documents/page.tsx:44 |
/api/v1/verify | POST | Cryptographic hash/ID verification | truelens-app/src/app/verify/page.tsx:75 |
/api/v1/health | GET | Environment status check | truelens-app/src/app/developers/page.tsx:46 |
Analysis Engine Logic (Mock)
In the absence of a live ML backend during initial local setup, the performAnalysis function in src/lib/analysis.ts provides the logic for generating trust scores.
Text Analysis Features
The local engine extracts several stylometric features to determine if text is AI-generated:
- Vocabulary Richness: Unique word ratio.
- Burstiness: Variation in paragraph and sentence lengths.
- Punctuation Density: Ratio of punctuation to total words.
- Repetition Score: Frequency of repeated word patterns.
Sources: truelens-app/src/lib/analysis.ts:15-30
Document Verification Simulation
The document verification module simulates file analysis for local testing. It identifies document types (e.g., Aadhaar cards, Invoices) and runs "findings" based on file metadata and size.
Testing QR Verification
The local setup includes html5-qrcode to test document verification via QR codes. Developers can use the /verify page to simulate scanning a physical or digital document containing a TrueLens verification hash.
Sources: truelens-app/src/app/verify/page.tsx:1-15, truelens-app/package.json:15
Summary
The TrueLens local development environment provides a comprehensive Next.js setup with integrated analysis simulation. By leveraging the internal analysis.ts library, developers can test the full user journey—from content submission to detailed signal breakdown—without requiring an external ML infrastructure in the initial stages.
Sources: truelens-app/README.md:1-5, truelens-app/src/lib/analysis.ts:5-10