Read between the lines. Intelligent contract analysis, risk detection, deadline extraction, and lifecycle management with native PDF clause highlighting and Google Workspace sync.
Subtext is a full-stack contract intelligence platform that helps agencies, project managers, and legal teams review and manage commercial agreements:
- Hierarchical Vault: Organize contracts cleanly by Client → Project → Document with complete version history.
- Native PDF Clause Highlights: High-resolution in-app PDF canvas viewer (powered by PDF.js) that maps extracted risks directly to exact clauses on physical document pages with glowing bounding boxes and smooth scroll navigation.
- Asymmetric Risk & Trap Detection: Detects unfavorable liability caps, indemnification traps, non-competes, and termination ambiguities powered by Google Gemini 3 Flash.
- 1-Click Google Calendar Sync: Automatically extracts critical deadlines and notice dates with one-click synchronization to Google Calendar.
- Interactive Vault Chat: Query any document conversationally with clause-referenced citations.
- Seamless Google Drive Integration: Import contracts directly via Google Drive Picker and view revisions seamlessly.
| Layer | Technology | Hosting / Provider |
|---|---|---|
| Frontend | Next.js 16 (App Router) · React 19 · PDF.js Canvas · NextAuth v5 | Vercel |
| Backend | FastAPI (Python 3.12) · Async SQLAlchemy · Pydantic v2 · HTTPX | Render |
| Database | PostgreSQL 16 (Serverless) · asyncpg · psycopg | Neon |
| AI / LLM | Google Gemini 3 Flash (gemini-3-flash-preview / gemini-2.5-flash) |
Google AI Studio |
| Integrations | Google Drive API (Picker & Media Export) · Google Calendar API | Google Cloud Platform |
| CI / CD | GitHub Actions (CI & Render Deploy Hook) | GitHub |
┌────────────────────────────────────────────────────────┐
│ Vercel (Frontend) │
│ Next.js 16 · NextAuth v5 · PDF.js Canvas Viewer │
│ https://subtext-dusky.vercel.app │
└───────────┬────────────────────────────────┬───────────┘
│ OAuth & Drive Tokens │ REST API
▼ ▼
┌───────────────────────┐ ┌────────────────────────┐
│ Google Cloud │ │ Render (Backend) │
│ • Google Drive API │ │ FastAPI · Async Engine │
│ • Google Calendar API │ │ Gemini Contract Engine │
│ • Google OAuth 2.0 │ └───────────┬────────────┘
└───────────────────────┘ │ asyncpg
▼
┌────────────────────────┐
│ Neon Database │
│ Serverless Postgres │
└────────────────────────┘
- Node.js 20+
- Python 3.11+
- PostgreSQL instance (local or Neon free tier)
- Google Cloud Console project with Drive, Calendar, and OAuth enabled
cd backend
# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows (PowerShell: .venv\Scripts\Activate.ps1)
# source .venv/bin/activate # macOS / Linux
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .envEnsure backend/.env contains:
DATABASE_URL=postgresql+asyncpg://<user>:<password>@<host>/<database>?ssl=require
SYNC_DATABASE_URL=postgresql+psycopg://<user>:<password>@<host>/<database>?ssl=require
AUTH_SECRET=your-32-character-random-secret
GEMINI_API_KEY=your-gemini-api-key
GOOGLE_CLIENT_ID=your-google-oauth-client-id
GOOGLE_CLIENT_SECRET=your-google-oauth-client-secret
CORS_ORIGINS=http://localhost:3000,https://subtext-dusky.vercel.appRun the backend server:
uvicorn app.main:app --reload --port 8000API Documentation will be live at http://localhost:8000/docs.
cd frontend
# Install dependencies
npm install
# Configure environment variables
cp .env.example .env.localEnsure frontend/.env.local contains:
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:8000
AUTH_SECRET=your-32-character-random-secret
AUTH_GOOGLE_ID=your-google-oauth-client-id
AUTH_GOOGLE_SECRET=your-google-oauth-client-secret
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-oauth-client-idRun the frontend dev server:
npm run devOpen http://localhost:3000 in your browser.
To enable Google Sign-In, Google Drive Picker, and Google Calendar Sync:
- Open the Google Cloud Console.
- Enable the following APIs under APIs & Services → Enabled APIs & Services:
- Google Drive API
- Google Calendar API
- Under OAuth 2.0 Client IDs, select your Web Client and configure:
http://localhost:3000
https://subtext-dusky.vercel.app
http://localhost:3000
http://localhost:3000/api/auth/callback/google
https://subtext-dusky.vercel.app
https://subtext-dusky.vercel.app/api/auth/callback/google
- Connect your GitHub repository to Vercel.
- Set Framework Preset to Next.js.
- Root directory:
frontend. - Add environment variables:
NEXT_PUBLIC_API_URL,AUTH_SECRET,AUTH_GOOGLE_ID,AUTH_GOOGLE_SECRET,NEXT_PUBLIC_GOOGLE_CLIENT_ID. - Every push to
mainautomatically deploys to production.
- Create a new Web Service on Render connected to the repository.
- Root directory:
backend. - Build Command:
pip install -r requirements.txt. - Start Command:
uvicorn app.main:app --host 0.0.0.0 --port $PORT. - Add backend environment variables (
DATABASE_URL,GEMINI_API_KEY, etc.).
To trigger Render deployment automatically via GitHub Actions:
- In Render, go to your Web Service Settings → Deploy Hook.
- Copy the Deploy Hook URL.
- In your GitHub repository, go to Settings → Secrets and variables → Actions and add:
- Name:
RENDER_DEPLOY_HOOK_URL - Value:
https://api.render.com/deploy/srv-xxxx?key=yyyy
- Name:
- Pushing to
maintriggers.github/workflows/deploy.ymlwhich triggers Render's deploy hook automatically.
Unlike plain-text readers or Google Drive preview iframes (which block DOM access via cross-origin policy), Subtext renders PDF contracts on an HTML5 <canvas> via PDF.js. When a risk or obligation is selected:
- Text bounding boxes are computed across font baselines, ascenders, and descenders.
- Glowing, color-coded highlight boxes pulse directly over the target clauses.
- The document smoothly auto-scrolls the active page and clause into view.
After Gemini finishes analyzing a contract, a prompt surfaces extracted deadlines with 1-click batch synchronization to Google Calendar. Google Identity Services tokens are cached in sessionStorage with email hints to eliminate annoying "Choose an account" permission loops.
MIT © Subtext