A modern, full-stack security awareness platform built with Next.js 15 (App Router), Clerk Authentication, Convex for real-time data management, and JWT token integration.
- ✅ Clerk Authentication - Complete sign-up/sign-in system
- ✅ JWT Token Integration - Access and verify JWT tokens server/client-side
- ✅ Protected Routes - Server-side authentication middleware
- ✅ Session Management - Secure user session handling
- ✅ Token Verification - Custom JWT verification utilities
- ✅ Role-Based Access Control (RBAC) - Complete permission system with Admin/Teacher/Student roles
- ✅ Next.js 15 with App Router architecture
- ✅ TypeScript for complete type safety
- ✅ Server Components for optimal performance
- ✅ API Routes for backend functionality
- ✅ Middleware for authentication routing
- ✅ Responsive Design - Mobile-first approach
- ✅ Tailwind CSS - Modern utility-first styling
- ✅ Radix UI Components - Accessible component library
- ✅ Interactive Dashboard - Real-time user interface
- ✅ Component Library - Reusable UI components
- ✅ Convex Integration - Real-time database setup
- ✅ Convex Auth Config - Authentication integration
- ✅ API Endpoints - RESTful API structure
- ✅ Data Validation - Type-safe data handling
- ✅ Dashboard - Comprehensive user dashboard
- ✅ JWT Token Demo - Interactive token exploration
- ✅ Authentication Status - Real-time auth state
- ✅ Error Handling - Graceful error management
- ✅ Loading States - Smooth user interactions
- ✅ Admin Dashboard - User management and role assignment
- ✅ RBAC Guards - Permission-based UI components
- Clone and install dependencies:
git clone <repository-url>
cd secureaware
npm install- Set up environment variables:
Create a
.env.localfile with your keys:
# Get these from https://dashboard.clerk.com
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
# Get these from https://dashboard.convex.dev
CONVEX_DEPLOYMENT=your_convex_deployment
NEXT_PUBLIC_CONVEX_URL=your_convex_url- Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
- Open your browser: Visit http://localhost:3000 to see the application.
- CLERK_SETUP.md - Complete Clerk authentication setup
- JWT_WITH_CLERK.md - JWT token integration with Clerk
- CUSTOM_JWT_AUTH.md - Custom JWT implementation guide
- Clerk Integration: Full authentication with social providers
- JWT Tokens: Server and client-side JWT token access
- Protected Routes: Middleware-based route protection
- Session Management: Secure session handling
- RBAC System: Complete role-based access control with Admin/Teacher/Student roles
- Three User Roles: Admin, Teacher, Student with hierarchical permissions
- Permission System: Granular permission controls (CREATE_QUIZ, MANAGE_USERS, etc.)
- Route Protection: Middleware-based role checking for protected routes
- API Security: Role-based API endpoint protection
- UI Guards: Permission-based component rendering
- Admin Dashboard: Complete user management interface
- Audit Trail: Role assignment tracking and logging
- User Management: Complete user lifecycle management
/api/user: User data and JWT token endpoint/api/auth/verify-token: JWT token verification service- Authentication Middleware: Route protection and token extraction
- Type-Safe APIs: Full TypeScript support
- JWTTokenDemo: Interactive JWT token explorer
- Dashboard: Enhanced user dashboard
- UI Components: Complete Radix UI component library
- Responsive Design: Mobile-first responsive components
- TypeScript: Full type safety throughout the project
- ESLint: Code quality and consistency
- Hot Reload: Fast development with Turbopack
- Error Handling: Comprehensive error management
# Development
npm run dev # Start dev server with Turbopack (port 3000/3001)
npm run build # Build for production with Turbopack
npm run start # Start production server
npm run lint # Run ESLint for code quality
# Type Checking & Debugging
npx tsc --noEmit # TypeScript type checking
npm run dev -- --port 3001 # Specify custom port
# Clean & Reset
rm -rf .next # Clear Next.js cache
rm -rf node_modules && npm install # Fresh install- Next.js 15.5.4 - App Router with Turbopack
- React 19.1.0 - Latest React with concurrent features
- TypeScript 5 - Full type safety
- @clerk/nextjs 6.32.2 - Authentication system
- @clerk/backend 2.15.0 - JWT verification utilities
- Tailwind CSS 4 - Utility-first styling
- Radix UI - Accessible component primitives
- Lucide React - Icon library
- Convex 1.27.3 - Real-time database
- React Hook Form - Form management
- Zod - Runtime type validation
- ESLint 9 - Code linting
- PostCSS - CSS processing
- Date-fns - Date utilities
secureaware/
├── 📁 app/ # Next.js App Router
│ ├── 📁 api/ # API Routes
│ │ ├── 📁 auth/
│ │ │ └── 📁 verify-token/ # JWT token verification API
│ │ │ └── route.ts # Token verification endpoint
│ │ └── 📁 user/ # User data API
│ │ └── route.ts # User info + JWT tokens endpoint
│ ├── 📁 dashboard/ # Protected Dashboard
│ │ └── page.tsx # Enhanced dashboard with JWT demo
│ ├── 📁 sign-in/ # Authentication Pages
│ │ └── 📁 [[...sign-in]]/
│ │ └── page.tsx # Clerk sign-in page
│ ├── 📁 sign-up/
│ │ └── 📁 [[...sign-up]]/
│ │ └── page.tsx # Clerk sign-up page
│ ├── layout.tsx # Root layout with ClerkProvider
│ ├── page.tsx # Enhanced home page
│ └── globals.css # Global styles
├── 📁 components/ # React Components
│ ├── JWTTokenDemo.tsx # Interactive JWT token component
│ └── 📁 ui/ # Radix UI components
│ ├── alert.tsx
│ ├── badge.tsx
│ ├── button.tsx
│ ├── card.tsx
│ ├── checkbox.tsx
│ ├── dialog.tsx
│ ├── form.tsx
│ ├── input.tsx
│ ├── label.tsx
│ ├── progress.tsx
│ ├── radio-group.tsx
│ ├── select.tsx
│ ├── separator.tsx
│ ├── sheet.tsx
│ ├── sidebar.tsx
│ ├── skeleton.tsx
│ ├── table.tsx
│ ├── tabs.tsx
│ ├── textarea.tsx
│ └── tooltip.tsx
├── 📁 convex/ # Convex Backend
│ ├── auth.config.ts # Convex + Clerk integration
│ ├── mutations.ts # Database mutations
│ ├── queries.ts # Database queries
│ ├── schema.ts # Database schema
│ └── 📁 _generated/ # Auto-generated Convex files
├── 📁 hooks/ # React Hooks
│ └── use-mobile.ts # Mobile detection hook
├── 📁 lib/ # Utilities & Helpers
│ ├── jwt-verify.ts # JWT verification utilities
│ └── utils.ts # General utilities
├── 📁 public/ # Static Assets
│ ├── file.svg
│ ├── globe.svg
│ ├── next.svg
│ ├── vercel.svg
│ └── window.svg
├── middleware.ts # Clerk authentication middleware
├── .env.local # Environment variables (configured)
├── .gitignore # Git ignore rules
├── components.json # shadcn/ui configuration
├── eslint.config.mjs # ESLint configuration
├── next-env.d.ts # Next.js TypeScript definitions
├── next.config.ts # Next.js configuration
├── package.json # Dependencies and scripts
├── postcss.config.mjs # PostCSS configuration
├── tsconfig.json # TypeScript configuration
├── 📚 CLERK_SETUP.md # Comprehensive Clerk guide
├── 📚 JWT_WITH_CLERK.md # JWT integration guide
├── 📚 CUSTOM_JWT_AUTH.md # Custom JWT implementation
└── 📚 README.md # This file
- ✅ Complete Setup: Fully configured Clerk integration
- ✅ Social Auth: Support for multiple OAuth providers
- ✅ Email Auth: Username/password authentication
- ✅ User Profiles: Complete user management system
- ✅ Session Management: Secure session handling
- ✅ Server-Side Access:
auth().getToken()implementation - ✅ Client-Side Access:
useAuth().getToken()hooks - ✅ Token Verification: Custom verification utilities
- ✅ API Authentication: Bearer token support
- ✅ Token Debugging: Interactive token explorer
- ✅ Route Protection: Middleware-based authentication
- ✅ Server-Side Validation: Protected API endpoints
- ✅ Token Extraction: Headers and cookies support
- ✅ Error Handling: Graceful authentication failures
// User Data + JWT Tokens
GET /api/user // Get user info and JWT tokens
POST /api/user // Authenticated API example
// Token Verification
POST /api/auth/verify-token // Verify JWT token payload
GET /api/auth/verify-token // Extract & verify from headers// Server-side utilities (lib/jwt-verify.ts)
verifyClerkJWT(token) // Verify JWT token
extractToken(request) // Extract from headers/cookies
decodeJWT(token) // Decode without verification
// Component usage
<JWTTokenDemo /> // Interactive JWT explorerConvex provides:
- Real-time data synchronization
- TypeScript-first database operations
- Built-in authentication integration
- Serverless function deployment
Built with:
- Tailwind CSS for styling
- Radix UI for accessible components
- Lucide React for icons
- Custom components in
/componentsdirectory
The application is fully responsive and works on:
- 📱 Mobile devices (320px+)
- 📱 Tablets (768px+)
- 💻 Desktop (1024px+)
- 🖥️ Large screens (1440px+)
# ✅ Configured in .env.local
CONVEX_DEPLOYMENT=dev:wry-goldfinch-589
NEXT_PUBLIC_CONVEX_URL=https://wry-goldfinch-589.convex.cloud
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_[configured]
CLERK_SECRET_KEY=sk_test_[configured]
NEXT_PUBLIC_CLERK_SIGN_IN_URL="/sign-in"
NEXT_PUBLIC_CLERK_SIGN_UP_URL="/sign-up"
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL="/dashboard"
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL="/dashboard"- ✅ Ready to Deploy - Project is production-ready
- Connect GitHub repository to Vercel
- Add production environment variables
- Deploy with automatic CI/CD
- Netlify:
npm run build→.nextdirectory - Railway: GitHub integration + env vars
- Heroku: Next.js buildpack supported
- Cloudflare Pages: Full-stack deployment
For production deployment, update these variables:
# Production Clerk Keys
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_your_production_key
CLERK_SECRET_KEY=sk_live_your_production_key
# Production Convex
NEXT_PUBLIC_CONVEX_URL=https://your-production.convex.cloud
CONVEX_DEPLOYMENT=production:your-deployment
# Production URLs (update domains)
NEXT_PUBLIC_CLERK_SIGN_IN_URL="/sign-in"
NEXT_PUBLIC_CLERK_SIGN_UP_URL="/sign-up"
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL="/dashboard"
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL="/dashboard"- ✅ Development Build: Working (
npm run dev) - ✅ Production Build: Tested (
npm run build) - ✅ TypeScript: No errors
- ✅ ESLint: All checks passing
- ✅ Authentication: Fully functional
Build fails with Clerk error:
- Verify your API keys are correct
- Check that keys are set in environment variables
Authentication not working:
- Ensure middleware.ts is in the root directory
- Verify Clerk dashboard domain settings
Development server issues:
- Try
npm run dev -- --port 3001if port 3000 is busy - Clear
.nextfolder and restart:rm -rf .next && npm run dev
For more troubleshooting, see CLERK_SETUP.md.
| Feature | Status | Details |
|---|---|---|
| 🔐 Authentication | ✅ Complete | Clerk integration with JWT tokens |
| 🛡️ Authorization | ✅ Complete | Protected routes and middleware |
| 🏗️ API Routes | ✅ Complete | User data and token verification |
| 🎨 UI Components | ✅ Complete | Radix UI + Tailwind CSS |
| 📱 Dashboard | ✅ Complete | Interactive user dashboard |
| 🔑 JWT Integration | ✅ Complete | Token access and verification |
| 📚 Documentation | ✅ Complete | Comprehensive guides |
| 🚀 Build System | ✅ Complete | Production-ready builds |
| 📦 Dependencies | ✅ Updated | Latest stable versions |
| 🎯 TypeScript | ✅ Complete | Full type safety |
✅ Development Server: Working (localhost:3001)
✅ Production Build: Successful
✅ Authentication: Functional
✅ JWT Tokens: Implemented & Tested
✅ API Endpoints: Working
✅ UI Components: Responsive
✅ Error Handling: Graceful
✅ TypeScript: No errors
✅ ESLint: PassingReady for security training functionality implementation:
-
Training Module Creation System
- Training builder interface
- Content management
- Multiple learning formats support
-
Training Experience
- Progress tracking
- Completion scoring
- Interactive content delivery
-
Results & Analytics
- Score calculation
- Performance analytics
- Leaderboards
-
Advanced Features
- Categories and tags
- Difficulty levels
- Group training sessions
- Next.js 15 Documentation - App Router features
- Clerk Authentication - Auth best practices
- Convex Real-time Database - Backend functions
- Tailwind CSS - Styling system
- TypeScript Handbook - Type safety
# Start development
npm run dev
# Test authentication
# 1. Visit http://localhost:3001
# 2. Sign up/Sign in
# 3. Access /dashboard
# 4. Explore JWT token functionality
# Build for production
npm run build
# Deploy to production
# 1. Push to GitHub
# 2. Connect to Vercel
# 3. Set environment variables
# 4. Deploy automatically- Issue Tracking: GitHub Issues
- Documentation: Comprehensive guides included
- Code Quality: ESLint + TypeScript
- Security: Clerk enterprise-grade auth
- Performance: Next.js 15 optimizations
Built with modern technologies:
- ⚡ Next.js 15 + React 19
- 🔐 Clerk Authentication + JWT
- 🗄️ Convex Real-time Database
- 🎨 Tailwind CSS + Radix UI
- 📝 TypeScript + ESLint
Ready for security awareness training feature development and deployment! 🚀