coreui-free-bootstrap-admin-template Agent Skills & AI Rules

GitHub

Free Bootstrap Admin & Dashboard Template Built for AI-Assisted Development

RAW Rules
2 Discovered Rules β€’ ~6,061 Estimated Tokens
Quick:
Loading skill content...

System Architecture & Module Boundaries

ARCHITECTURE.md project-spec ~4,581 tokens
Raw
# Architecture Documentation

## Project Purpose

CoreUI Free Bootstrap Admin Template is a professional admin dashboard template built on Bootstrap 5 and CoreUI components. It provides a ready-to-use foundation for building admin panels, dashboards, and web applications with a clean, modern interface.

**Key Characteristics:**
- Server-side templating approach (Pug β†’ HTML)
- Bootstrap 5 + CoreUI component library
- Vanilla JavaScript (no framework dependencies)
- Multi-page application (MPA) architecture
- Static file generation with build-time compilation

## High-Level Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Source Files                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚   Pug    β”‚  β”‚   Sass   β”‚  β”‚    JS    β”‚           β”‚
β”‚  β”‚Templates β”‚  β”‚  Styles  β”‚  β”‚ Modules  β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜           β”‚
β”‚       β”‚             β”‚             β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚             β”‚             β”‚
        β–Ό             β–Ό             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Build Pipeline                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚   Pug    β”‚  β”‚PostCSS + β”‚  β”‚ syncdir  β”‚           β”‚
β”‚  β”‚Compiler  β”‚  β”‚  Sass    β”‚  β”‚(copy JS) β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜           β”‚
β”‚       β”‚             β”‚             β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚             β”‚             β”‚
        β–Ό             β–Ό             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 Distribution Files                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚   HTML   β”‚  β”‚   CSS    β”‚  β”‚    JS    β”‚           β”‚
β”‚  β”‚  Files   β”‚  β”‚ (minified)β”‚  β”‚(bundled) β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚         (served via browser-sync or web server)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Technology Stack

### Frontend
- **HTML Generation**: Pug 3.0.3 (template engine)
- **CSS Framework**: Bootstrap 5.3.x
- **Component Library**: CoreUI 5.x (@coreui/coreui)
- **Icons**: CoreUI Icons (@coreui/icons)
- **JavaScript**: Vanilla ES6+ (no framework)
- **Charts**: Chart.js 4.x
- **Scrollbars**: SimpleBar 6.x

