Skip to content

abdelazizBi/briefd

Repository files navigation

Briefd

AI document intelligence workspace for turning PDFs into structured summaries, risk flags, key clauses, financial highlights, and comparison insights.

View the live application

Briefd application preview

Overview

Briefd helps users understand long documents without reading every page first.

Upload a contract, pitch deck, financial report, or other text-based PDF to generate a structured brief containing:

  • An executive summary
  • Key clauses
  • Risk flags and an overall risk score
  • Financial highlights
  • Recommended actions
  • Estimated reading time

Analyses can be saved, searched, compared, grouped into collections, exported, shared through public links, and explored through document Q&A.

The product supports a guest-first workflow, so users can start without creating an account and sign in later to sync their saved workspace.

Product highlights

  • Structured document analysis — turn PDFs into clear summaries, clauses, risks, financial highlights, and recommended actions
  • Risk intelligence — surface critical, moderate, and low-risk findings with an overall score
  • Document comparison — compare two saved briefs across risks, clauses, and financial information
  • Ask this document — explore a completed analysis through natural-language questions
  • Dashboard — search, filter, sort, reopen, rename, and manage saved analyses
  • Collections — organize related documents by deal, client, project, or research topic
  • Guest mode — analyze and save work without creating an account
  • Account sync — sign in to access saved analyses and collections across devices
  • Export and sharing — export briefs and create token-based public share links
  • Preferences and privacy controls — manage appearance, AI model preference, saved data, and account settings

How it works

  1. Upload a PDF
    Briefd extracts text from the document on the server.

  2. Generate a structured brief
    The extracted text is sent to an LLM through OpenRouter and returned as structured analysis data.

  3. Review and organize
    Save the result, compare it with another document, add it to a collection, export it, or share it.

Main application routes

Route Purpose
/ Product landing page
/app Upload and analyze a PDF
/analysis/[id] Review a saved analysis
/dashboard Browse and manage saved analyses
/collections Organize analyses into collections
/compare Compare two saved documents
/settings Manage account, sync, data, and preferences
/guide Product documentation and usage guide
/share/[token] Read-only public analysis view

Tech stack

Application

  • Next.js 16 with the App Router
  • React 19
  • TypeScript
  • Tailwind CSS 4
  • Framer Motion
  • Lucide React
  • next-themes

Data and authentication

  • Supabase
  • PostgreSQL
  • Supabase Authentication
  • Row Level Security
  • Guest and authenticated ownership scopes

AI and document processing

  • OpenRouter
  • Streaming LLM responses
  • Multi-model fallback handling
  • pdf-parse
  • Structured JSON analysis
  • jsPDF

Architecture

Briefd uses the Next.js App Router for pages, layouts, and server-side API routes.

Document analysis flow

  1. The client validates and uploads a PDF to POST /api/analyze.
  2. The server extracts text using pdf-parse.
  3. Extracted text is sent to OpenRouter with a strict structured-output prompt.
  4. The route streams generated JSON back to the client.
  5. The completed result can be saved to Supabase.

The analyzer attempts the user's preferred model first when configured, then falls back through the application's available model list when a provider is rate-limited or unavailable.

Data ownership

Briefd supports two ownership modes:

  • Guest users are scoped through a device identifier.
  • Authenticated users are scoped through their Supabase user ID.

Saved analyses and collections remain isolated by ownership scope. Authenticated database records also use Row Level Security policies.

Authentication

The browser uses the Supabase anonymous key for authentication. The application stores the authenticated session in secure HTTP-only cookies for server-side access.

Public sharing

Saved analyses can receive a unique share token. Public share routes return only the fields needed to display the read-only shared brief.

Database

The included Supabase schema creates:

  • analyses
  • collections
  • collection_analyses
  • profiles

The schema also includes indexes, update triggers, ownership fields, and Row Level Security policies.

The original uploaded PDF is not stored by the included database schema. Briefd stores document metadata, structured analysis results, sharing data, and chat history.

Local setup

Prerequisites

  • Node.js 20.9 or newer
  • npm
  • A Supabase project
  • An OpenRouter API key

1. Clone the repository

git clone https://github.com/abdelazizBi/briefd.git
cd briefd

2. Install dependencies

npm install

3. Configure environment variables

Copy the example environment file:

cp .env.example .env.local

Add your values to .env.local:

# OpenRouter — server only
OPENROUTER_API_KEY=

# Supabase
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=

# Supabase service role — server only
SUPABASE_SERVICE_ROLE_KEY=

