Skip to content

dev-templates/qwik-dashboard-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

image image

Qwik Dashboard Template

A production-ready dashboard template built with Qwik and Tailwind CSS, designed for rapid project initialization with enterprise-grade features.

✨ Features

πŸ” Authentication & Security

  • User Authentication - Secure login/logout system with JWT
  • Two-Factor Authentication (2FA) - TOTP-based 2FA with QR code setup
  • Role-Based Access Control (RBAC) - Fine-grained permission system
  • Session Management - Automatic session tracking and timeout handling
  • Password Security - bcrypt hashing with salt rounds

πŸ‘₯ User Management

  • User CRUD Operations - Create, read, update, and delete users
  • Role Assignment - Assign multiple roles to users
  • User Status Management - Activate/deactivate user accounts
  • Profile Management - User profile editing and avatar support
  • Login Attempt Tracking - Security audit trail

🎨 UI/UX

  • Dark Mode - Full dark mode support with CSS custom properties
  • Responsive Design - Mobile-first, fully responsive layouts
  • Modern UI Components - Pre-built reusable components
  • Accessibility - ARIA-compliant components
  • Icons - @qwikest/icons integration

πŸ“Š Dashboard Features

  • System Overview - Real-time statistics and metrics
  • Chart Integration - Chart.js for data visualization
  • Reports - Customizable reporting system
  • Settings Management - System configuration interface

πŸ› οΈ Developer Experience

  • Auto Database Setup - Database automatically initializes on first run
  • Type Safety - Full TypeScript support
  • Hot Module Replacement - Fast development with Vite
  • Code Quality - Biome for linting and formatting
  • Demo Users - Pre-configured demo accounts for testing

πŸš€ Quick Start

Prerequisites

  • Node.js: v18.17.0 or higher
  • Bun: Latest version (or npm/yarn/pnpm)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd qwik-dashboard-template
  2. Install dependencies

    bun install
  3. Set up environment variables

    cp .env.example .env

    Edit .env and configure:

    DATABASE_URL="file:./dev.db"
    JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"
    TWO_FACTOR_ISSUER="Qwik Dashboard"
    SESSION_EXPIRES_IN="7d"
    NODE_ENV="development"
  4. Start development server

    bun run dev

    The database will automatically initialize on first run! πŸŽ‰

  5. Access the application

πŸ”‘ Demo Accounts

The system automatically creates these demo accounts:

Role Email Password Access Level
Admin admin@example.com password123 Full system access
Editor editor@example.com password123 Read dashboard/users
User user@example.com password123 Read dashboard only

⚠️ Security Note: Change these credentials in production!

πŸ“ Project Structure

qwik-dashboard-template/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma         # Database schema
β”‚   └── seed.ts               # Database seed data
β”œβ”€β”€ public/                   # Static assets
β”‚   β”œβ”€β”€ favicon.svg
β”‚   β”œβ”€β”€ logo.svg
β”‚   └── manifest.json
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/               # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Badge.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Box.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Input.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Modal.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ OTPInput.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PageHeader.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Select.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Table.tsx
β”‚   β”‚   β”‚   └── Textarea.tsx
β”‚   β”‚   β”œβ”€β”€ router-head/
β”‚   β”‚   └── theme-script.tsx  # Dark mode script
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth/             # Authentication routes
β”‚   β”‚   β”‚   β”œβ”€β”€ login/
β”‚   β”‚   β”‚   β”œβ”€β”€ setup-2fa/
β”‚   β”‚   β”‚   └── verify-2fa/
β”‚   β”‚   β”œβ”€β”€ dashboard/        # Dashboard routes
β”‚   β”‚   β”‚   β”œβ”€β”€ index.tsx     # Dashboard home
β”‚   β”‚   β”‚   β”œβ”€β”€ profile/      # User profile
β”‚   β”‚   β”‚   β”œβ”€β”€ roles/        # Role management
β”‚   β”‚   β”‚   β”œβ”€β”€ security/     # Security settings
β”‚   β”‚   β”‚   β”œβ”€β”€ settings/     # System settings
β”‚   β”‚   β”‚   β”œβ”€β”€ users/        # User management
β”‚   β”‚   β”‚   └── reports/      # Reports
β”‚   β”‚   β”œβ”€β”€ plugin@db.ts      # Database init plugin
β”‚   β”‚   β”œβ”€β”€ layout.tsx        # Root layout
β”‚   β”‚   └── index.tsx         # Homepage redirect
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ auth/             # Auth configuration
β”‚   β”‚   β”œβ”€β”€ middleware/       # Request middleware
β”‚   β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”œβ”€β”€ db.ts             # Prisma client
β”‚   β”‚   └── db-init.ts        # Auto database setup
β”‚   β”œβ”€β”€ utils/                # Utility functions
β”‚   β”œβ”€β”€ entry.dev.tsx
β”‚   β”œβ”€β”€ entry.preview.tsx
β”‚   β”œβ”€β”€ entry.ssr.tsx
β”‚   └── root.tsx
β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ biome.json                # Biome configuration
β”œβ”€β”€ playwright.config.ts      # Playwright configuration
β”œβ”€β”€ tsconfig.json             # TypeScript configuration
└── vite.config.ts            # Vite configuration

πŸ§ͺ Development

Available Scripts

# Development
bun run dev              # Start development server
bun run dev.debug        # Start with Node.js debugger

# Building
bun run build            # Production build
bun run build.client     # Client-only build
bun run build.preview    # Preview build
bun run build.types      # Type checking

# Code Quality
bun run fmt              # Format code with Biome
bun run lint             # Lint and type check

# Database
bun run db:studio        # Open Prisma Studio (browse database)

# Preview
bun run preview          # Preview production build

πŸ—„οΈ Database

Automatic Initialization

The database automatically initializes on first server start:

  1. Checks if database file exists
  2. Creates database if needed
  3. Syncs schema (dev: db push, prod: migrate deploy)
  4. Seeds default data (roles, permissions, demo users)

No manual setup required! πŸŽ‰

Database Management

The database is fully managed automatically. For advanced operations:

# Browse database with Prisma Studio
bun run db:studio

# Note: db:generate, db:migrate, db:push, and db:seed
# are automatically handled by the system on startup

Database Schema

The schema includes:

  • Users - User accounts with authentication
  • Roles - System and custom roles
  • Permissions - Resource-based permissions
  • UserRoles - User-role assignments
  • RolePermissions - Role-permission assignments
  • Sessions - Active user sessions
  • LoginAttempts - Security audit log
  • PendingAuth - 2FA pending authentication
  • Settings - System configuration

🎨 Styling

Tailwind CSS v4

This template uses the latest Tailwind CSS v4 with:

  • CSS-first configuration
  • Modern color system
  • Dark mode via CSS custom properties
  • Responsive design utilities

Dark Mode

Toggle dark mode with the theme switcher in the navigation bar. The theme persists across sessions.

Implementation:

// Theme is managed via classList
// Dark mode: document.documentElement.classList.add('dark')
// Light mode: document.documentElement.classList.remove('dark')

πŸ”’ Security

Authentication Flow

  1. User logs in with email/password
  2. Credentials validated against database
  3. JWT token generated and stored
  4. If 2FA enabled, redirect to verification
  5. Session tracked in database

2FA Setup

  1. Navigate to Security Settings
  2. Click "Enable 2FA"
  3. Scan QR code with authenticator app
  4. Enter verification code
  5. Save recovery codes securely

Permission System

Fine-grained RBAC with:

  • Resources: users, roles, settings, dashboard
  • Actions: read, manage
  • Assignment: Roles β†’ Permissions β†’ Users

Example:

// Check permission
import { hasPermission } from '~/server/services/auth.service';

const canManageUsers = hasPermission(user, 'users', 'manage');

πŸ“¦ Production Deployment

Build for Production

# Create production build
bun run build

# Preview production build locally
bun run preview

Environment Variables

Ensure these are set in production:

DATABASE_URL="<production-database-url>"
JWT_SECRET="<strong-random-secret>"
TWO_FACTOR_ISSUER="Your App Name"
SESSION_EXPIRES_IN="7d"
NODE_ENV="production"

Deployment Platforms

Add deployment adapters:

# Cloudflare
bun qwik add cloudflare-pages

# Netlify
bun qwik add netlify-edge

# Vercel
bun qwik add vercel-edge

# Node.js
bun qwik add express

🧩 Tech Stack

Category Technology
Framework Qwik 1.17+
Styling Tailwind CSS v4
Database Prisma + SQLite
Authentication JWT + bcryptjs
2FA speakeasy + qrcode
Validation Zod
Icons @qwikest/icons
Linting/Formatting Biome
Type Checking TypeScript 5.4
Build Tool Vite 5.3

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Run linting (bun run lint)
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Code Style

  • Use TypeScript for all new files
  • Follow Biome formatting rules
  • Add JSDoc comments for public APIs
  • Use semantic commit messages

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

A production-ready dashboard template built with Qwik and Tailwind CSS, designed for rapid project initialization with enterprise-grade features.

Resources

License

Stars

Watchers

Forks

Contributors