Flarekit is a scalable and modular monorepo designed to build modern, edge-first web applications using Cloudflare Infrastructure. It provides a unified structure for developing frontend, backend, and shared services, ensuring code reusability, maintainability, and performance across distributed applications.
Supported and sponsored by Atyantik Technologies. 🚀
- Introduction
- Project Structure
- Prerequisites
- Setup Instructions
- Development
- Testing
- Deployment
- Manual Deployment
- Working with Database Services
- Contribution Guidelines
- License
Flarekit simplifies the complexities of building interconnected apps for Cloudflare Infrastructure. While Cloudflare provides excellent production-ready tools, local development and testing often pose challenges. Flarekit addresses this by providing:
- Predefined commands for managing apps and databases.
- Integrated developer tools like ESLint, Prettier, and examples using Astro (frontend) and Hono (backend).
- Shared infrastructure setup supporting D1 databases, R2 storage, and Queues for seamless local and production environments.
By enabling an edge-first development model, Flarekit ensures developers can create scalable, maintainable, and testable applications for Cloudflare.
The monorepo is organized as follows:
flarekit/
├── apps/
│ ├── backend/ # Backend services
│ └── web/ # Frontend application
├── packages/
│ └── database/ # Shared database layer
├── scripts/ # Utility scripts
├── .github/ # GitHub Actions workflows
├── turbo.json # TurboRepo configuration
└── package.json # Root package manager configuration
- apps/backend: Cloudflare Worker API built with Hono.
- apps/web: Frontend application using Astro.
- packages/database: Centralized database layer with D1 and Drizzle ORM.
Ensure the following tools are installed:
-
Clone the Repository:
git clone https://github.com/Atyantik/flarekit.git cd flarekit
-
Install Dependencies:
npm install
-
Start the Development Environment:
npm run dev
TurboRepo ensures all apps and services start seamlessly.
npx flarekit dev --filter="@flarekit/backend"
npx flarekit dev --filter="@flarekit/web"
npm test
npx playwright install && npm run test:e2e
Flarekit leverages GitHub Actions for automated deployments:
- Linting and testing ensure code quality.
- Builds separate deployable applications for backend and frontend.
- Deploys to Cloudflare environments using Wrangler.
In cases where manual deployment is necessary:
-
Run linting:
npm run lint
-
Build applications:
npm run build
-
Run tests:
npm test
-
Deploy database migrations:
CLOUDFLARE_API_TOKEN=<token> CLOUDFLARE_ACCOUNT_ID=<account_id> npx flarekit migrate:d1:production
-
Deploy frontend:
cd apps/web CLOUDFLARE_API_TOKEN=<token> CLOUDFLARE_ACCOUNT_ID=<account_id> npx wrangler pages deploy ./dist cd ../..
-
Deploy backend:
cd apps/backend CLOUDFLARE_API_TOKEN=<token> CLOUDFLARE_ACCOUNT_ID=<account_id> npx wrangler deploy cd ../..
The database package (@flarekit/database
) is a lightweight library built with Rollup, ensuring compatibility with all monorepo apps.
Drizzle ORM is edge-deployable, making it ideal for Cloudflare’s infrastructure. Avoid non-edge-compatible ORMs.
Define a schema in packages/database/src/schema
:
import { sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { sql } from 'drizzle-orm';
export const userSchema = sqliteTable('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull(),
createdAt: text('created_at').default(sql`(current_timestamp)`),
});
Generate migrations:
npx flarekit build:migrations
Run migrations locally:
npx flarekit migrate:d1:local
-
Fork the Repository: Fork the Flarekit repository to your GitHub account and clone it locally:
git clone https://github.com/<your-username>/flarekit.git cd flarekit
-
Create a Feature Branch: Create a branch for your feature or bug fix:
git checkout -b feature/your-feature-name
-
Implement Changes:
- Write your code following the project's style and guidelines.
- Pre-commit and pre-push hooks will automatically ensure linting and quality checks. You can also run them manually:
npm run lint
-
Write Tests: Add unit and integration tests for your changes:
npm test
-
Push Your Changes: Push your feature branch to your forked repository:
git push origin feature/your-feature-name
-
Submit a Pull Request:
- Open a pull request from your branch to the main Flarekit repository.
- Include a clear and detailed description of your changes, linking any relevant issues.
- Provide steps for testing your contribution if necessary.
By following these steps, you contribute to the success and quality of the Flarekit project.
This project is licensed under the MIT License. See the LICENSE
file for details.
For further assistance, refer to the Cloudflare Developers Documentation or contact the maintainers.
Flarekit is proudly supported and sponsored by Atyantik Technologies, a leading software development company specializing in scalable web applications, cloud services, and cutting-edge technologies.
Flarekit – Simplifying Edge-First Development with Cloudflare and Astro! 🌍✨
For issues or inquiries, please open an issue or reach out directly. Thank you for contributing and using Flarekit!