NextPy
2.1k 148What is NextPy ?
NextPy is a Pythonic Web App framework For Humans & LLMs, Simple like Streamlit + Fast and Flexible like Next.js.
Build any web app —effortlessly and quickly ⚡. It simplifies Pythonic development for everything from backends to frontends (yes, visually 🦚stunning frontends in Python!), AI integrations, APIs, and beyond—empowering both humans and AI agents.
Nextpy is designed to solve compatibility issues and improve code generation. It is built on our insight🔍 that the choice of app framework significantly affects the efficiency of AI code generation, regardless of other factors such as LLMs, prompts, or fine-tuning methods.
-
⏰ What You Can Build in 1 hour: Beautiful portfolios, portals, data apps, internal tools, APIs etc.
-
📚 & The best part? Transferable Knowledge: Building with nextpy
progressively
teaches you the best python libraries- FastAPI, Pydantic, SQLModel, Pandas, Jinja2, SQLAlchemy, etc.
Nextpy Features
Simplifying App Development:🧩
-
🐍 Unleash Python’s Full Potential - Eliminate complexities and build everything—frontend and backend—in Python, seamlessly integrating any Python library.
-
🎨 Rich UI Library - Over 100 fully customizable built-in components for rapid UI development.
-
⚛️ Tap into React’s Power with Pythonic Wrappers - Harness the vast React ecosystem directly within Python, utilizing any React library without JavaScript knowledge.
-
🚀 Built-in Performance Optimizations - Deliver exceptional user experiences with automatic image, font, and script optimizations for lightning-fast loading speeds and responsiveness. See the difference for yourself at nextpy.org.
Better AI Generations: 🤖
-
🧠 More Effective Than Chaining or Prompt Engineering - Next.py aligns with LLM processing patterns, enabling precise output control and optimal model utilization.
-
💡 Optimized for Code Generation - Regardless of the LLMs, prompts, or fine-tuning used, the underlying app framework significantly impacts the efficiency of code generation. Next.py’s architecture is specifically engineered to maximize efficiency.
-
💾 Session State with LLM - Efficiently maintain state with LLMs, leveraging KV caches to convert multiple output tokens into prompt token batches. This approach reduces redundant generations, accelerating the handling of lengthy and intricate prompts. (only for open-source models)
-
🧪 Detect Syntax Errors: Test LLM-generated code, identifying and correcting LLM hallucinations, invalid Nextpy methods, and automatically generating prompts for seamless fixes.
Developer-First: ❤️
-
📘 Transferable Knowledge - Learning Next.py instills framework-agnostic fundamentals, enhancing your app development expertise and enabling you to excel across any frameworks.
-
🛠️ Extensible - If you know how to do something in Python or plain English, you can integrate it with nextpy.
🚀 Quick Start (3 mins)
1. Installing Nextpy
Open your terminal and prepare for an adventure of a lifetime!
(Remember, Python 3.7 or later is required.)
2. Initializing Your App
Navigate to the desired directory for your project in the terminal. Use the nextpy init
command to initialize a template app in your new directory.
3. Choose your template:
For now, just press enter to automatically default to the blank template.
4. Running the App
In the same directory where you previously ran nextpy init, enter the following command:
5. View the App:
Check out your app by visiting http://localhost:3000
[! NOTE]
Your application is now fully functional. To view the frontend, navigate to
localhost:3000
. The backend server is accessible atlocalhost:8000
.
While it’s unlikely you’ll ever directly interact with it, the backend API documentation can be found at
localhost:8000/docs
, and the openapi.json file is located atlocalhost:8000/openapi.json
.
🎨 Start with a template!
We speedup your development with a ever growing list of community templates. Some examples:
Setting Up the Template
-
Copy the template files to your local folder.
-
Install necessary dependencies with
pip install -r requirements.txt
. -
Initialize your app by running
nextpy init
. -
Launch the app with
nextpy run
to see it in action. To check the site visitlocalhost:3000
➖ or ➖
🤣 Building a Joke Generator App (5 mins)
Edit myapp/myapp.py
to create your app.
1. Import Libraries
Start by importing nextpy
for development and pyjokes
for random jokes.
2. Set Up the App State
Create a State
class with a joke
variable. Use generate_joke
to fetch new jokes.
3. Design the Main Page
The index
function arranges a joke display and a button. vstack
is used to stack components vertically, while hstack
is used to stack components horizontally.
4. Optional Styling
Set up the app, add the main page. To view the frontend, navigate to localhost:3000
.
🛣️ Project Roadmap
🌟 Upcoming Features
- Frontend Magic Components
- 🪄 PDF Resume to Personal Site: Create a “magic component” that converts PDF resumes into customizable, full-stack personal websites.
- Backend Modules
-
🔐 User Authentication and Email Integration: Add modules for robust login functionality and email subscription.
-
🛒 Modules for Blogging and E-commerce: Add backend modules to facilitate blog management and e-commerce webapps.
- Build and Performance Optimization
- 🔧 Compiler Enhancement with Rust or mojo: Transitioning our existing compiler to Rust or mojo to achieve faster performance.
- Generative AI
-
🐍 Nextpy LLM: Build the best Python LLM.
-
💬 End-User Copilot Feature: A chat-based copilot for app users that lets them interact with your product and do things by text. We have all the modules ready for this, we just need to simplify the abstraction. Just set
copilot = True
in xtconfig and you’re should be good to go.