How suvepatra004/format-doc-now works
Project type and purpose
• PDFox is a full-stack, single-page web application (SPA) for AI-enhanced content formatting, built with React (TypeScript) on the frontend and Supabase (Auth + PostgreSQL + Edge Functions) on the backend.
• It provides real-time preview, local formatting, optional Gemini AI integration, user authentication, and multiple export formats (PDF, TXT).
File structure
• Top-level “src” folder contains the React app: pages, components, hooks, integrations, lib, UI.
• “src/integrations/supabase” and “supabase/functions” hold backend integration and serverless functions.
• Supabase-related files: config.toml, migrations, functions for AI formatting and email.
• Build/config files: vite.config.ts, tailwind.config.ts, tsconfigs.
Key insights from the README
• Frontend uses React 18 + Vite + Tailwind + shadcn/ui + Framer Motion + React Router.
• Backend is Supabase (Auth, PostgreSQL with RLS) with Edge Functions:
• format-with-ai: calls Google Gemini AI for formatting
• send-contact-email
• Local formatting engine (regex & custom logic) runs in the browser.
• Client-side PDF/TXT generation using html2pdf.js and FileSaver.js.
Main components & interactions
a. Components
• Client Browser (SPA):
– UI Layer: React pages & shadcn/ui components
– Formatting Engine: Local regex + structural analysis + output generation modules
– Export Modules: html2pdf.js, FileSaver.js
– State & Hooks: useAuth, use-toast, use-mobile
– Local Storage for privacy
• Backend (Supabase):
– Auth Service (Email verification, JWT)
– PostgreSQL Database (user profiles, pricing, usage logs, documents)
– Edge Functions: format-with-ai, send-contact-email
• External Service:
– Google Gemini AI API
• Deployment & Hosting:
– Vite Dev/Prod server (static assets)
– Supabase hosting for db and functions
b. Relationships & data flows
1. User interacts with React UI → updates local store & preview via local formatting engine
2. For advanced AI formatting: UI → Supabase Edge Function (format-with-ai) → Google Gemini AI → returns formatted HTML/Text → UI
3. Auth flows: UI ↔ Supabase Auth (sign-up/login, JWT)
4. Protected data requests: UI ↔ Supabase Database (via Supabase client)
5. Contact form: UI → Supabase Edge Function (send-contact-email) → SMTP service
6. Export: UI triggers html2pdf.js/FileSaver.js to download document
7. Static assets: Browser fetches index.html + JS bundle from Vite/hosting
c. Architectural patterns & principles
• SPA (React) with client-driven routing (React Router)
• BaaS + Serverless Functions for backend logic
• Multi-layered formatting engine (client-side + optional AI)
• Strict separation: Presentation (components) vs Business logic (hooks, formatting engine) vs Data (Supabase)
• Configuration as code: Vite, Tailwind, tsconfig
d. Key technologies per component
• Frontend: React 18, TypeScript, Vite, Tailwind CSS, shadcn/ui, Framer Motion, React Router
• Formatting: Custom regex engine, html2pdf.js, FileSaver.js
• Backend: Supabase Auth, Postgres, Edge Functions (TypeScript)
• External AI: Google Gemini API