An enterprise-grade, full-stack web application designed to instantly convert PDF documents into responsive, perfectly formatted EPUB files for e-readers. Built with modern web technologies, this system guarantees zero data loss, intelligent layout extraction, and high-performance concurrent processing.
The core of the application relies on an asynchronous Python microservice built to handle heavy, concurrent PDF parsing.
- FastAPI Core: Leverages
uvicornandFastAPIfor ultra-low latency, async route handling, and highly concurrent multipart file uploads (up to 20MB per request payload limits enforced). - Intelligent Page-by-Page Extraction (
PyMuPDF / fitz): Extracts raw structural text arrays from the document. The system processes PDF geometries (x/y coordinates) to mathematically separate body text from running headers and footers (ignoring the top and bottom 8% vertical margins to strip out repeated author names/page numbers). - Dynamic E-Book Generation (
EbookLib): Recompiles chronological string chunks directly into standard, reflowable EPUB3 architecture. The API enforces strict CSS rules (page-break-before: always;) to perfectly map 1 PDF Page to 1 EPUB Page without compromising the fluid, text-based reading experience. - Auto-Cleanup Background Tasks: Integrates FastAPI's
BackgroundTasksqueue to programmatically flush temporary processing directories (tmp) immediately after theFileResponseexecutes, strictly preventing memory leaks and storage overlap.
The frontend provides a seamless, App-like (PWA) experience without page reloading or server-side lag.
- Next.js & Turbopack: Bootstrapped via Next.js for SSR/CSR combinations, utilizing
Turbopackfor near-instant compilation and rendering. - Dynamic IP Binding: Developed with mobile-testing in mind. Includes intelligent window
.hostnamepolling viaXMLHttpRequestto automatically bypass "localhost" restrictions, dynamically targeting local network and cellular network endpoints without code recompilation. - State Management: Fully client-side state machine (React Hooks) tracking parallel file objects inside an interactive Dropzone. Supports 4 distinct lifecycle queues:
idle,converting,success, anderror. - UI/UX Design: Zero CSS frameworks required beyond standard
TailwindCSS v4. Implements advanced "Glassmorphism" design paradigms (backdrop-filters) combined with granular micro-animations viaLucide-React.
- Built to function identically to a native iOS/Android application.
- Configured with strict metadata limits and caching layers to be fully installable directly to a mobile device's home screen.
- Node.js (v18+)
- Python (v3.11+)
cd backend- Create virtual environment:
python -m venv venv - Activate virtual environment:
- Mac/Linux:
source venv/bin/activate - Windows:
venv\Scripts\activate
- Mac/Linux:
- Install dependencies:
pip install -r requirements.txt - Start the FastAPI server (Bind to all IPs for mobile testing):
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
cd frontend- Install active dependencies:
npm install - Start the Turbopack server:
npm run dev
This application utilizes a decoupled, serverless hosting strategy for maximum free-tier scaling and security.
- Frontend Hosting (Vercel): The Next.js client is CI/CD integrated with Vercel edge networks. Ensure the
NEXT_PUBLIC_API_URLenvironment variable is explicitly set to point to the backend provider. - Backend Hosting (Render.com / AWS): The FastAPI Python engine is deployed natively using Python 3.11 (configured via
.python-versionexplicitly). Requires minimal build triggers:pip install -r requirements.txtanduvicorn main:app --host 0.0.0.0 --port $PORT.