Environment-variable reference

Variable Scope Purpose
OPENROUTER_API_KEY Server only Sends extracted document text to the configured AI models
NEXT_PUBLIC_SUPABASE_URL Browser and server Identifies the Supabase project
NEXT_PUBLIC_SUPABASE_ANON_KEY Browser and server Supports browser authentication and authorized client access
SUPABASE_SERVICE_ROLE_KEY Server only Performs trusted server-side database operations

SUPABASE_SERVICE_ROLE_KEY bypasses Row Level Security. Never expose it to browser code, commit it to Git, or prefix it with NEXT_PUBLIC_.

4. Create the database schema

Open the Supabase SQL Editor and run:

supabase/schema.sql

This creates the required tables, indexes, triggers, and policies.

5. Configure authentication

Enable the authentication provider you want to use in the Supabase dashboard and add the correct local and production redirect URLs.

The application can still be used in guest mode without signing in.

6. Start the development server

npm run dev

Open:

http://localhost:3000

Available commands

Command Description
npm run dev Start the development server with Webpack
npm run build Create a production build
npm run start Start the production server
npm run lint Run ESLint
npm run typecheck Run TypeScript validation

Regenerating Supabase types

Link your Supabase project once:

npx supabase link --project-ref YOUR_PROJECT_REF

Then regenerate the types:

npm run db:types

Production checks

Before deploying changes:

npm run lint
npm run typecheck
npm run build

Deployment

Briefd is designed for deployment on Vercel with Supabase as the database and authentication provider.

Add these environment variables to the production project:

OPENROUTER_API_KEY=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=

Then:

  1. Run supabase/schema.sql against the production Supabase project.
  2. Configure the production authentication redirect URLs in Supabase.
  3. Add the environment variables in Vercel.
  4. Deploy the application.

Security and privacy notes

  • OpenRouter receives extracted document text so the configured AI model can analyze it.
  • The original PDF file is not stored by the included database schema.
  • The service-role key is used only in server-side code.
  • Authenticated records are protected by ownership checks and Row Level Security policies.
  • Guest records are scoped to a device identifier.
  • Public analysis pages require a unique share token.
  • AI-generated analysis should be reviewed before it is used for legal, financial, or business decisions.

Do not upload confidential or regulated documents unless you understand and accept the data-handling policies of your hosting, database, and AI providers.

Known limitations

  • Only PDF files are accepted.
  • Image-only, scanned, or encrypted PDFs may fail because OCR is not included.
  • The application validates files up to 10 MB, but serverless platform request limits may reduce the practical upload size.
  • Very long extracted documents are truncated before analysis.
  • AI providers can be rate-limited or temporarily unavailable.
  • Generated summaries, scores, and recommendations may be incomplete or inaccurate.
  • The risk score is a triage aid, not a legal, financial, or compliance assessment.
  • Public share links should be revoked when they are no longer needed.

Project structure

src/
├── app/
│   ├── analysis/[id]/      # Saved analysis workspace
│   ├── api/                # Server-side API routes
│   ├── app/                # Upload and analysis flow
│   ├── auth/callback/      # Authentication callback
│   ├── collections/        # Collection management
│   ├── compare/            # Document comparison
│   ├── dashboard/          # Saved analysis library
│   ├── guide/              # User guide
│   ├── settings/           # Account, data, and preferences
│   └── share/[token]/      # Public shared analysis
├── components/
│   ├── analysis/           # Upload, results, chat, and comparison UI
│   ├── collections/        # Collection interfaces
│   ├── dashboard/          # Dashboard cards and controls
│   ├── guide/              # Guide visuals and navigation
│   ├── landing/            # Marketing page sections
│   ├── layout/             # Shared application shell
│   └── ui/                 # Reusable interface components
├── lib/
│   ├── auth/               # Authentication and viewer scope
│   ├── analysis-store.ts   # Analysis persistence
│   ├── collections-store.ts
│   ├── ownership.ts        # Guest and user ownership filters
│   ├── profile-store.ts    # Account preferences
│   └── supabase.ts         # Server-side Supabase client
└── types/                  # Generated and shared TypeScript types

supabase/
└── schema.sql              # Database schema, indexes, and RLS policies

public/
└── briefd-preview.png      # README preview image

Author

Built by Abdelaziz Biad, Senior Full-Stack Engineer.

About

AI document intelligence workspace for summarizing, comparing and organizing PDFs using Next.js, TypeScript and LLM-powered analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors