Skip to content

hepsi33/Role-based-Dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Role-Based Dashboard

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

Next.js TypeScript Tailwind CSS PostgreSQL


✨ Features

πŸ” Authentication & Authorization

  • 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

πŸ€– AI-Powered YouTube Notes

  • 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-transcript library
    • YouTube timedtext API (manual + auto-generated captions)
    • Invidious API (multiple instances)
    • ytdl-core caption 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

πŸ“„ RAG Knowledge Workspace

  • 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 with pgvector
  • 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"

πŸ“Š Admin Dashboard

  • View user statistics (approved, pending, rejected)
  • Approve or reject user registrations
  • Manage all users from a central panel

🎨 Premium UI

  • Modern dark theme with glassmorphism design
  • Gradient accents and smooth animations
  • Fully responsive layout

πŸ› οΈ Tech Stack

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

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/hepsi33/Role-based-Dashboard.git
    cd Role-based-Dashboard
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    cp .env.example .env

    Edit .env with 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"
  4. Push the database schema:

    npm run db:push
  5. Enable pgvector extension:

    npx tsx scripts/enable-vector.ts
  6. Seed the admin user:

    npm run db:seed

    Default admin: test@test.com / Test123@123

  7. Run the development server:

    npm run dev

    Open http://localhost:3002 in your browser.


πŸ‘€ User Flow

Sign Up β†’ Pending Approval β†’ Admin Approves/Rejects
                                    ↓
                        βœ… Approved β†’ Dashboard + AI Notes + RAG Chat
                        ❌ Rejected β†’ Access Denied Page
  1. Sign Up β†’ User creates an account (status: pending)
  2. Pending β†’ User sees a pending approval page
  3. Admin Approval β†’ Admin approves or rejects in the admin dashboard
  4. Access Granted β†’ Approved users can access the dashboard and AI features
  5. Access Denied β†’ Rejected users see the access denied page

πŸ’¬ Chat Modes

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.

πŸ“ Project Structure

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

βš™οΈ Environment Variables

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

🧰 Utility Scripts

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

πŸ“œ License

MIT

About

"A full stack dashboard with secure role-based access, AI-powered YouTube summaries, and RAG document chat.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors