ReactronBase is a boilerplate for building desktop applications using Electron and Vite. This template sets up a development environment with TypeScript, Tailwind CSS, and Electron, providing essential configurations for building and packaging your application. It is designed to accelerate development by offering a streamlined setup, rapid build processes, and powerful tooling for both the main and renderer processes.
.
โโโ db/ # Directory containing database files
โ โโโ dev.db # SQLite database file
โโโ dist/ # Compiled output directory for main process
โโโ libs/ # Directory for native libraries (e.g., SQLite)
โ โโโ sqlite3.dll # SQLite library for Windows
โโโ node_modules/ # Node.js dependencies
โโโ public/ # Static assets (e.g., icons, images)
โโโ reactron-base-win32-x64 # Packaged application for Windows (x64)
โโโ src/ # Source files
โ โโโ assets/ # Assets like fonts and images
โ โโโ libs/ # Source files for additional libraries
โ โโโ main/ # Main process TypeScript files
โ โโโ renderer/ # Renderer process TypeScript files
โ โโโ types/ # TypeScript type definitions
โ โโโ styles.css # Global styles
โโโ electron-windows-store-config.json # Configuration for Windows Store packaging
โโโ license.md # License information
โโโ package.json # Project metadata and scripts
โโโ package-lock.json # Dependency lock file
โโโ postcss.config.js # PostCSS configuration
โโโ readme.md # Project overview and documentation
โโโ tailwind.config.js # Tailwind CSS configuration
โโโ tsconfig.json # TypeScript configuration
โโโ vite.config.ts # Vite configuration
To get started with ReactronBase, follow these steps:
To quickly set up a new ReactronBase application, use the command-line tool:
npx create-reactronbase <app-name>
Replace <app-name>
with your desired application name. This will:
If you prefer to clone the repository and set up manually:
git clone https://github.com/ahadnawaz585/ReactronBase.git
cd ReactronBase
npm install
To start the development server and Electron application simultaneously:
npm run dev
This will:
To build the application for production:
npm run build
This command will:
dist/main
directory.To package the application for Windows (x64):
npm run package
This will create a packaged application in the reactron-base-win32-x64
directory. It includes:
libs/sqlite3.dll
).db/dev.db
).If you need to rebuild the SQLite library for a different version or configuration:
npm run rebuild-sql
Database Location: On Windows, you can find your application's database file in %appdata%
. Navigate to the folder named after your application to locate dev.db
.
Debugging: Use Chrome DevTools for debugging the renderer process by launching Electron with DEBUG=true
.
Better Development Environment: Use concurrently
or npm-run-all
to run multiple scripts simultaneously (e.g., Vite and Electron). Install them using:
npm install concurrently
Update package.json
scripts:
"scripts": {
"start": "concurrently \"npm run dev:renderer\" \"npm run dev:main\"",
"dev:renderer": "vite",
"dev:main": "electron .",
"build": "vite build && tsc",
"package": "electron-packager . --platform=win32 --arch=x64",
"rebuild-sql": "node rebuild-sql.js"
}
src/renderer/styles.css
to adjust the appearance of your application. Utilize Tailwind CSS for utility-first styling.electron-windows-store-config.json
for custom Windows Store packaging settings.To create a new component, run:
npm run create:component <component-name>
Replace <component-name>
with the desired name for your component. This command will:
src/renderer/components/
.To create a new page, run:
npm run create:page <page-name>
Replace <page-name>
with the desired name for your page. This command will:
src/renderer/pages/
with the page name.Q: What is ReactronBase?
A: ReactronBase is a boilerplate for creating desktop applications using Electron and Vite. It provides a ready-to-use setup with TypeScript and Tailwind CSS.
Q: How do I add new features to my application?
A: You can add new features by modifying the files in the src/
directory. For example, update src/renderer
for UI changes or src/main
for backend logic.
Q: How can I update the SQLite library?
A: To update the SQLite library, modify the libs/
directory with the new library version and rebuild it using npm run rebuild-sql
.
Q: How do I seed or reset the database?
A: Use the provided seeding and resetting methods in src/main
or dedicated scripts. Refer to the Seeding and Resetting the Database section for detailed instructions.
Q: Where can I find more information about Electron and Vite?
A: Refer to the Electron Documentation and the Vite Documentation for more information.
Here's the updated section for your README.md
file, including instructions for running Knex migrations:
To seed your database with initial data, create a seeding script. You can add this script to the src/main
directory or as a standalone script in your project.
Example seeding script (seed.ts
):
import { Database } from 'sqlite3';
const db = new Database('db/dev.db');
db.serialize(() => {
db.run('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
const stmt = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
stmt.run('John Doe', '[email protected]');
stmt.finalize();
});
db.close();
Run the seeding script:
npx ts-node src/main/seed.ts
To reset your database, you can drop existing tables and re-run the seeding script. Modify your seeding script to include table dropping commands:
db.serialize(() => {
db.run('DROP TABLE IF EXISTS users');
db.run('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
// Re-run seeding
});
Run the script to reset the database:
npx ts-node src/main/seed.ts
To manage your database schema with Knex, use migrations. Follow these steps:
Create a Migration File
Create a new migration file to define schema changes:
npx knex migrate:make creating_schema
This will generate a file like YYYYMMDDHHMMSS_creating_schema.js
inside the migrations
directory.
Define Your Schema in the Migration File
Open the generated migration file and define your schema:
// migrations/YYYYMMDDHHMMSS_creating_schema.js
exports.up = function (knex) {
return knex.schema.createTable('example_table', (table) => {
table.increments('id').primary();
table.string('name').notNullable();
table.timestamps(true, true);
});
};
exports.down = function (knex) {
return knex.schema.dropTable('example_table');
};
Run the Migrations
Apply the migrations to your database:
npx knex migrate:latest
This command will execute all pending migrations and update your database schema.
Enhanced ORM Integration: Research and integrate an ORM (Object-Relational Mapping) library for improved database interactions. Options include TypeORM, Sequelize, or creating a custom base model for better data management.
Advanced Seeding and Migration: Develop advanced seeding capabilities and migration scripts for managing database changes and updates.
Improved Development Environment: Implement features to streamline development workflows, such as automated testing setups, enhanced build processes, and integrated debugging tools.
Additional Configuration Options: Enhance configuration flexibility, including support for additional database engines and deployment platforms.
For updates on these upcoming features, follow the project on GitHub and participate in discussions and feature requests.
For discussions, feature requests, and community support, please visit the GitHub Discussions page. Here, you can engage with other users and contributors, share ideas, and get help with any issues you encounter.
๐ License
This project is licensed under the MIT License. See the license.md file for details.
We welcome and appreciate contributions from the community! To ensure a smooth and effective collaboration, please follow these guidelines when contributing to the project:
Fork the Repository:
Start by forking the repository to your GitHub account. This will create a copy of the repository where you can make changes.
Clone Your Fork:
Clone your forked repository to your local machine.
git clone https://github.com/ahadnawaz585/ReactronBase
cd your-repo-name
Create a Branch:
Create a new branch for your changes. Use a descriptive name that reflects the purpose of the branch.
git checkout -b feature/your-feature-name
Make Your Changes:
Implement your changes in the new branch. Ensure that your code adheres to the project's coding standards and includes relevant tests if applicable.
Commit Your Changes:
Write clear and concise commit messages. Follow conventional commit guidelines to keep the commit history clean and understandable.
git add .
git commit -m "feat: add new feature X"
Push to Your Fork:
Push the changes in your branch to your forked repository.
git push origin feature/your-feature-name
Create a Pull Request:
Navigate to the original repository and submit a pull request from your branch. Provide a detailed description of the changes you made and why they are necessary.
npm run lint
before committing your changes.npm run format
to automatically format your code.npm test
to execute the test suite.Fixes #issue_number
syntax.For more details about the technologies used in this project, refer to the following resources:
For support or questions, please open an issue on GitHub or contact the project maintainers directly.