Skip to content
/ flarekit Public template

Flarekit is a scalable, modular, and developer-friendly monorepo ecosystem designed to build and deploy high-performance web applications leveraging Cloudflare Infrastructure. It provides seamless integration with modern web technologies, enabling rapid development with a focus on speed, modularity, and reliability.

License

Notifications You must be signed in to change notification settings

Atyantik/flarekit

Repository files navigation

Flarekit

Flarekit

License

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

  1. Introduction
  2. Project Structure
  3. Prerequisites
  4. Setup Instructions
  5. Development
  6. Testing
  7. Deployment
  8. Manual Deployment
  9. Working with Database Services
  10. Contribution Guidelines
  11. 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

  1. Clone the Repository:

    git clone https://github.com/Atyantik/flarekit.git
    cd flarekit
  2. Install Dependencies:

    npm install
  3. Start the Development Environment:

    npm run dev

    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

npm test

Run End-to-End Tests (Playwright)

npx playwright install && npm run test:e2e

Deployment

Automated Deployment (GitHub Actions)

Flarekit leverages GitHub Actions for automated deployments:

  1. Linting and testing ensure code quality.
  2. Builds separate deployable applications for backend and frontend.
  3. Deploys to Cloudflare environments using Wrangler.

Manual Deployment

In cases where manual deployment is necessary:

  1. Run linting:

    npm run lint
  2. Build applications:

    npm run build
  3. Run tests:

    npm test
  4. Deploy database migrations:

    CLOUDFLARE_API_TOKEN=<token> CLOUDFLARE_ACCOUNT_ID=<account_id> npx flarekit migrate:d1:production
  5. Deploy frontend:

    cd apps/web
    CLOUDFLARE_API_TOKEN=<token> CLOUDFLARE_ACCOUNT_ID=<account_id> npx wrangler pages deploy ./dist
    cd ../..
  6. 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

Contribution Guidelines

  1. 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
  2. Create a Feature Branch: Create a branch for your feature or bug fix:

    git checkout -b feature/your-feature-name
  3. 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
  4. Write Tests: Add unit and integration tests for your changes:

    npm test
  5. Push Your Changes: Push your feature branch to your forked repository:

    git push origin feature/your-feature-name
  6. 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

Atyantik 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!

About

Flarekit is a scalable, modular, and developer-friendly monorepo ecosystem designed to build and deploy high-performance web applications leveraging Cloudflare Infrastructure. It provides seamless integration with modern web technologies, enabling rapid development with a focus on speed, modularity, and reliability.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published