### Build Tools
- **Package Manager**: npm
- **CSS Processing**: Sass 1.102.x β†’ PostCSS β†’ Autoprefixer
- **JS**: plain ES2015+, copied as-is via `sync-directory` (no transpilation - the declared browser targets already support the syntax used, see [Browser Support](#browser-support))
- **Task Runner**: npm scripts with npm-run-all
- **File Watching**: Nodemon
- **Live Server**: Browser-sync 3.0.4

### Code Quality
- **Linting**: ESLint 9.x (flat config) with XO + Unicorn
- **Style Linting**: Stylelint 16.x with Bootstrap config
- **Formatting**: Prettier 3.9.x
- **Editor Config**: .editorconfig for consistency

## Directory Structure

```
coreui-free-bootstrap-admin-template/
β”‚
β”œβ”€β”€ src/                          # Source files (edit these)
β”‚   β”œβ”€β”€ pug/                      # Pug templates (HTML source)
β”‚   β”‚   β”œβ”€β”€ _layout/              # Base layout templates
β”‚   β”‚   β”‚   β”œβ”€β”€ default.pug       # Main layout with sidebar/header
β”‚   β”‚   β”‚   └── pages.pug         # Standalone pages layout (auth, errors)
β”‚   β”‚   β”œβ”€β”€ _partials/            # Reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ banner.pug        # Top announcement banner
β”‚   β”‚   β”‚   β”œβ”€β”€ head.pug          # HTML <head> section
β”‚   β”‚   β”‚   β”œβ”€β”€ header.pug        # Top navigation bar
β”‚   β”‚   β”‚   β”œβ”€β”€ sidebar.pug       # Left sidebar wrapper
β”‚   β”‚   β”‚   β”œβ”€β”€ sidebar-nav.pug   # Sidebar navigation items (data-driven)
β”‚   β”‚   β”‚   β”œβ”€β”€ footer.pug        # Page footer
β”‚   β”‚   β”‚   β”œβ”€β”€ scripts.pug       # Common script includes
β”‚   β”‚   β”‚   └── docs-icons.pug    # Icon documentation helpers
β”‚   β”‚   β”œβ”€β”€ _mixins/              # Pug helper mixins
β”‚   β”‚   β”‚   β”œβ”€β”€ breadcrumb.pug    # Breadcrumb generator
β”‚   β”‚   β”‚   β”œβ”€β”€ callout.pug       # Alert/callout boxes
β”‚   β”‚   β”‚   β”œβ”€β”€ callout-custom.pug # Custom callout variant
β”‚   β”‚   β”‚   β”œβ”€β”€ docs-components.pug # Docs component helpers
β”‚   β”‚   β”‚   β”œβ”€β”€ example.pug       # Code example displays
β”‚   β”‚   β”‚   └── inline-svg.pug    # Inline SVG helper
β”‚   β”‚   └── views/                # Page templates
β”‚   β”‚       β”œβ”€β”€ index.pug         # Main dashboard page
β”‚   β”‚       β”œβ”€β”€ blank.pug         # Blank page template
β”‚   β”‚       β”œβ”€β”€ charts.pug        # Charts page
β”‚   β”‚       β”œβ”€β”€ widgets.pug       # Widgets page
β”‚   β”‚       β”œβ”€β”€ authentication/   # Auth pages (login, register, etc.)
β”‚   β”‚       β”œβ”€β”€ components/       # UI components (buttons, modals, etc.)
β”‚   β”‚       β”œβ”€β”€ error-pages/      # Error pages (404, 500)
β”‚   β”‚       β”œβ”€β”€ forms/            # Form components
β”‚   β”‚       └── icons/            # Icon libraries
β”‚   β”‚
β”‚   β”œβ”€β”€ scss/                     # Sass stylesheets
β”‚   β”‚   β”œβ”€β”€ style.scss            # Main stylesheet entry
β”‚   β”‚   β”œβ”€β”€ style-rtl.scss        # RTL (right-to-left) styles
β”‚   β”‚   └── examples.scss         # Demo/example page styles
β”‚   β”‚
β”‚   β”œβ”€β”€ js/                       # JavaScript modules
β”‚   β”‚   β”œβ”€β”€ main.js               # Main entry point
β”‚   β”‚   β”œβ”€β”€ charts.js             # Chart.js configurations
β”‚   β”‚   β”œβ”€β”€ color-modes.js        # Dark/light theme switcher
β”‚   β”‚   β”œβ”€β”€ config.js             # App configuration / shared settings
β”‚   β”‚   β”œβ”€β”€ tooltips.js           # Tooltip initialization
β”‚   β”‚   β”œβ”€β”€ popovers.js           # Popover initialization
β”‚   β”‚   β”œβ”€β”€ toasts.js             # Toast notification initialization
β”‚   β”‚   └── widgets.js            # Widgets page charts
β”‚   β”‚
β”‚   β”œβ”€β”€ assets/                   # Static assets
β”‚   β”‚   β”œβ”€β”€ brand/                # Logo files
β”‚   β”‚   β”œβ”€β”€ favicon/              # Favicon files
β”‚   β”‚   └── img/                  # Images
β”‚   β”‚
β”‚   └── views/                    # Compiled HTML (auto-generated)
β”‚       └── *.html                # Do NOT edit these manually
β”‚
β”œβ”€β”€ dist/                         # Production build output
β”‚   β”œβ”€β”€ css/                      # Minified CSS
β”‚   β”œβ”€β”€ js/                       # Synced JS (copied as-is, no transform)
β”‚   β”œβ”€β”€ assets/                   # Copied assets
β”‚   β”œβ”€β”€ vendors/                  # Third-party libraries
β”‚   └── *.html                    # Production HTML files
β”‚
β”œβ”€β”€ build/                        # Build scripts
β”‚   β”œβ”€β”€ pug.mjs                   # Pug compilation script
β”‚   β”œβ”€β”€ postcss.config.mjs        # PostCSS configuration
β”‚   β”œβ”€β”€ vendors.mjs               # Vendor file bundling
β”‚   └── format-html.mjs           # HTML formatting/prettifying
β”‚
β”œβ”€β”€ node_modules/                 # npm dependencies (ignored)
β”‚
└── Configuration files
    β”œβ”€β”€ package.json              # Dependencies and scripts
    β”œβ”€β”€ .editorconfig             # Editor settings
    β”œβ”€β”€ eslint.config.mjs         # ESLint flat config
    β”œβ”€β”€ .prettierrc.json          # Prettier formatting
    β”œβ”€β”€ .stylelintrc              # Stylelint rules
    β”œβ”€β”€ .browserslistrc           # Target browsers
    └── .cursorrules              # AI context (Cursor IDE)
```

## Build Pipeline Details

### Development Mode (`npm start`)

1. **Clean**: Remove old compiled files
2. **Compile Pug**: `src/pug/**/*.pug` β†’ `src/views/*.html`
3. **Compile Sass**: `src/scss/*.scss` β†’ `dist/css/*.css` (expanded, autoprefixed)
4. **Sync JS**: `src/js/*.js` β†’ `dist/js/*.js` (copied as-is via `sync-directory`, no transform)
5. **Copy Assets**: `src/assets/**/*` β†’ `dist/assets/`
6. **Build Vendors**: Bundle third-party libraries
7. **Watch Files**: Monitor changes and recompile
8. **Browser-sync**: Live reload server on http://localhost:3000

### Production Build (`npm run build`)

1. **All development steps**
2. **Minify CSS**: Compress stylesheets with clean-css-cli
3. **JS**: No separate minify step - shipped as synced source
4. **Optimize Assets**: Copy optimized files
5. **Generate zip**: Create distribution package

### File Watching

```
npm run watch          # Watch all file types
npm run watch-pug      # Watch Pug templates only
npm run watch-css      # Watch Sass files only
npm run watch-js       # Watch JavaScript files only
```

Each watch task uses **nodemon** to monitor file changes and trigger appropriate compilation.

## Data Flow

### Page Rendering Flow

```
1. Browser Request
   └─> /index.html

2. Server Response
   └─> Serve dist/index.html (static file)

3. HTML Loads Resources
   β”œβ”€> dist/css/style.css (Bootstrap + CoreUI + custom styles)
   β”œβ”€> dist/js/main.js (app initialization)
   └─> dist/vendors/*.js (Chart.js, SimpleBar, etc.)

4. JavaScript Execution
   β”œβ”€> Initialize CoreUI components
   β”œβ”€> Set up event listeners
   β”œβ”€> Configure charts (if on dashboard)
   └─> Enable tooltips/popovers

5. User Interaction
   └─> JavaScript handles UI updates (no page reload)
```

### Theme Switching Flow

```
1. User clicks theme toggle button
   └─> color-modes.js listens for click

2. ColorModeStorageManager updates preference
   β”œβ”€> Save to localStorage
   └─> Update [data-coreui-theme] attribute

3. CSS custom properties respond
   └─> Variables change (--cui-primary-bg, --cui-text-color, etc.)

4. ColorSchemeChange event fires
   └─> Charts re-render with new theme colors
```

### Chart Rendering Flow

```
1. charts.js module loads
   └─> import Chart from 'chart.js/auto'

2. DOM ready
   └─> Find chart canvas elements

3. Fetch data (or use inline data)
   └─> Random data generator for demo

4. Create Chart.js instance
   β”œβ”€> Configure chart type (line, bar, pie, etc.)
   β”œβ”€> Apply theme colors from CSS variables
   └─> Set responsive options

5. Theme changes
   └─> Re-initialize charts with new colors
```

## Component Organization

### Pug Template Hierarchy

```
default.pug (main layout β€” dashboard/component pages)
β”œβ”€> sidebar.pug (side navigation)
β”‚   └─> sidebar-nav.pug (data-driven nav items)
β”œβ”€> header.pug (top navigation bar)
β”‚   └─> block breadcrumb
β”œβ”€> block canonical / block styles
β”œβ”€> block view
β”‚   └─> index.pug / components/*.pug / etc. (page content)
└─> footer.pug (page footer)
    └─> scripts.pug (common script includes)
        └─> block scripts / block js

pages.pug (standalone layout β€” auth & error pages)
β”œβ”€> block styles
└─> block view
    └─> authentication/*.pug / error-pages/*.pug
```

**Block System:**
- `block view`: Main page content area (both layouts)
- `block canonical`: `<link rel="canonical">` override (`default.pug` only)
- `block breadcrumb`: Breadcrumb trail, declared inside `header.pug` (`default.pug` only)
- `block scripts` / `block js`: Page-specific script includes, declared inside `scripts.pug`
- Each view extends a layout and overrides only the blocks it needs

### CSS Architecture

```
style.scss
β”œβ”€> Import Bootstrap 5
β”œβ”€> Import CoreUI components
β”œβ”€> Import custom variables
└─> Import custom component styles

Theme System:
[data-coreui-theme="light"]  # Light mode (default)
[data-coreui-theme="dark"]   # Dark mode
[data-coreui-theme="auto"]   # System preference
```

**CSS Custom Properties:**
- `--cui-primary`, `--cui-secondary`, etc. (colors)
- `--cui-bg`, `--cui-text-color` (backgrounds/text)
- `--cui-border-color`, `--cui-shadow` (UI elements)

### JavaScript Module Pattern

Each JS file in `src/js/` is an ES6 module:

```javascript
// Import dependencies
import { Something } from '@coreui/coreui'

// Define functionality
const doSomething = () => { /* ... */ }

// Initialize on DOM ready
document.addEventListener('DOMContentLoaded', () => {
  doSomething()
})

// Export if needed (most files use side effects only)
```

## Key Dependencies

### Runtime Dependencies

| Package | Purpose | Used In |
|---------|---------|---------|
| `@coreui/coreui` | UI component library | All pages |
| `@coreui/icons` | Icon library | Icon pages |
| `chart.js` | Charts and graphs | Dashboard |
| `simplebar` | Custom scrollbars | Sidebar |
| `@coreui/utils` | Utility functions | Theme switching |

### Build Dependencies

| Package | Purpose |
|---------|---------|
| `sass` | CSS preprocessing |
| `sync-directory` | Copy `src/js`, `src/assets`, `src/views` into `dist/` |
| `pug` | HTML templating |
| `postcss` | CSS post-processing |
| `autoprefixer` | Vendor prefix automation |
| `browser-sync` | Development server |
| `eslint` | JavaScript linting |
| `stylelint` | CSS linting |

## Browser Support

Defined in `.browserslistrc`:

```
>= 0.5%
last 2 major versions
not dead
Chrome >= 60
Firefox >= 60
Firefox ESR
iOS >= 12
Safari >= 12
not Explorer <= 11
```

Modern browsers with native ES2015+ support - this is also why `src/js` ships untranspiled (see [Build Tools](#build-tools)).

## Deployment

### Static Hosting (Recommended)

1. Run `npm run build`
2. Deploy `dist/` folder to:
   - Netlify
   - Vercel
   - GitHub Pages
   - AWS S3 + CloudFront
   - Any static file server

### Traditional Web Server

1. Run `npm run build`
2. Copy `dist/` contents to web root
3. Configure server to serve `index.html` as default
4. Set proper MIME types for CSS/JS files

### Docker (Optional)

```dockerfile
FROM nginx:alpine
COPY dist/ /usr/share/nginx/html/
EXPOSE 80
```

## Performance Considerations

### CSS Optimization
- Sass compilation removes unused styles
- PostCSS autoprefixer adds only necessary prefixes
- Minification in production build
- CSS is render-blocking (loaded in `<head>`)

### JavaScript Optimization
- No transpilation or minification step - files are copied as-is (see [Build Tools](#build-tools))
- Files loaded as separate scripts (no bundler)
- Deferred script loading where possible

### Asset Optimization
- SVG icons (scalable, small file size)
- Favicon in multiple formats for compatibility
- Images in `src/assets/` should be optimized before adding

## Security Considerations

### Content Security Policy (CSP)
Template includes inline scripts and styles. For strict CSP:
1. Extract inline scripts to external files
2. Use nonces or hashes for required inline scripts
3. Update CSP headers accordingly

### XSS Prevention
- Pug automatically escapes HTML by default
- Use `!= html` only for trusted content
- Sanitize user input on server-side (if adding backend)

### Dependency Management
- Regularly update npm dependencies
- Run `npm audit` to check for vulnerabilities
- Pin major versions in `package.json`

## Extensibility

### Adding New Pages

1. Create `src/pug/views/my-page.pug`
2. Extend layout: `extends ../_layout/default.pug`
3. Override the `view` block (see [Block System](#pug-template-hierarchy)):
   ```pug
   block view
     .container-lg.px-4
       h1 My Page Title
       p Page content here
   ```
4. Add an entry to `src/pug/_partials/sidebar-nav.pug` so the page is reachable from the sidebar
5. Run `npm run pug` (or `npm start`) to compile
6. Access at `/my-page.html`

### Adding New Components

1. Check CoreUI docs: https://coreui.io/bootstrap/docs/
2. Copy component markup to Pug file
3. Convert HTML to Pug syntax (use html2pug.com if needed)
4. Import required JavaScript:
   ```javascript
   import { Modal } from '@coreui/coreui'
   ```
5. Initialize component in page-specific JS

### Adding New Styles

1. Edit `src/scss/style.scss` or create new partial
2. Use Sass modules syntax to import CoreUI:
   ```scss
   @use "@coreui/coreui/scss/coreui" as * with (
     $enable-deprecation-messages: false
   );
   ```
   For CoreUI Pro projects:
   ```scss
   @use "@coreui/coreui-pro/scss/coreui" as * with (
     $enable-deprecation-messages: false
   );
   ```
3. Use CSS custom properties for theme compatibility
4. Run `npm run css` to compile

### Integrating Backend APIs

This template is frontend-only. To add backend:

1. **Fetch API** for AJAX requests:
   ```javascript
   fetch('/api/endpoint')
     .then(response => response.json())
     .then(data => updateUI(data))
   ```

2. **Authentication**: Implement token-based auth
   - Store JWT in localStorage/sessionStorage
   - Add Authorization header to requests
   - Redirect to login on 401 responses

3. **State Management**: For complex apps, consider:
   - Vanilla JS with custom events
   - Lightweight state library (Zustand, Nano Stores)
   - Full framework migration (React, Vue, etc.)

## Common Issues and Solutions

### Pug Compilation Errors
- **Error**: "Cannot find module"
  - **Fix**: Check Pug include/extend paths (relative to file)

### Sass Compilation Errors
- **Error**: "Undefined variable"
  - **Fix**: Import Bootstrap/CoreUI variables before using

### JavaScript Errors
- **Error**: "X is not defined"
  - **Fix**: Add `/* global X */` comment or import module

### Live Reload Not Working
- **Error**: Browser-sync not updating
  - **Fix**: Check if `watch` scripts are running, restart `npm start`

### Build Fails
- **Error**: npm scripts fail
  - **Fix**: Delete `node_modules/` and `dist/`, run `npm install`, then `npm run build`

## Resources

- **CoreUI Bootstrap Docs**: https://coreui.io/bootstrap/docs/
- **Pug Documentation**: https://pugjs.org/
- **Chart.js Documentation**: https://www.chartjs.org/
- **Sass Documentation**: https://sass-lang.com/documentation/

## Changelog

See [releases](https://github.com/coreui/coreui-free-bootstrap-admin-template/releases) for version history and updates.