Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Turbo-Doc

A Powerful Document & Image Conversion Platform

Transform your documents and images with ease. Built with modern web technologies for speed, reliability, and scale.

License Build Status Node

🌐 Live Demo

πŸ“‹ Table of Contents

πŸš€ Overview

Turbo-Doc is a full-stack document and image conversion platform built with a modern monorepo architecture. It provides users with powerful file processing capabilities including format conversion, PDF merging/splitting, and image optimization with a beautiful, responsive UI.

Key Highlights

  • Fast Processing: Worker thread-based architecture for non-blocking file operations
  • Scalable: Turborepo monorepo with shared packages and optimized builds
  • Secure: Better Auth integration with social providers, file encryption, and secure S3 storage
  • Flexible: Support for guest users and authenticated users with tiered subscription plans
  • Modern: Built with Next.js 16, React 19, and the latest web technologies

✨ Features

Document Processing

  • Format Conversion: Convert between PDF, DOCX, TXT, PPT, XLSX formats
  • PDF Manipulation: Merge multiple PDFs or split PDF by page range
  • Batch Processing: Process multiple files simultaneously
  • Auto-expiration: Automatic cleanup based on user plan retention period

Image Operations

  • Format Conversion: Convert between JPEG, PNG, WebP, AVIF, GIF
  • Compression: Optimize image file size with quality controls
  • Resizing: Scale images from 25% to 200% of original size
  • Dimension Detection: Automatic width/height detection

User Management

  • Authentication: Email/password and social login (Google, GitHub) via Better Auth
  • Guest Access: Limited daily conversions without account creation
  • Subscription Plans: FREE and PRO tiers with varying limits
  • Usage Tracking: Real-time monitoring of daily quotas

Payment Integration

  • Razorpay: Secure payment processing for PRO subscriptions
  • Webhooks: Automated subscription management
  • Invoice Generation: Transaction history and receipts

πŸ›  Tech Stack

Monorepo

  • Turborepo - High-performance build system
  • pnpm - Fast, disk space efficient package manager

Frontend (apps/web)

Backend (apps/api)

Database & ORM

Authentication

  • Better Auth - Modern authentication library
  • OAuth Providers: Google, GitHub
  • Session Management: Cookie-based with cross-subdomain support

File Processing

  • Sharp - High-performance image processing
  • LibreOffice - Document format conversion (headless)
  • PDF-lib - PDF manipulation

Storage & CDN

  • AWS S3 - Object storage
  • AWS CloudFront - Content delivery network
  • Presigned URLs: Secure file upload/download

Payment

  • Razorpay - Payment gateway (India)
  • Webhook Integration: Automated subscription updates

Developer Tools

πŸ“ Project Structure

Turbo-Doc/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                    # Express.js backend API
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/   # Route controllers
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/    # Auth, limits, storage checks
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/        # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ services/      # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ workers/       # Piscina worker threads
β”‚   β”‚   β”‚   └── utils/         # Helper functions
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── web/                   # Next.js frontend
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ app/           # App router pages
β”‚       β”‚   β”œβ”€β”€ components/    # React components
β”‚       β”‚   β”œβ”€β”€ views/         # Page views
β”‚       β”‚   β”œβ”€β”€ api/           # API clients
β”‚       β”‚   β”œβ”€β”€ lib/           # Utilities
β”‚       β”‚   └── providers/     # Context providers
β”‚       └── package.json
β”‚
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ auth/                  # Better Auth configuration
β”‚   β”œβ”€β”€ database/              # Prisma schema & client
β”‚   β”‚   └── prisma/
β”‚   β”‚       β”œβ”€β”€ schema.prisma # Database model
β”‚   β”‚       └── seed.ts       # Seed script
β”‚   β”œβ”€β”€ file-upload/           # AWS S3 utilities
β”‚   β”œβ”€β”€ ui/                    # Shared UI components (shadcn/ui)
β”‚   β”œβ”€β”€ zod-schemas/           # Shared validation schemas
β”‚   └── config/                # Shared configuration
β”‚       β”œβ”€β”€ eslint-config/
β”‚       β”œβ”€β”€ tailwind-config/
β”‚       └── typescript-config/
β”‚
β”œβ”€β”€ package.json               # Root workspace config
β”œβ”€β”€ pnpm-workspace.yaml        # pnpm workspace definition
β”œβ”€β”€ turbo.json                 # Turborepo pipeline config
└── README.md

🏁 Getting Started

Prerequisites

  • Node.js >= 18
  • pnpm >= 9.0.0
  • PostgreSQL database
  • AWS S3 bucket and credentials
  • Razorpay account (for payments)
  • LibreOffice installed (for document conversion)

Installation

  1. Clone the repository

    git clone https://github.com/sharad-77/Turbo-Doc.git
    cd Turbo-Doc
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    Create a .env file in the root directory:

    # Database
    DATABASE_URL="postgresql://user:password@localhost:5432/turbodoc"
    
    # API Configuration
    API_PORT=3001
    API_URL="http://localhost:3001"
    NEXT_PUBLIC_API_URL="http://localhost:3001"
    NEXT_PUBLIC_APP_URL="http://localhost:3000"
    
    # Better Auth
    BETTER_AUTH_SECRET="your-secret-key-here"
    BETTER_AUTH_URL="http://localhost:3001"
    
    # OAuth (Optional)
    GOOGLE_CLIENT_ID="your-google-client-id"
    GOOGLE_CLIENT_SECRET="your-google-client-secret"
    GITHUB_CLIENT_ID="your-github-client-id"
    GITHUB_CLIENT_SECRET="your-github-client-secret"
    
    # AWS S3
    AWS_ACCESS_KEY_ID="your-aws-access-key"
    AWS_SECRET_ACCESS_KEY="your-aws-secret-key"
    AWS_S3_REGION="your-aws-region"
    AWS_BUCKET_NAME="your-bucket-name"
    AWS_CLOUDFRONT_URL="https://your-cloudfront-url"
    
    # Razorpay
    TEST_API_KEY="your-razorpay-key"
    TEST_API_SECRET="your-razorpay-secret"
    TEST_API_WEBHOOK_SECRET="your-webhook-secret"
    NEXT_PUBLIC_RAZORPAY_KEY_ID="your-razorpay-key-id"
  4. Generate Prisma Client & Run Migrations

    cd packages/database
    pnpm db:generate
    pnpm db:push
    pnpm db:seed    # Seed subscription plans
    cd ../..
  5. Build packages

    pnpm build
  6. Start development servers

    pnpm dev

    This will start:

πŸ“œ Available Scripts

From the root directory:

# Development
pnpm dev              # Start all apps in dev mode
pnpm dev --filter=web # Start only frontend
pnpm dev --filter=api # Start only backend

# Building
pnpm build            # Build all apps
pnpm build --filter=web

# Code Quality
pnpm lint             # Run ESLint
pnpm format           # Format code with Prettier
pnpm format:check     # Check code formatting
pnpm types            # TypeScript type checking
pnpm check            # Run format + lint + types

# Database
cd packages/database
pnpm db:generate      # Generate Prisma Client
pnpm db:push          # Push schema to database
pnpm db:migrate       # Run migrations
pnpm db:studio        # Open Prisma Studio
pnpm db:seed          # Seed database

🚒 Deployment

Frontend (Vercel)

The frontend is deployed on Vercel:

  1. Connect your GitHub repository to Vercel
  2. Set the root directory to apps/web
  3. Configure environment variables:
    • NEXT_PUBLIC_API_URL
    • NEXT_PUBLIC_APP_URL
    • NEXT_PUBLIC_RAZORPAY_KEY_ID
  4. Deploy!

Backend (AWS EC2)

The backend is deployed on AWS EC2:

  1. Launch EC2 Instance (Ubuntu 22.04, t3.micro or larger)

  2. Install Dependencies

    sudo apt update
    sudo apt install -y nodejs npm postgresql-client libreoffice
    npm install -g pnpm pm2
  3. Clone & Build

    git clone https://github.com/sharad-77/Turbo-Doc.git
    cd Turbo-Doc
    pnpm install --frozen-lockfile
    pnpm build --filter=api
  4. Configure Environment

    • Copy .env file with production values
    • Ensure NODE_ENV=production
  5. Start with PM2

    pm2 start apps/api/dist/index.js --name turbodoc-api
    pm2 save
    pm2 startup
  6. Setup Nginx (Optional) Configure Nginx as a reverse proxy with SSL termination

Database (PostgreSQL)

Hosted on a managed PostgreSQL service (e.g., AWS RDS, Neon, Supabase):

  1. Create database instance
  2. Configure connection string in .env
  3. Run migrations: pnpm db:push
  4. Seed initial data: pnpm db:seed

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Sharad


Built with ❀️ using modern web technologies

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages