Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

TextSleuth AI

Next.js TypeScript Tailwind CSS Google Genkit License Version

Your intelligent partner for analyzing text. TextSleuth AI is a cutting-edge web application that detects AI-generated content and checks for plagiarism using advanced AI-powered tools.

Live Demo β€’ Report Bug β€’ Request Feature

πŸ“– Table of Contents

🎯 Features

  • πŸ€– AI Content Detection - Identify whether text is AI-generated or human-written with confidence scoring
  • πŸ” Plagiarism Checker - Detect plagiarism by comparing text against online sources and get similarity percentages
  • πŸ“œ History Tracking - Keep a record of your previous analyses for easy reference
  • 🎨 Modern UI - Clean, responsive interface built with Next.js and Tailwind CSS
  • ⚑ Real-time Analysis - Get instant results using Google Genkit AI flows
  • πŸ“± Fully Responsive - Works seamlessly on desktop, tablet, and mobile devices
  • πŸ” Type-Safe - Built with TypeScript for maximum reliability
  • πŸš€ Fast Performance - Powered by Next.js with Turbopack for lightning-fast builds

πŸš€ Tech Stack

  • Frontend: Next.js 15.3.3 with TypeScript
  • Styling: Tailwind CSS with shadcn/ui components
  • AI Engine: Google Genkit with genai provider
  • State Management: React Hooks
  • Form Handling: React Hook Form with Zod validation
  • Backend: Next.js Server Actions
  • Database: Firebase
  • Icons: Lucide React

πŸ“‹ Prerequisites

Before running the project, ensure you have:

πŸš€ Quick Start

# Clone the repository
git clone https://github.com/darvex-0/TextSleuthAi-Project.git
cd TextSleuthAi-Project

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your credentials

# Start development server
npm run dev

Navigate to http://localhost:9002 and start analyzing text!

βš™οΈ Installation

Step 1: Clone the Repository

git clone https://github.com/darvex-0/TextSleuthAi-Project.git
cd TextSleuthAi-Project

Step 2: Install Dependencies

npm install
# or
yarn install

Step 3: Set Up Environment Variables

Create a .env.local file in the root directory:

# Google Gemini API Key (Get free from https://aistudio.google.com/apikey)
GENKIT_API_KEY=your_gemini_api_key_here

Step 4: Configure Gemini API

  1. Visit Google AI Studio
  2. Click "Create API Key" (Free tier available)
  3. Copy your API key
  4. Paste it in .env.local as shown above

πŸƒ Running the Project

Development Mode

# Start Next.js development server (port 9002 with Turbopack)
npm run dev

Visit http://localhost:9002 to access the application.

Type Checking

# Verify TypeScript types without building
npm run typecheck

Linting

# Run ESLint checks
npm run lint

Production Build

# Create optimized production build
npm run build

# Start production server
npm start

πŸ“ Project Structure

src/
β”œβ”€β”€ ai/                                 # AI-related configurations
β”‚   β”œβ”€β”€ genkit.ts                      # Genkit initialization
β”‚   β”œβ”€β”€ dev.ts                         # Development setup
β”‚   └── flows/                         # AI workflow definitions
β”‚       β”œβ”€β”€ analyze-text-for-ai.ts     # AI detection flow
β”‚       └── check-text-for-plagiarism.ts # Plagiarism check flow
β”œβ”€β”€ app/                               # Next.js app directory
β”‚   β”œβ”€β”€ layout.tsx                     # Root layout
β”‚   β”œβ”€β”€ page.tsx                       # Home page
β”‚   β”œβ”€β”€ globals.css                    # Global styles
β”‚   β”œβ”€β”€ ai-detector/                   # AI detection tool
β”‚   β”‚   β”œβ”€β”€ page.tsx
β”‚   β”‚   └── actions.ts                # Server actions
β”‚   β”œβ”€β”€ plagiarism-checker/            # Plagiarism checker tool
β”‚   β”‚   β”œβ”€β”€ page.tsx
β”‚   β”‚   └── actions.ts                # Server actions
β”‚   └── history/                       # User history
β”‚       └── page.tsx
β”œβ”€β”€ components/                        # Reusable React components
β”‚   β”œβ”€β”€ ai-result-chart.tsx           # Visualization component
β”‚   └── ui/                           # shadcn/ui components
β”œβ”€β”€ hooks/                             # Custom React hooks
β”‚   β”œβ”€β”€ use-mobile.tsx                # Mobile detection
β”‚   └── use-toast.ts                  # Toast notifications
└── lib/                               # Utility functions
    β”œβ”€β”€ utils.ts
    β”œβ”€β”€ placeholder-images.json
    └── placeholder-images.ts

πŸ› οΈ Available Scripts

Command Description Port
npm run dev Start Next.js dev server with Turbopack 9002
npm run build Create optimized production build β€”
npm start Start production server 3000
npm run lint Run ESLint checks β€”
npm run typecheck Run TypeScript type checking β€”

πŸ”§ AI Flows

Analyze Text for AI (AI Detection)

Detects whether text is AI-generated or human-written.

Endpoint: POST /api/ai-detector

Input:

{
  text: string;  // The text to analyze
}

Output:

{
  isAiGenerated: boolean;      // Whether text is AI-generated
  confidenceScore: number;     // Confidence score (0-1)
}

Example:

curl -X POST http://localhost:9002/api/ai-detector \
  -H "Content-Type: application/json" \
  -d '{"text": "Your text here..."}'

Check Text for Plagiarism

Detects plagiarism by comparing text against online sources.

Endpoint: POST /api/plagiarism-checker

Input:

{
  text: string;  // The text to check for plagiarism
}

Output:

{
  similarityPercentage: number;  // Similarity percentage (0-100)
  sourceUrls: string[];          // URLs of matching sources
}

Example:

curl -X POST http://localhost:9002/api/plagiarism-checker \
  -H "Content-Type: application/json" \
  -d '{"text": "Your text here..."}'

βš™οΈ Configuration

Environment Variables

Variable Description Required
GENKIT_API_KEY Google Gemini API key βœ…

Get your free API key at: https://aistudio.google.com/apikey

Next.js Configuration

The project uses:

  • next.config.ts - Custom Next.js configuration
  • tsconfig.json - TypeScript configuration with strict mode
  • tailwind.config.ts - Tailwind CSS customization
  • postcss.config.js - PostCSS plugins
  • components.json - shadcn/ui component configuration

🎨 UI Components

The project leverages shadcn/ui, a high-quality component library built on Radix UI and Tailwind CSS:

Data Display: Accordion, Avatar, Badge, Card, Carousel, Chart, Progress, Skeleton, Table, Tabs

Input: Button, Checkbox, Dialog, Dropdown, Input, Label, Radio Group, Select, Slider, Switch, Textarea

Feedback: Alert, Alert Dialog, Toast, Tooltip

Layout: Collapsible, Menubar, Popover, Scroll Area, Separator, Sheet, Sidebar

For component documentation, visit shadcn/ui docs.

πŸ“± Responsive Design

The application is fully responsive and optimized for:

Device Breakpoint Status
Mobile < 640px βœ… Optimized
Tablet 640px - 1024px βœ… Optimized
Desktop > 1024px βœ… Optimized

All components adapt seamlessly across screen sizes using Tailwind CSS responsive utilities.

πŸ” Security

  • βœ… Type-Safe - Full TypeScript coverage for type safety
  • βœ… Server Actions - Secure server-side execution with Next.js
  • βœ… Form Validation - Input validation using Zod schemas
  • βœ… Environment Variables - API keys protected via .env.local (never committed to git)
  • βœ… API Key Protection - Keys never exposed to client-side code

πŸ› Troubleshooting

Port Already in Use

# If port 9002 is already in use, specify a different port
npm run dev -- -p 3000

Genkit Connection Issues

# Ensure your GEMINI_API_KEY is set correctly in .env.local
# The Genkit flows run automatically with npm run dev
  • Verify your API key is valid: https://aistudio.google.com/apikey
  • Check that Gemini API is enabled for your key
  • Verify .env.local file is in the root directory with the correct API key
  • Restart the development server after updating .env.local

Environment Variables Not Loading

# Verify .env.local exists in the root directory
ls -la .env.local

# Restart the development server after updating .env.local
# Clear Next.js cache if needed
rm -rf .next
npm run dev

TypeScript Errors

# Run type checking to identify issues
npm run typecheck

# Update dependencies if types are outdated
npm install --save-dev @types/node@latest

Gemini API Connection Errors

# Verify API key is set correctly
echo $env:GENKIT_API_KEY  # PowerShell on Windows
echo $GENKIT_API_KEY      # Bash on Mac/Linux
  • Ensure your API key is valid: https://aistudio.google.com/apikey
  • Check that Gemini API is enabled for your key
  • Verify .env.local file is in the root directory
  • Restart the development server after updating .env.local

For more help, check the troubleshooting guide or open an issue.

🀝 Contributing

We welcome contributions to TextSleuth AI! Here's how to get started:

Development Workflow

  1. Fork the repository

    git clone https://github.com/darvex-0/TextSleuthAi-Project.git
  2. Create a feature branch

    git checkout -b feature/amazing-feature
  3. Make your changes

    • Write clean, well-documented code
    • Follow the existing code style
    • Add tests if applicable
  4. Commit your changes

    git commit -m 'Add amazing feature'
  5. Push to the branch

    git push origin feature/amazing-feature
  6. Open a Pull Request

    • Describe the changes in detail
    • Reference related issues
    • Ensure all tests pass

Code Style

  • Use TypeScript for type safety
  • Follow ESLint rules: npm run lint
  • Format code with Prettier (if configured)
  • Write meaningful commit messages

Reporting Issues

When reporting bugs, please include:

  • OS and Node.js version
  • Steps to reproduce
  • Expected vs actual behavior
  • Error messages or screenshots

πŸ“„ License

You are free to use, modify, and distribute this software for any purpose. see the LICENSE file for details.

πŸ’¬ Support

Need help? Here are your options:

πŸŽ‰ Acknowledgments

This project was built with amazing open-source technologies:

Special thanks to the community for contributions and feedback!


⭐ Found this helpful? Consider giving us a star!

⬆ back to top

Made with ❀️ by the TextSleuth AI Team

Version: 0.1.0 | Last Updated: December 2025

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages