Code Monkey home page Code Monkey logo

ai-generation's Introduction

Cloudflare Ai Generation

Overview

This project is a simple web application that utilizes Cloudflare Workers for the backend and Preact for the frontend. Cloudflare Workers provide serverless compute environments that enable developers to deploy code at the edge of Cloudflare's network, closer to users, which can significantly improve performance and reduce latency. Preact, a lightweight alternative to React, is used for building fast and efficient user interfaces.

Only the free cloudflare provider is allowed on this url

Image Generation

UI Image Showcase

Chat

UI Chat Showcase

Multiple providers

UI Provider Dropdown Showcase

Features

  • Serverless backend powered by Cloudflare Workers
  • Lightweight and efficient frontend built with Preact
  • Responsive design for various screen sizes
  • Minimalistic user interface

Technologies Used

  • Cloudflare Workers: Serverless compute platform
  • Preact: Fast 3kB alternative to React with the same modern API
  • HTML/CSS: For structuring and styling the frontend
  • JavaScript: Programming language used for both backend and frontend logic

Setup

  1. Clone the repository:
    git clone https://github.com/geekcoderscz/ai-generation.git
  2. Install dependencies for frontend:
    cd ui
    npm install
  3. Install dependencies for backend:
    cd api
    npm install
  4. Fill in the environment variables for frontend and backend:
    cd api
    cp wrangler.example.toml wrangler.prod.toml
    cp wrangler.example.toml wrangler.toml
    cd ../ui
    cp .env.production
  5. Deploy UI Workers:
    cd ui
    npm run deploy:cf
  6. Deploy Cloudflare Workers:
    cd api
    npm run deploy:cf
  7. Migrate D1 Cloudflare Database:
    cd api
    npx wrangler d1 execute prod-img-engine --file=./migrations/01.sql
    npx wrangler d1 execute prod-img-engine --file=./migrations/02.sql

Frontend variables

File ui/.env

VITE_API_HOST="https://YOUR_DOMAIN/api"

Backend variables

File api/wrangler.toml

OPEN_AI_KEY = "***"

OPENAI_AI_ENABLED = false

CLOUDFLARE_AI_ENABLED = true

Usage

Once deployed, users can access the application through the provided Cloudflare Workers URL. The frontend interface allows users to interact with the backend through various actions such as fetching data or submitting forms.

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Pull the repository
  2. Create your feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Create a new Pull Request

License

This project is licensed under the MIT License.

Acknowledgements

  • Thanks to Cloudflare for providing the powerful serverless platform
  • Preact for offering a lightweight alternative to React
  • Contributors and open-source community for valuable feedback and support.

ai-generation's People

Contributors

dependabot[bot] avatar krcaltomas99 avatar tomaskrcal avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.