Skip to content
codeitwithaayushPublic

About

Lecture intelligence platform: record, upload or paste a link and get AI study kits. Next.js, FastAPI, Supabase, Stripe, Claude.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧬 Synapse

Next.js FastAPI Supabase Stripe Claude License


πŸ“– Overview

Synapse is an AI-powered lecture intelligence platform that works as a second brain for students, teachers and researchers. Feed it a lecture in almost any form (live voice recording, a YouTube link, a PDF, slides, handwritten notes or audio) and it returns a complete study kit: structured notes, flashcards, timed quizzes, auto-generated concept diagrams and multi-agent deep research.

Under the hood it ships with Supabase authentication, shared team workspaces and a complete Stripe subscription billing layer, so it behaves like a real SaaS product rather than a demo.


✨ Key Features

Everything below is implemented and working today.

πŸ“₯ Multi-Channel Lecture Ingestion

  • πŸŽ™οΈ Live recording: capture the microphone and transcribe in the browser with the Web Speech API.
  • πŸ“Ί YouTube import: paste a public video link and the backend pulls the transcript and sends it through the AI pipeline.
  • πŸ“„ File uploads: PDFs, PowerPoint decks, images of handwritten notes, audio files, plus plain transcripts and text summaries.

🧠 Claude-Powered Intelligence

  • πŸ“ Study notes: summaries, key takeaways, exam-prep questions and reminders generated from each lecture.
  • πŸ“Š Concept maps: Mermaid.js diagrams are produced automatically to show how ideas or events connect.
  • πŸ’¬ Chat with your lectures: ask questions, request deeper explanations or clarify topics against the context of your own notes.
  • πŸ”¬ Deep research over SSE: a multi-agent run that analyses your notes and streams live progress to the browser via Server-Sent Events.

πŸ—‚οΈ Study Tools & Collaboration

  • πŸ“‡ Flashcards: decks generated automatically and grouped by topic and difficulty.
  • ❓ Quizzes: multiple-choice practice exams with a timer, created on demand.
  • πŸ‘₯ Team workspaces: shared folders for study groups and projects, governed by role-based access control (RBAC) with four roles: Owner, Admin, Editor and Viewer.

πŸ’³ Billing & Usage Control

  • πŸ” Authentication: sessions handled end to end by Supabase SSR auth.
  • πŸ’³ Subscription plans: four tiers (Explorer, Pro, Premium, Team) kept in sync with Stripe billing intervals.
  • ⚑ Daily quotas: per-plan limits on AI queries, YouTube imports, flashcard generations and quiz generations keep API costs under control.

πŸ”’ Security & Data Isolation

  • πŸ›‘οΈ Row-Level Security (RLS): Postgres policies make sure users can only read, write or delete their own notes and flashcards.
  • πŸ”‘ JWT verification: every backend request carries a Supabase access token, which FastAPI dependencies verify with SUPABASE_JWT_SECRET before any router runs.
  • πŸ“¦ Secrets stay server-side: Anthropic/Groq keys, Stripe keys and the Supabase service-role key never reach the browser bundle.

πŸ› οΈ Architecture & Tech Stack

graph TD
    Client[Next.js 16 + React 19 Frontend]
    STT[Web Speech API STT] --> Client
    Client -->|API Requests + Auth JWT| Gateway[FastAPI Backend Gateway]
    Gateway -->|User Auth Verification| SupabaseAuth[Supabase Auth / SSR]
    Gateway -->|Data & Notes CRUD| SupabaseDB[(Supabase PostgreSQL)]
    Gateway -->|Contextual Prompting| Claude[Claude Sonnet 4 API]
    Gateway -->|Billing & Subscriptions| Stripe[Stripe API & Webhooks]
    Gateway -->|Usage Tracking| Cache[(In-Memory / Postgres Usage Tracker)]
Loading

Stack at a Glance

Layer Technologies
Frontend React 19 Β· Next.js 16 (App Router) Β· TypeScript Β· Tailwind CSS v4 Β· Framer Motion Β· shadcn/ui
Backend FastAPI Β· Pydantic Β· Python 3.10+ Β· Uvicorn
Database Supabase PostgreSQL
Authentication Supabase SSR session provider
AI Processing Claude Sonnet 4 via the Anthropic API (Groq available as an alternative provider)
Payments Stripe (Checkout, Webhooks, Billing Portal)
Diagrams Mermaid.js (client-side rendering)

πŸ“‚ Repository Structure

synapse/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ (auth)/             # Login and sign-up screens
β”‚   β”‚   β”œβ”€β”€ ask/                # AI chat Q&A and deep research
β”‚   β”‚   β”œβ”€β”€ flashcards/         # Flashcard review
β”‚   β”‚   β”œβ”€β”€ notes/              # Notes library, detail view and editor
β”‚   β”‚   β”œβ”€β”€ pricing/            # Plan cards and Stripe checkout
β”‚   β”‚   β”œβ”€β”€ quiz/               # Multiple-choice quizzes
β”‚   β”‚   β”œβ”€β”€ record/             # Live recording and transcript view
β”‚   β”‚   β”œβ”€β”€ search/             # Global full-text search
β”‚   β”‚   β”œβ”€β”€ settings/           # Billing and account settings
β”‚   β”‚   β”œβ”€β”€ youtube/            # YouTube transcript import
β”‚   β”‚   β”œβ”€β”€ globals.css         # Tailwind v4 setup and design tokens
β”‚   β”‚   └── layout.tsx          # Root layout with the sidebar dock
β”‚   β”œβ”€β”€ components/             # Custom components and shadcn/ui primitives
β”‚   β”œβ”€β”€ lib/                    # Supabase SSR clients, API helpers, TS utilities
β”‚   └── package.json
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py             # App creation and CORS setup
β”‚   β”‚   β”œβ”€β”€ config.py           # Settings loaded with Pydantic BaseSettings
β”‚   β”‚   β”œβ”€β”€ dependencies.py     # Shared FastAPI dependencies (auth, DB, settings)
β”‚   β”‚   β”œβ”€β”€ middleware/         # Auth and subscription/limit checks
β”‚   β”‚   β”œβ”€β”€ migrations/         # PostgreSQL schema SQL scripts
β”‚   β”‚   β”œβ”€β”€ models/             # Database client and Pydantic schemas
β”‚   β”‚   β”œβ”€β”€ routers/            # API routes (notes, youtube, ask, billing, workspaces, ...)
β”‚   β”‚   └── services/           # Business logic (ai_service, stripe_service, usage_service)
β”‚   β”œβ”€β”€ requirements.txt        # Python dependencies
β”‚   └── .env.example            # Environment variable template
β”œβ”€β”€ docs/                       # PRD, architecture, rules and roadmap
└── README.md                   # You are here

βš™οΈ Local Development Setup

1. Prerequisites

You will need:

  • Node.js v18 or newer
  • Python 3.10 or newer
  • A Supabase account with a project
  • An Anthropic API key (or a Groq key if you prefer that provider)
  • A Stripe developer account

2. Initialise the Database

Run the SQL scripts in backend/app/migrations from the Supabase SQL editor or the Supabase CLI, in this order:

  1. 001_subscription_tables.sql creates the subscription, daily-usage and payment tables and seeds the Explorer, Pro, Premium and Team plans.
  2. 002_team_workspaces.sql adds workspaces and memberships, and links notes to workspaces.

3. Run the Backend

  1. Move into the backend folder:

    cd backend
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # Windows: venv\Scripts\activate
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Create your environment file:

    cp .env.example .env

    Then fill in .env:

    • ANTHROPIC_API_KEY: your Anthropic key.
    • SUPABASE_URL, SUPABASE_SERVICE_KEY, SUPABASE_JWT_SECRET: from your Supabase project settings.
    • STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_*: your Stripe secrets and price IDs.
  5. Start the API server:

    uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

4. Run the Frontend

  1. Move into the frontend folder:
    cd frontend
  2. Install the packages:
    npm install
  3. Create a .env.local file in frontend/ with your Supabase and API settings:
    NEXT_PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
    NEXT_PUBLIC_API_URL=http://localhost:8000
  4. Start the dev server:
    npm run dev
  5. Open http://localhost:3000 in your browser.

πŸ“Š Database Schema

Synapse stores its data in a relational PostgreSQL database hosted on Supabase. The main tables relate like this:

                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚  auth.users   β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                β–Ό                β–Ό               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚user_subscriptionsβ”‚ β”‚workspaces β”‚ β”‚  usage_daily   β”‚ β”‚   notes   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
         β”‚                β”‚                                β”‚
         β–Ό                β–Ό                                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ payment_history β”‚ β”‚wksp_membersβ”‚                    β”‚flashcards β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • notes: summaries, topics and tags, raw transcripts, key points, study schedules and Mermaid diagrams, each scoped to a workspace_id.
  • flashcards: AI-generated cards with question, answer, display order and difficulty.
  • workspaces and workspace_members: teams, shared folders and each member's RBAC role.
  • subscription_plans and user_subscriptions: available tiers, each user's current plan, Stripe sync data and billing dates.
  • usage_daily: a daily counter of operations (YouTube imports, AI queries and so on) used to enforce plan limits.


🀝 Contributing

Contributions are welcome. Before opening a pull request, read docs/rules.md for the architecture guidelines, naming conventions and PR rules.



πŸ‘¨β€πŸ’» Author

Aayush β€” GitHub

About

Lecture intelligence platform: record, upload or paste a link and get AI study kits. Next.js, FastAPI, Supabase, Stripe, Claude.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages