Full-Stack SaaS

Avidnote — Academic Research & AI Platform

Full-stack academic SaaS with AI-powered PDF annotation, RAG-based document chat, and university-integrated subscriptions.

Timeline: Long-term SaaS development and maintenance engagement

Key Results

80+

API Endpoints

RESTful endpoints covering documents, AI chat, projects, billing, admin, and more

151

Database Migrations

Schema evolution across the full product lifecycle

50+

Vue Components

Rich SPA with document viewer, editors, modals, navigation, and AI interfaces

4 modules

AI Features

Document chat (RAG), AI writing templates, text autocomplete, text improvement

The Problem

Academic researchers and students needed a unified platform to upload, annotate, and take notes on research PDFs — then use AI to chat with their documents, generate academic writing, and organize findings across multi-document projects.

  • Researchers juggled multiple disconnected tools (PDF readers, note apps, citation managers, AI chatbots) with no unified workflow.
  • Manual text extraction and cross-referencing across large document libraries was time-consuming and error-prone.
  • No AI-native academic writing assistant existed that could understand the context of uploaded research papers.
  • University institutions lacked a way to provision premium access to students via SSO/email domain verification.

The Solution

Built a Laravel 12 + Vue.js 3 SaaS platform with 80+ API endpoints, real-time AI document chat (RAG-based), a rich-text academic editor (Tiptap), and PDF viewing/annotation — all tied together by a project-based workspace model.

  1. 1Architected a RESTful API with 80+ endpoints across authentication, documents, notes, notebooks, bookshelves, projects, AI chat, subscriptions, and admin — all secured with Laravel Sanctum token authentication.
  2. 2Built the document processing pipeline — file upload → queued background jobs (ProcessDocument, ExtractDocumentText) → PDF text extraction via Poppler (pdftotext) → document embedding for RAG-based AI chat.
  3. 3Integrated OpenAI for AI features — document chat with context-aware retrieval (ChatService with RAG), AI writing assistant with templates, autocomplete, and text improvement — all with token usage tracking and cost logging.
  4. 4Implemented the Projects system — multi-document workspaces with project-scoped chat histories, notes, and an AI Writer module for generating academic content from research context.
  5. 5Built the subscription and billing system — Stripe integration via Laravel Cashier with multi-plan support (Free/Starter/Premium), coupon validation, and university domain-based auto-provisioning.
  6. 6Developed the PDF viewer experience — migrated from PSPDFKit server-hosted approach to a hybrid model supporting both legacy PSPDFKit and local storage with ComPDF/EmbedPDF viewers on the frontend.
  7. 7Set up SSO/OIDC authentication — Keycloak and generic OpenID Connect integration alongside standard email/password auth, enabling university single sign-on.
  8. 8Configured CI/CD and infrastructure — Bitbucket Pipelines for automated deployments (dev → staging → production), Deployer for zero-downtime releases, Docker Compose for local development.

Architecture Decisions

Key technical decisions made during the project and the reasoning behind them.

Hybrid PDF Storage (Local + PSPDFKit Legacy)

Reasoning

The platform originally used PSPDFKit Document Engine for all PDF storage and rendering. As the product matured, the cost and complexity for documents that only needed viewing — not server-side annotation — became unnecessary. Evaluated keeping PSPDFKit-only vs. migrating entirely to local storage vs. a hybrid approach.

Outcome

New uploads go to local disk storage with ComPDF/EmbedPDF frontend viewers, while legacy documents continue to work through PSPDFKit. Reduced infrastructure dependency and simplified the upload pipeline.

RAG-Based Document Chat via OpenAI

Reasoning

Users needed to chat with their PDFs — ask questions and get answers grounded in their uploaded research. Evaluated simple prompt-stuffing vs. embedding-based retrieval (RAG). RAG was necessary because academic papers often exceed token limits, and users needed accurate citations from specific sections.

Outcome

Documents are processed through a text extraction pipeline, embedded, and retrieved contextually via ChatService. Supports both single-document and multi-document (project-scoped) chat.

Event-Driven AI Usage Tracking

Reasoning

Needed to track every AI interaction (tokens consumed, costs, model used, success/failure) for billing accuracy and analytics. Evaluated inline logging vs. event-driven approach. Event-driven was chosen to keep controller/service logic clean and allow multiple listeners without coupling.

Outcome

AIActionCompleted event fires after every AI operation, triggering LogAIUsage and UpdateKahubiBalanceOnAIAction listeners. Full audit trail with prompt/completion token counts and per-request cost tracking.

University Domain-Based Subscription Provisioning

Reasoning

University partnerships required automatic premium access for students with verified institutional email domains. Evaluated manual approval vs. domain-based auto-provisioning. Auto-provisioning eliminated admin overhead and improved onboarding speed.

Outcome

DomainSubscription model maps email domains to subscription plans. Users registering with a matching university email are automatically upgraded — no manual intervention needed.

The Tech Stack

Laravel 12

PHP 8.2+ — 80+ API endpoints, Eloquent ORM with 20+ models, Sanctum auth, Horizon queue management, event-driven architecture

Vue.js 3

SPA with Vuex (8 store modules), Vue Router, Tiptap rich-text editor with AI slash commands, 50+ components

OpenAI API

GPT-5 family — RAG-based document chat, academic text generation, autocomplete, text improvement with token usage tracking

Stripe

Laravel Cashier with multi-plan subscriptions (Free/Starter/Premium), coupon validation, university domain auto-provisioning

MySQL

MariaDB 10.8 — 151 migrations, hierarchical data models (nested bookshelves/notebooks), soft deletes, full audit trails

Redis

Caching layer, session storage, and queue backend for Laravel Horizon processing document analysis and embedding jobs

Docker

Docker Compose for local development with MariaDB, PostgreSQL, Redis, Nginx, PHP-FPM, PSPDFKit containers

The Impact

A production academic SaaS platform with 80+ API endpoints, 151 database migrations, 50+ Vue components, and 4 AI-powered features serving researchers and university students.

Deep dives and comparisons related to the technologies used in this project.

Explore similar case studies with overlapping technologies and challenges.