A premium, full-stack AI productivity workspace with secure authentication, role-based access control, AI-powered YouTube video analysis, RAG-based document chat with deep research, and a sleek dark theme UI.
π Live Demo: https://role-based-three.vercel.app
- Secure Login/Signup β NextAuth.js v5 with credentials provider and bcrypt password hashing
- Role-Based Access Control β Admin and User roles with protected routes and middleware
- User Approval System β New users require admin approval before accessing the dashboard
- Paste any YouTube video URL and get AI-generated notes powered by Gemini AI via OpenRouter
- Multi-strategy transcript fetching β tries multiple methods to extract video transcripts:
youtube-transcriptlibrary- YouTube timedtext API (manual + auto-generated captions)
- Invidious API (multiple instances)
ytdl-corecaption tracks- Metadata fallback (when no transcript is available)
- Structured output format:
- π¬ Video Summary β concise overview of the video
- π Key Points β all major points covered
- π Detailed Notes β in-depth, structured notes
- π‘ Important Facts β stats, definitions, and takeaways
- π What to Learn Next β suggested topics and resources
- Markdown rendering β notes are beautifully formatted with proper headings, lists, and styling
- Multi-format document upload β PDF, DOCX, PPTX, TXT, MD, CSV, and Images (JPG, PNG, WebP)
- URL ingestion β Paste a website URL to scrape and ingest its content via Firecrawl
- Workspace system β Organize documents into workspaces for project-based knowledge management
- Per-document chat β Each document gets its own chat interface
- Vector search β Embeddings generated via Gemini (
gemini-embedding-001, 3072 dimensions) stored in PostgreSQL withpgvector - Document-first answers β AI answers strictly from uploaded documents by default (no hallucination)
- Deep Research mode β Toggle "Search Web (Firecrawl)" to synthesize document context + live web results
- AI answers β Relevant chunks retrieved and answered by Groq (
llama-3.3-70b-versatile) with citation support - Graceful image handling β Images analyzed by Gemini Vision with automatic fallback + retry when rate-limited
- Card grid layout β Browse all documents, see indexing status, and click "View & Chat"
- View user statistics (approved, pending, rejected)
- Approve or reject user registrations
- Manage all users from a central panel
- Modern dark theme with glassmorphism design
- Gradient accents and smooth animations
- Fully responsive layout
| Layer | Technology |
|---|---|
| Frontend | Next.js 16, React 19, TypeScript, Tailwind CSS 4 |
| Backend | Next.js API Routes (App Router) |
| Database | PostgreSQL (Neon) with Drizzle ORM + pgvector |
| Authentication | NextAuth.js v5 (Auth.js) |
| AI - Notes | Google Gemini 2.0 Flash via OpenRouter |
| AI - Embeddings | Google Gemini (gemini-embedding-001, 3072d) |
| AI - Chat LLM | Groq (llama-3.3-70b-versatile) |
| AI - Vision | Google Gemini (image analysis with retry) |
| Web Scraping | Firecrawl (URL ingestion + deep research) |
| Document Parsing | pdf-parse, mammoth (DOCX), pptx (PPTX) |
| Deployment | Vercel |
- Node.js 18+
- PostgreSQL database (or Neon account) with
pgvectorextension - OpenRouter API key (for AI notes)
- Gemini API key (for embeddings + image analysis)
- Groq API key (for RAG chat)
- Firecrawl API key (for URL ingestion + deep research)
-
Clone the repository:
git clone https://github.com/hepsi33/Role-based-Dashboard.git cd Role-based-Dashboard -
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env
Edit
.envwith your values:DATABASE_URL="your-postgresql-connection-string" AUTH_SECRET="your-secret-key" NEXTAUTH_URL="http://localhost:3000" OPENROUTER_API_KEY="your-openrouter-api-key" GEMINI_API_KEY="your-gemini-api-key" GROQ_API_KEY="your-groq-api-key" FIRECRAWL_API_KEY="your-firecrawl-api-key"
-
Push the database schema:
npm run db:push
-
Enable pgvector extension:
npx tsx scripts/enable-vector.ts
-
Seed the admin user:
npm run db:seed
Default admin:
test@test.com/Test123@123 -
Run the development server:
npm run dev
Open http://localhost:3002 in your browser.
Sign Up β Pending Approval β Admin Approves/Rejects
β
β
Approved β Dashboard + AI Notes + RAG Chat
β Rejected β Access Denied Page
- Sign Up β User creates an account (status: pending)
- Pending β User sees a pending approval page
- Admin Approval β Admin approves or rejects in the admin dashboard
- Access Granted β Approved users can access the dashboard and AI features
- Access Denied β Rejected users see the access denied page
The RAG chat has two modes controlled by a toggle in the chat interface:
| Mode | Toggle | Behavior |
|---|---|---|
| Document-Only (default) | β Unchecked | Answers strictly from uploaded documents. Says "not available" if info isn't found. |
| Deep Research | β Search Web | Synthesizes document context + live Firecrawl web results with source citations. |
src/
βββ app/
β βββ access-denied/ # Rejected users page
β βββ admin/ # Admin dashboard (stats + user management)
β βββ dashboard/
β β βββ ai-notes/ # AI Study Notes generator
β β βββ rag/ # RAG document grid
β β β βββ [documentId]/ # Per-document chat page
β β βββ page.tsx # Main dashboard
β βββ get-started/ # Getting started / onboarding
β βββ login/ # Login page
β βββ signup/ # Sign up page
β βββ pending/ # Pending approval page
β βββ api/
β βββ auth/ # Auth endpoints (login, signup)
β βββ admin/ # Admin API (stats, user management)
β βββ ai/generate/ # AI notes generation endpoint
β βββ chat/ # RAG chat API (document-first + deep research)
β βββ documents/ # Document CRUD + retry API
β βββ ingest/url/ # URL scraping & ingestion API
β βββ upload/ # File upload & processing API
β βββ workspaces/ # Workspace CRUD API
βββ components/
β βββ rag/ # ChatInterface, DocumentManager, WorkspaceSelector
βββ drizzle/ # Database schema & seed scripts
βββ lib/
βββ auth.ts # NextAuth configuration
βββ db.ts # Database connection (Neon + Drizzle)
βββ file-parsers.ts # Multi-format file parsers (PDF, DOCX, PPTX, images)
βββ firecrawl.ts # Firecrawl wrapper (scrape, search, deep research)
βββ processor.ts # Document processing pipeline (parse β chunk β embed)
βββ utils.ts # Shared utilities
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
β | PostgreSQL connection string (Neon recommended) |
AUTH_SECRET |
β | NextAuth secret key for session encryption |
NEXTAUTH_URL |
β | App URL (http://localhost:3002 for dev, Vercel URL for prod) |
OPENROUTER_API_KEY |
β | OpenRouter API key for AI YouTube notes |
GEMINI_API_KEY |
β | Gemini API key for embeddings + image analysis |
GROQ_API_KEY |
β | Groq API key for RAG chat LLM |
FIRECRAWL_API_KEY |
β | Firecrawl API key for URL ingestion + deep research |
| Script | Command | Description |
|---|---|---|
| Enable pgvector | npx tsx scripts/enable-vector.ts |
Enables the vector extension in PostgreSQL |
| Verify DB connection | npx tsx scripts/verify-db.ts |
Tests database connectivity |
| Check DNS | npx tsx scripts/check-dns.ts |
Diagnoses DNS resolution issues |
MIT