Package: nextpy
繁體中文.简体中文.Français·German·Italiano·Português·Tamil·Ukrainian·русский·عربي·Español·हिंदी·Türkçe·한국어Streamlit's simplicity (but 4-10x faster) + FastAPI's full power + (Pydantic & SQL Alchemy)'s robustness+ 🤖 Searching for 'OpenAMS' or 'OpenAgent'? They're now seamlessly integrated into Nextpy. +🤩 Nextpy : Fast, Pure Pythonic Web AppsBuild 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 underlying frameworks 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, dashboards, portals, data apps, internal tools, APIs etc.📚& The best part? Transferable Knowledge:Building with nextpyprogressivelyteaches you framework-agnostic fundamentals and the best python libraries- FastAPI, Pydantic, SQLModel, Pandas, Jinja2, SQLAlchemy, etc.⚡4-10x faster than Streamlit:Our compiled app achieves a staggering 4-10x performance leap over Streamlit. See the difference for yourself atnextpy.org, boasting a PageSpeed score of 99/100💡 Key FeaturesSimplifying 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 librarywithout 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 atnextpy.org.👁️‍🗨️ Accessibility Out of the Box- Achieving accessibility can be complex. We've selected the best UI React components, like Radix, to ensure accessibility is a standard feature, not an afterthought.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 teaches you framework-agnostic fundamentals and the best Python libraries, improving your python development expertise and enabling you to excel across any framework.🛠️ 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 NextpyOpen your terminal and prepare for an adventure of a lifetime!pipinstallnextpy(Remember, Python 3.7 or later is required.)2. Initializing Your AppNavigate to the desired directory for your project in the terminal. Use thenextpy initcommand to initialize a template app in your new directory.nextpyinit3. Choose your template:For now, just press enter to automatically default to the blank template.Blank Template: A simple single page template
    Base Template: A multi-page app with a sidebar4. Running the AppIn the same directory where you previously ran nextpy init, enter the following command:nextpyrun5. View the App:Check out your app by visitinghttp://localhost:3000[!NOTE]
Your application is now fully functional. To view the frontend, navigate tolocalhost: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 atlocalhost:8000/docs, and the openapi.json file is located atlocalhost:8000/openapi.json.🎨 Start with a template!We speedup your development with aever growing list of community templates. Some examples:Powerful tablesPortfolio SitesInteractive ChartsAI chatCrud AppsOnboardingSetting Up the TemplateCopy the template files to your local folder.Install necessary dependencies withpip install -r requirements.txt.Initialize your app by runningnextpy init.Launch the app withnextpy runto see it in action. To check the site visitlocalhost:3000➖ or ➖🤣 Building a Joke Generator App (5 mins)Editmyapp/myapp.pyto create your app.1. Import LibrariesimportnextpyasxtimportpyjokesStart by importingnextpyfor development andpyjokesfor random jokes.2. Set Up the App StateclassState(xt.State):joke:str="Click the button to get a joke!"defgenerate_joke(self):self.joke=pyjokes.get_joke()Create aStateclass with ajokevariable. Usegenerate_joketo fetch new jokes.3. Design the Main Pagedefindex():layout=xt.vstack(xt.text(State.joke,font_size="2em"),xt.button("Generate Joke",on_click=State.generate_joke),)returnlayoutTheindexfunction arranges a joke display and a button.vstackis used to stack components vertically, whilehstackis used to stack components horizontally.4. Optional Stylingdef index():
    layout = xt.vstack(
        xt.text(State.joke, font_size="2em"),
        xt.button("Generate Joke", on_click=State.generate_joke),

        spacing="1em",
        align_items="center",
        justify_content="center",
        height="100vh",
   )
    return layoutThespacingattribute adds space between thetextandbuttonelements, whilealign_itemsandjustify_contentensure that these elements are centered. The stack'sheightis set to 100% of the Viewport Height (100vh), which allows the vertical stack to fill the entire height of your screen.5. Setup the appapp=xt.App()app.add_page(index)Set up the app, add the main page. To view the frontend, navigate tolocalhost:3000.🛣️ Project Roadmap🌟 Upcoming FeaturesFrontend 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 setcopilot = Truein xtconfig and you’re should be good to go.🤗 Get InvolvedWe welcome contributors of all skill levels! 🤝Want to make a difference? Start by forking our repository and sending in your pull requests. We're excited to welcome you to our community. Together, we'll craft something truly remarkable! ✨Why another framework?In our quest to create apps that write themselves, we delved deep into a labyrinth of coding tools, frameworks, and libraries. Our experiments spanned all major large language models (LLMs), thousands of prompts, and every major web development framework, from React to Streamlit.Insight[!TIP]
We found that the choice of the foundational app framework significantly influences code generation efficiency, irrespective of the LLMs, prompts, or fine-tuning methods.Initially, reflex's flexibility seemed promising, aligning with several of our requirements. However, as we experimented with different web apps, crucial feature gaps emerged. Bridging these gaps necessitated extensive "glue code," which dramatically slowed down development.For months, we resisted the urge to reinvent the wheel and tried to assemble different tools to bring our vision to life. Instead of creating a framework from scratch, we aimed to create an opinionated app starter kit by selectively incorporating the best features from top frameworks. Although we still view this project as afull stack app starter kitrather than a framework, the distinction is becoming somewhat blurred as we have developed several custom modules and made specific design decisions.This novel framework merges the simplicity of Streamlit with the speed and adaptability of Next.js. For the backend, we opted for FastAPI for its simplicity, coupled with Pydantic for robust type-checking. Our frontend was crafted using a tailored version of the Reflex library, incorporating new components. Currently, we are in the process of overhauling the core Python-to-JavaScript compiler to optimize speed. Additionally, we embraced SQLModel & SQLAlchemy for database connectivity. Furthermore, we have developed selected features specifically for generative AI. We have created a JSON-based database that uses JSON as the data storage medium, while also providing SQL-like capabilities.Our mission?Make Next.py the most efficient app framework, for humans and AI alike!Want to know more? Check out our manifesto!https://nextpy.org/manifesto/🙏 ThanksNextpy Framework is a state-of-the-art app development framerwork optimized for AI-based code generation, built on the open-source community’s spirit of cooperation. It integrates key components from landmark projects like Guidance, Llama-Index, FastAPI-Mail, LangChain, ReactPy, Reflex, Chakra, Radix, Numpy and Next.js, while also drawing insights from the React and Rust ecosystems. This fusion ideas has been pivotal in shaping Nextpy into a framework that's not just AI-friendly but also a trailblazer in generative web development tools.We are deeply grateful to the open-source creators, contributors, and maintainers whose work has provided the basis for Nextpy. Your commitment to innovation and openness has been vital for shaping this framework. Your contributions have not only enhanced Nextpy but are also advancing the new era of AI-powered software development. Thank you for being the catalysts and enablers of this transformational journey.