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! π