Skip to content

Commit

Permalink
Nextpy ui refactor
Browse files Browse the repository at this point in the history
Refactor Frontend Structure and Component Abstractions
  • Loading branch information
anubrag authored Feb 25, 2024
2 parents abdd43a + e76fdf9 commit f9ab6ef
Show file tree
Hide file tree
Showing 639 changed files with 14,609 additions and 3,053 deletions.
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
> [!NOTE]
> Exciting news! Version 0.4 is coming soon, Backward compatible, with optional AI upgrade assistant (0.3.x to 0.4.x) for a smooth ride.
<div align="center">
<img src="https://res.cloudinary.com/doojikdqd/image/upload/v1705651891/nextpy_logo_light_theme_ijofia.svg#gh-light-mode-only" alt="Nextpy Logo" width="320px">

Expand Down Expand Up @@ -37,14 +34,11 @@
</p>
<br>

<a href="https://discord.gg/asTZktHrcH" target="blank">
<img alt="Discord" src="https://img.shields.io/discord/1111984809821089883?style=for-the-badge&logo=discord&logoColor=white&label=Live%20Support%20%26%20Coding%20Bots%20on%20Discord&labelColor=%23684DFF&link=https%3A%2F%2Fdiscord.gg%2FasTZktHrcH">

</a>

![-----------------------------------------------------](https://res.cloudinary.com/dzznkbdrb/image/upload/v1694798498/divider_1_rej288.gif)

<h3><i>Streamlit's simplicity (but 4-10x faster) + FastAPI's full power + (Pydantic & SQL Alchemy)'s robustness</i></h3>
<h3><i>Build ⚡Blazing Fast, 🤖Self-Modifying Apps in Pure Python!</i></h3>


```diff
Expand All @@ -53,9 +47,9 @@

</div>

## 🤩 Nextpy : Fast, Pure Pythonic Web Apps
## 🤩 Nextpy : Build apps that write themselves

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.
Build apps —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.

Expand Down Expand Up @@ -314,9 +308,9 @@ Initially, reflex's flexibility seemed promising, aligning with several of our r

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 a **full stack app starter kit** rather 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.
This framework combines Streamlit's simplicity with Next.js's speed and flexibility. For the backend, FastAPI's ease of use is enhanced by Pydantic's strong type-checking. The frontend utilizes Reflex, Reacton, and Solara libraries, enabling not just web app support but also GUI integration within Jupyter, adding new components seamlessly. We're currently refining our Python-to-JavaScript compiler for improved speed. SQLModel and SQLAlchemy have been integrated for database management. Additionally, we've tailored features for generative AI and introduced a JSON-based database, offering SQL-like functionalities with JSON as the storage format.

**Our mission?** Make Next.py the most efficient app framework, for humans and AI alike!
**Our mission?** Make Next.py the most efficient app framework, for building self writing applications!

Want to know more? Check out our manifesto! https://nextpy.org/manifesto/

Expand Down
5 changes: 4 additions & 1 deletion app-examples/gallery/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.db

*.py[cod]
.web

*.web

__pycache__/
2 changes: 1 addition & 1 deletion app-examples/mapping/mapping/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from typing import Dict, List, Tuple
import nextpy as xt
from nextpy.frontend.components.leaflet import (
from nextpy.interfaces.web.components.leaflet import (
map_container,
tile_layer,
marker,
Expand Down
54 changes: 38 additions & 16 deletions nextpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import importlib
from typing import Type

from nextpy.frontend.page import page as page
from nextpy.interfaces.web.page import page as page
from nextpy.utils import console
from nextpy.utils.format import to_snake_case



_ALL_COMPONENTS = [
"Accordion",
"AccordionButton",
Expand Down Expand Up @@ -61,6 +63,7 @@
"ColorModeButton",
"ColorModeIcon",
"ColorModeSwitch",
"ColorPicker",
"Component",
"Cond",
"ConnectionBanner",
Expand All @@ -86,6 +89,12 @@
"EditableTextarea",
"Editor",
"Email",
"Error",
"Expander",
"ExpanderButton",
"ExpanderIcon",
"ExpanderItem",
"ExpanderPanel",
"Fade",
"Flex",
"Foreach",
Expand All @@ -97,13 +106,15 @@
"Fragment",
"Grid",
"GridItem",
"Header",
"Heading",
"Highlight",
"Hstack",
"Html",
"Icon",
"IconButton",
"Image",
"Info",
"Input",
"InputGroup",
"InputLeftAddon",
Expand Down Expand Up @@ -158,12 +169,12 @@
"PopoverHeader",
"PopoverTrigger",
"Progress",
"Radio",
"RadioGroup",
"RangeSlider",
"RangeSliderTrack",
"RangeSliderFilledTrack",
"RangeSliderThumb",
"RangeSliderTrack",
"Radio",
"RadioGroup",
"ResponsiveGrid",
"ScaleFade",
"Script",
Expand Down Expand Up @@ -198,6 +209,7 @@
"StepStatus",
"StepTitle",
"Stepper",
"Success",
"Switch",
"Tab",
"TabList",
Expand All @@ -219,13 +231,15 @@
"Tfoot",
"Th",
"Thead",
"Title",
"Tooltip",
"Tr",
"UnorderedList",
"Upload",
"Video",
"VisuallyHidden",
"Vstack",
"Warning",
"Wrap",
"WrapItem",
]
Expand All @@ -246,6 +260,12 @@
"EditorButtonList",
"EditorOptions",
"NoSSRComponent",
"dataframe",
"empty",
'select_slider',
'select_slider_filled_track',
'select_slider_thumb',
'select_slider_track'
]

# _MAPPING: Maps module paths as keys to lists of their attributes (classes, functions, variables) as values for dynamic imports.
Expand Down Expand Up @@ -283,14 +303,15 @@
"nextpy.constants": ["Env", "constants"],
"nextpy.data.jsondb": ["JsonDatabase"],
"nextpy.data.model": ["Model", "model", "session"],
"nextpy.frontend.components": _ALL_COMPONENTS + ["chakra", "next"],
"nextpy.frontend.components.framer.motion": ["motion"],
"nextpy.frontend.components.component": ["memo"],
"nextpy.frontend.components.el": ["el"],
"nextpy.frontend.components.moment.moment": ["MomentDelta"],
"nextpy.frontend.page": ["page"],
"nextpy.frontend.style": ["color_mode", "style", "toggle_color_mode"],
"nextpy.frontend.components.recharts": [
"nextpy.interfaces.web.components": _ALL_COMPONENTS + ["chakra", "next"],
"nextpy.interfaces.web.components.framer.motion": ["motion"],
"nextpy.interfaces.web.components.component": ["memo"],
"nextpy.interfaces.web.components.el": ["el"],
"nextpy.interfaces.web.components.moment.moment": ["MomentDelta"],
"nextpy.interfaces.page": ["page"],
"nextpy.interfaces.web.components.proxy": ["animation", "unstyled"],
"nextpy.interfaces.web.style": ["color_mode", "style", "toggle_color_mode"],
"nextpy.interfaces.web.components.recharts": [
"area_chart", "bar_chart", "line_chart", "composed_chart", "pie_chart",
"radar_chart", "radial_bar_chart", "scatter_chart", "funnel_chart", "treemap",
"area", "bar", "line", "scatter", "x_axis", "y_axis", "z_axis", "brush",
Expand All @@ -300,7 +321,6 @@
"polar_angle_axis", "polar_grid", "polar_radius_axis",
],
"nextpy.utils": ["utils"],
"nextpy.frontend.components.proxy": ["animation"],
}


Expand Down Expand Up @@ -351,10 +371,12 @@ def __getattr__(name: str) -> Type:
"""
# Custom alias handling
if name == "animation":
module = importlib.import_module("nextpy.frontend.components.proxy")
module = importlib.import_module("nextpy.interfaces.web.components.proxy")
return module.animation


# Custom alias handling for 'unstyled'
if name == "unstyled":
return importlib.import_module("nextpy.interfaces.web.components.proxy.unstyled")
try:
# Check for import of a module that is not in the mapping.
if name not in _MAPPING:
Expand All @@ -371,4 +393,4 @@ def __getattr__(name: str) -> Type:
getattr(module, name) if name != _MAPPING[name].rsplit(".")[-1] else module
)
except ModuleNotFoundError:
raise AttributeError(f"module 'nextpy' has no attribute {name}") from None
raise AttributeError(f"module 'nextpy' has no attribute {name}") from None
Loading

0 comments on commit f9ab6ef

Please sign in to comment.