Skip to content

trevorius/electron-forge-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

98 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Electron React Boilerplate

A modern, feature-rich Electron application boilerplate with React, TypeScript, ShadcnUI, and Tailwind CSS integration. This project provides a solid foundation for building cross-platform desktop applications with comprehensive testing, 100% jest coverage and development workflows.

project integrates llama.cpp with options to download llama3.2 or upload your own llmGGUF.

๐Ÿš€ Features

  • Electron - Cross-platform desktop app framework
  • React 19 - Modern React with latest features
  • TypeScript - Type-safe development
  • ShadcnUI - Beautiful, accessible component library
  • Tailwind CSS - Utility-first CSS framework
  • Vite - Fast build tool and development server
  • Jest - Comprehensive testing framework
  • i18next - Internationalization support
  • React Router - Client-side routing
  • Lucide Icons - Beautiful icon library

๐Ÿ“ฆ Installation

# Clone the repository
git clone https://github.com/trev-z-dev/electron-boilerplate.git
cd electron-boilerplate

# Install dependencies
npm install

๐Ÿ› ๏ธ Development

Start Development Server

# Start both Vite dev server and Electron in development mode
npm run dev

# Or start individually:
npm run dev:vite    # Start Vite dev server only
npm run dev:electron # Start Electron only (requires Vite server running)

Available Scripts

Command Description
npm start Start Electron using Electron Forge
npm run dev Start development environment (Vite + Electron)
npm run build Build the React application for production
npm run preview Preview the production build
npm test Run all tests
npm run test:watch Run tests in watch mode
npm run test:coverage Run tests with coverage report
npm run package Package the application
npm run make Create distribution packages
npm run publish Publish the application

๐Ÿ—๏ธ Project Structure

src/
โ”œโ”€โ”€ electron/           # Electron main process files
โ”‚   โ”œโ”€โ”€ main.js        # Main Electron process
โ”‚   โ””โ”€โ”€ preload.js     # Preload script
โ””โ”€โ”€ react/             # React application
    โ”œโ”€โ”€ components/    # React components
    โ”‚   โ”œโ”€โ”€ common/    # Shared components
    โ”‚   โ”œโ”€โ”€ game/      # Game components (TicTacToe, lineDestroyer)
    โ”‚   โ”œโ”€โ”€ layout/    # Layout components
    โ”‚   โ””โ”€โ”€ ui/        # ShadcnUI components
    โ”œโ”€โ”€ lib/           # Utility libraries
    โ”œโ”€โ”€ locales/       # i18n translation files
    โ”œโ”€โ”€ styles/        # Global styles
    โ”œโ”€โ”€ __mocks__/     # Jest mocks
    โ”œโ”€โ”€ App.tsx        # Main App component
    โ”œโ”€โ”€ routes.tsx     # Route definitions
    โ””โ”€โ”€ index.tsx      # React entry point

๐ŸŽฎ Built-in Games

This boilerplate includes two fully-featured games to demonstrate the capabilities:

lineDestroyer

  • Complete lineDestroyer implementation with scoring, levels, and line clearing
  • Comprehensive test coverage (99%+)
  • Documented architecture in lineDestroyer.doc.md
  • Keyboard controls: Arrow keys for movement, Space for hard drop, P for pause

TicTacToe

  • Classic 3x3 grid game
  • Player vs Player gameplay
  • Win detection and game reset functionality

๐Ÿงช Testing

The project maintains high test coverage standards:

  • Coverage Target: 99%+
  • Testing Strategy: Unit tests, integration tests, and mocked component tests
  • Framework: Jest with React Testing Library

Test Coverage Strategy

When coverage targets cannot be achieved through traditional testing:

  1. Refactor complex logic into helper functions
  2. Helper functions achieve 100% coverage easily
  3. Focus on separation of concerns
  4. Prefer unit testing of helpers over complex component mocking

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

โšก Adding Features

This section provides comprehensive guides for extending the application with new functionality. Each guide includes implementation patterns, best practices, and testing strategies to maintain code quality and consistency.

๐Ÿ“„ Documentation Guides

Guide Description Focus Areas
Routes and Pages Complete guide for adding new routes and pages Type-safe routing, component organization, navigation integration, i18n support
Backend Architecture Comprehensive backend development guide Database layer, service architecture, controllers, preload scripts, IPC communication
Testing Strategies Advanced testing techniques for 100% coverage Helper function extraction, edge case testing, mocking strategies, coverage analysis
Release Compilation Complete build and distribution guide Production builds, cross-platform packaging, release automation, security hardening

๐ŸŽฏ Feature Development Workflow

  1. Plan the Feature: Review relevant documentation guides above
  2. Define Routes: Follow Routes and Pages Guide for frontend navigation
  3. Implement Backend: Use Backend Architecture Guide for data layer and IPC
  4. Achieve Coverage: Apply Testing Strategies Guide for comprehensive testing
  5. Build and Release: Follow Release Compilation Guide for production deployment
  6. Validate: Run npm run test:coverage to ensure 100% coverage maintenance

๐Ÿ“‹ Quick Reference

  • New Page Component: Extract complex logic to helpers for testability
  • Database Operations: Use service layer with Prisma ORM and automatic initialization
  • IPC Communication: Implement secure controller-preload-component patterns
  • Testing: Target 100% coverage through helper function extraction and edge case testing
  • Release Builds: Use npm run build && npm run package && npm run make for distribution
  • Internationalization: Add i18n keys for all user-facing text

๐ŸŒ Internationalization

The application supports multiple languages using i18next:

  • English (default)
  • French
  • Automatic language detection
  • Easy to add new languages in src/react/locales/

๐Ÿ“ฑ Distribution

Supported Platforms

  • Windows - Squirrel installer
  • macOS - ZIP package
  • Linux - DEB and RPM packages

Building for Distribution

# Package the application
npm run package

# Create distribution packages for all platforms
npm run make

๐Ÿ› ๏ธ Technology Stack

Core Technologies

  • Electron 38 - Desktop app framework
  • React 19 - UI library
  • TypeScript 5 - Programming language
  • Vite 7 - Build tool

UI & Styling

  • ShadcnUI - Component library
  • Tailwind CSS 4 - CSS framework
  • Radix UI - Accessible primitives
  • Lucide React - Icon library

Development Tools

  • Jest 30 - Testing framework
  • React Testing Library - Component testing
  • Electron Forge - Packaging and distribution
  • Concurrently - Parallel script execution

๐Ÿ“ Configuration Files

  • package.json - Project metadata and scripts
  • vite.config.js - Vite configuration
  • jest.config.js - Jest testing configuration
  • tailwind.config.js - Tailwind CSS configuration
  • tsconfig.json - TypeScript configuration
  • CLAUDE.md - Project-specific development rules

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass and maintain coverage targets
  6. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿ‘จโ€๐Ÿ’ป Author

๐Ÿ”— Links

About

Modern Electron boilerplate with React, Vite, Tailwind CSS, shadcn/ui, and TypeScript. Built with Electron Forge for cross-platform desktop applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages