Skip to main content

A wrapper for FastAPI to automatically generate a frontend

Project description

Natural Frontend Logo

From backend to frontend with one line
Don't waste hours generating a frontend for your users.

NF Usage

NF Screenshot

Features

  • Natural Frontend understands your codebase and the potential user personas for your product.
  • On the /frontend endpoint, select a user personas and NF generates a tailored frontend.

Coming soon:

  • Save your generated frontends to modify them later.
  • Use local models instead of openai.

Usage

⬇️ Installation

With pip: pip install natural-frontend

➕ Add to your code

Just add one-line to your api project:

from fastapi import FastAPI
from natural_frontend import NaturalFrontend

openai_key = "sk-..."

app = FastAPI()
app = NaturalFrontend(app, openai_key)

@app.get("/books")
async def get_books():
    return books_db


@app.post("/books")
async def add_book(book: Book):
    books_db.append(book.dict())
    return {"message": "Book added successfully"}

class Book(BaseModel):
    id: int
    title: str
    author: str
    genre: str

⚙️ Options

You can provide options to customize your Natural Frontend:

nf_options = NaturalFrontendOptions(
   colors={"primary": "lightblue", "secondary": "purple"},
   personas=[{"Bookworm": "Loves to look for new books"}],
   cache_expiry_time=600,
   frontend_endpoint="frontend",
)

app = NaturalFrontend(app, openai_key, nf_options)

Documentation of options:

  • colors: Customize the colors of the frontend. Use two keys: "primary" and "secondary".
  • personas: Add custom personas for your frontend. NF will guess more until there's 5 personas.
  • cache_expiry_time: Set the time in seconds before the generation cache expires.
  • frontend_endpoint: Change the endpoint of the frontend.

Development

We're happy to get contributors working with us! Follow the instructions below to quickly setup yo

Running the Application

  1. (Optional) Use virtualenv to quickly setup your environment: virtualenv venv && source venv/bin/activate

  2. Install the required packages: pip install -r requirements.txt

  3. Run the example application: uvicorn app.main:app --reload

(With Docker)

  1. Make sure you have Docker installed

  2. Run docker compose up --build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

natural_frontend-0.0.2.tar.gz (230.3 kB view details)

Uploaded Source

Built Distribution

natural_frontend-0.0.2-py3-none-any.whl (226.8 kB view details)

Uploaded Python 3

File details

Details for the file natural_frontend-0.0.2.tar.gz.

File metadata

  • Download URL: natural_frontend-0.0.2.tar.gz
  • Upload date:
  • Size: 230.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for natural_frontend-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d05fae6a22cb3a084500f1f44d08580d09aaf38eb0dd70f78309d69dd76ea25c
MD5 ba4da6e7b6109ddae3f9c55d36c7bf9d
BLAKE2b-256 abb293c1881deee7912884c30246cd36ecc4e33f7f26fe54806e396ab20bf067

See more details on using hashes here.

File details

Details for the file natural_frontend-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for natural_frontend-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c815a5d330527c5e3eef8b3812392f67750cf0ed10046e697abc6119ddbf3d71
MD5 2d8c76602e1c4608d2d21c56b0bffae4
BLAKE2b-256 e9fa67e55cadfbef28714ea7782b5f7994cbef785c865fb1b707a166b11edbe9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page