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

https://github.com/axelpey/natural-frontend/assets/1381992/dbef93fa-6313-4122-902b-9109961abeec

Features

  • Natural Frontend understands your codebase and the potential user personas for your product.
  • On the /frontend endpoint, select a user persona and NF will generate 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 color themes of the frontend. Use two keys: "primary" and "secondary".
  • personas: Add custom personas for your frontend. NF will guess more until there's a total of 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 your local environment.

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 one of the example applications: uvicorn example.APP.main:app --reload where APP is one in the examples directory.

(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.5.tar.gz (233.2 kB view details)

Uploaded Source

Built Distribution

natural_frontend-0.0.5-py3-none-any.whl (227.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for natural_frontend-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c4c52296f54247b99d3e5a6a2f9e00324ab6d3706a93720a021812b76156ccea
MD5 424141d62b9a63087f7a5fda43965f6e
BLAKE2b-256 c57ae00973bb150116780cf05a4190866e59f2646c5e7f79aa14ca12f9d30b97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natural_frontend-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c8da69c971162fe97e8fc451eca729be792ac697f57fd5081121e4ffe0d23f50
MD5 c16854269bd3fbff59917f6c71db59d0
BLAKE2b-256 d8814f4bf2b0788e72b36ba0825cc0c3ecd8cc9f7dff17283ef8e914a6c1015f

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