Skip to content
ijatinydvPublic

About

Make labFiles in seconds

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Next.js TypeScript Tailwind Prisma

⚡ LabSnap

AI-Powered Lab Record Generator for Engineering Students

Generate perfect lab documentation with a single click. No more manual formatting!

Live Demo


✨ Features

Feature Description
🤖 AI Generation Automatically generates code, output, and theory using advanced AI models
📄 DOCX Export Download print-ready Word documents instantly
🎨 Smart Formatter Already have code? Paste it with screenshots to create formatted lab records
☁️ Cloud Save Save experiments to your dashboard for easy access
🖨️ Ink Saver Optimized output formatting to save printer ink
⚡ Instant Generation Get your complete lab record in under 30 seconds
🆓 Freemium Model Try 5 generations free as a guest, 20 credits on signup

🛠️ Tech Stack

📁 Project Structure

labsnap/
├── prisma/
│   └── schema.prisma      # Database schema (User, Experiment, GuestUsage)
├── public/                # Static assets
├── src/
│   ├── app/
│   │   ├── api/
│   │   │   ├── generate/  # AI generation endpoint
│   │   │   └── experiments/# Experiment CRUD operations
│   │   ├── dashboard/     # User dashboard (protected)
│   │   ├── format/        # Smart Formatter page
│   │   ├── generate/      # Main generation page
│   │   └── page.tsx       # Landing page
│   ├── components/
│   │   ├── ui/            # Reusable UI components
│   │   ├── LabForm.tsx    # Main experiment form
│   │   ├── FakeTerminal.tsx # Terminal output preview
│   │   └── ...
│   ├── lib/
│   │   ├── db.ts          # Prisma client
│   │   ├── generateDoc.ts # DOCX generation logic
│   │   └── utils.ts       # Utility functions
│   └── middleware.ts      # Auth & route protection
├── .env.local             # Environment variables
└── package.json

🚀 Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/labsnap.git
    cd labsnap
  2. Install dependencies

    npm install
  3. Set up environment variables

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

    # Database
    DATABASE_URL="mongodb+srv://<username>:<password>@<cluster>.mongodb.net/labsnap"
    
    # Clerk Authentication
    NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxx
    CLERK_SECRET_KEY=sk_test_xxxxx
    NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
    NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
    
    # AI Provider
    NOVITA_API_KEY=your_novita_api_key
    NOVITA_MODEL=xiaomimimo/mimo-v2.6-flash
    # Optional comma-separated fallback models
    NOVITA_FALLBACK_MODELS=
  4. Generate Prisma client

    npx prisma generate
  5. Push database schema

    npx prisma db push
  6. Start the development server

    npm run dev
  7. Open your browser

    Navigate to http://localhost:3000

📖 Usage

Generate a Lab Record

  1. Go to the Generate page
  2. Fill in the experiment details:
    • Experiment Number
    • Date
    • Subject (C++, Java, Python, DBMS, etc.)
    • Aim of the experiment
    • Name and Roll Number (optional)
  3. Click Generate
  4. Preview the code and terminal output
  5. Download as a formatted DOCX file

Smart Formatter

Already have your own code? Use the Smart Formatter:

  1. Paste your code
  2. Upload output screenshots
  3. Get a perfectly formatted lab record document

Dashboard

Sign in to access:

  • Saved experiments
  • Credit balance
  • Re-download previous records

🌐 Supported Subjects

Subject Features
C++ Code + Console Output
Java Code + Console Output
Python Code + Console Output
DSA Code + Console Output
DBMS/SQL Theory + Syntax + Code + ASCII Table Output

📝 API Reference

POST /api/generate

Generate lab record content using AI.

Request Body:

{
  "aim": "Write a program to implement bubble sort",
  "subject": "C++",
  "name": "John Doe",
  "rollNo": "21CS101",
  "mode": "full"
}

Response:

{
  "type": "coding",
  "code": "// Source code here...",
  "output_text": "// Console output here..."
}

API Access Guide

  • Base URL (OpenAI-compatible): https://api.novita.ai/openai
  • Base URL (Anthropic-compatible): https://api.novita.ai/anthropic
  • API Endpoint: chat/completions, responses
  • Model ID: Controlled by NOVITA_MODEL (default: xiaomimimo/mimo-v2.6-flash)
  • Fallback models (optional): NOVITA_FALLBACK_MODELS (comma-separated)

🔐 Authentication

LabSnap uses Clerk for authentication:

  • Guest Users: 5 free generations (tracked by IP)
  • Signed-in Users: 20 credits on signup
  • Protected Routes: /dashboard, /api/experiments/*

🙏 Acknowledgments


Made with ❤️ for Engineering Students

About

Make labFiles in seconds

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages