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. π
Table of Contents
- Introduction
- Project Structure
- Prerequisites
- Setup Instructions
- Development
- Testing
- Deployment
- Manual Deployment
- Working with Database Services
- Contribution Guidelines
- License
Introduction
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.
Project Structure
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.
Prerequisites
Ensure the following tools are installed:
Setup Instructions
-
Clone the Repository:
git clone https://github.com/Atyantik/flarekit.git cd flarekit -
Install Dependencies:
-
Start the Development Environment:
TurboRepo ensures all apps and services start seamlessly.
Development
Backend Development
npx flarekit dev --filter="@flarekit/backend"Frontend Development
npx flarekit dev --filter="@flarekit/web"Testing
Run Unit Tests
Run End-to-End Tests (Playwright)
npx playwright install && npm run test:e2eDeployment
Automated Deployment (GitHub Actions)
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.
Manual Deployment
In cases where manual deployment is necessary:
-
Run linting:
-
Build applications:
-
Run tests:
-
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 ../..
Working with Database Services
The database package (@flarekit/database) is a lightweight library built with Rollup, ensuring compatibility with all monorepo apps.
Why Drizzle ORM?
Drizzle ORM is edge-deployable, making it ideal for Cloudflareβs infrastructure. Avoid non-edge-compatible ORMs.
Creating a Schema
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)`), });
Generating Migrations
Generate migrations:
npx flarekit build:migrations
Applying Local Migrations
Run migrations locally:
npx flarekit migrate:d1:local
Joining Tables
The BaseService constructor accepts an optional relations array to join
related tables using Drizzle ORM.
import { eq } from 'drizzle-orm'; import { storageSchema, storageInfoSchema } from '@flarekit/database'; const storageInfoService = new BaseService(storageInfoSchema, ctx, [ { schema: storageSchema, on: (info, storage) => eq(info.storageId, storage.id), }, ]); // Fetch a record with its related storage entry const result = await storageInfoService.getByIdWithRelations(id);
Contribution Guidelines
-
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:
-
Write Tests: Add unit and integration tests for your changes:
-
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.
License
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.
About Atyantik Technologies
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.
Contact Atyantik
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!

