Skip to main content

The Python-Powered Fullstack Language

Project description

PyReact ๐Ÿš€

The Python-Powered Fullstack Language โ€” v1.2.0

Build beautiful AI-powered fullstack applications using a single language, a single file, and a single workflow.

PyReact = Python Simplicity + React Power + AI Native Development


Quick Start

# Install
pip install -e .

# Create new project
pyreact new myapp

# Start dev servers
cd myapp
pyreact dev

One File. Full Stack.

server {
    def forecast(data):
        return {"result": [1, 4, 9, 16]}
}

pages {
    Home      = "/"
    Dashboard = "/dashboard" [guard]
    Login     = "/login"
}

component Dashboard():
    result, setResult = use_state(None)

    def runForecast():
        data = server.forecast([])
        setResult(data)

    return (
        <UI.Page>
            <UI.Navbar title="PyReact App" />
            <UI.Button onClick={runForecast}>Run Forecast</UI.Button>
            <UI.Chart type="line" data={result} />
        </UI.Page>
    )

style {
    primary = "#6366f1"
    radius  = "16px"
}

Dikompilasi menjadi:

  • โœ… Flask backend dengan auto-generated REST endpoints
  • โœ… React frontend + Tailwind CSS + react-router-dom v6
  • โœ… PyBridgeโ„ข RPC โ€” zero fetch() / axios boilerplate
  • โœ… File-System Routing โ€” pages block & folder pages/
  • โœ… Vite production build

CLI Commands

Command Description
pyreact new <name> Create a new project
pyreact dev Start Flask + Vite dev servers
pyreact dev --heal Dev mode + AI self-healing
pyreact build Build for production
pyreact compile [file] Compile โ†’ Flask + React source
pyreact compile [file] --heal Compile + AI auto-heal error
pyreact compile [file] --heal --model codellama Pilih model Ollama
pyreact serve Serve production via Gunicorn/Waitress
pyreact generate component <Name> Scaffold a component
pyreact ai "<prompt>" Generate kode dengan AI lokal (gratis)
pyreact install <package> Install dari PPR Registry
pyreact hub Lihat Hub Marketplace templates
pyreact test Run backend + frontend tests

Fase 15: Self-Healing Compiler ๐Ÿฉบ

Ketika terjadi syntax error, PyReact bisa memperbaikinya secara otomatis via Ollama:

pyreact compile app.pyreact --heal
+==================================================+
|    PyReact Self-Healing Compiler  [Fase 15]     |
+==================================================+

[ERROR] Kompilasi gagal: Expected IDENTIFIER, got LBRACE '{'
[HEAL]  Model terpilih: gemma4:31b-cloud
[HEAL]  Mengirim ke Ollama (Percobaan 1/3)...
[HEAL]  Self-Healing BERHASIL pada percobaan ke-1!

[HEAL]  Perubahan:
  - component {
  + component MyComponent():

Fitur:

  • Auto-detect model Ollama terbaik (codellama โ†’ qwen2.5-coder โ†’ gemma4 โ†’ llama3)
  • Iterative retry hingga 3x
  • Diff viewer + backup otomatis
  • Rule-based fallback jika Ollama offline

Fase 16: File-System Routing ๐Ÿ—บ๏ธ

Pages Block (Explicit)

pages {
    Home      = "/"
    About     = "/about"
    Blog      = "/blog"
    Dashboard = "/dashboard" [guard]           # Protected route
    Settings  = "/settings"  [guard, layout=App] # Guard + Layout
    Login     = "/login"
}

File-System Routing (Next.js Style)

pages/
  index.pyreact          โ†’ /
  about.pyreact          โ†’ /about
  blog/index.pyreact     โ†’ /blog
  blog/[slug].pyreact    โ†’ /blog/:slug  (dynamic)
  user/[id].pyreact      โ†’ /user/:id    (dynamic)
  404.pyreact            โ†’ * (Not Found)

Output App.jsx:

<BrowserRouter>
  <Routes>
    <Route path="/"          element={<Home />} />
    <Route path="/dashboard" element={<RequireAuth><Dashboard /></RequireAuth>} />
    <Route path="/blog/:slug" element={<BlogSlug />} />
    <Route path="*"          element={<NotFound />} />
  </Routes>
</BrowserRouter>

Built-in UI Components (30+)

UI.Page      UI.Navbar    UI.Sidebar    UI.Card
UI.Button    UI.Input     UI.TextArea   UI.Select
UI.Table     UI.DataGrid  UI.Chart      UI.MetricCard
UI.Alert     UI.Toast     UI.Modal      UI.Spinner
UI.Badge     UI.Tabs      UI.Dropdown   UI.Accordion
UI.Calendar  UI.Upload    UI.Chatbot    UI.Heading
UI.Text      UI.Divider   UI.Link       UI.NavLink
UI.useAuth()

Compiler Architecture

app.pyreact
    โ”‚
    โ–ผ
 Lexer โ†’ Parser โ†’ AST โ†’ CodeGenerator
                          โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           Flask        React          Router
          backend      frontend     (react-router-dom v6)

Fase 15 โ€” Self-Healing: compiler/healer.py Fase 16 โ€” Routing Engine: compiler/router.py


Output Structure

dist/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py           โ† Flask application
โ”‚   โ”œโ”€โ”€ routes.py        โ† Auto-generated endpoints
โ”‚   โ”œโ”€โ”€ generated_api.py โ† server {} Python code
โ”‚   โ””โ”€โ”€ requirements.txt
โ””โ”€โ”€ frontend/
    โ”œโ”€โ”€ package.json     โ† Includes react-router-dom
    โ””โ”€โ”€ src/
        โ”œโ”€โ”€ App.jsx      โ† BrowserRouter + Routes
        โ”œโ”€โ”€ pybridge.js  โ† PyBridgeโ„ข RPC client
        โ”œโ”€โ”€ _routes.txt  โ† Router manifest
        โ””โ”€โ”€ ui/
            โ””โ”€โ”€ components.jsx

Demo

# Demo routing lengkap (Fase 16)
pyreact compile demo_routing.pyreact --out dist_routing

# Test self-healing (Fase 15) โ€” butuh Ollama berjalan
pyreact compile broken_demo.pyreact --heal

Roadmap

Fase Fitur Status
1โ€“14 Compiler, PyBridge, UI, Database, AI Agents, PPR โœ… Done
15 Self-Healing Compiler (Ollama) โœ… Done
16 File-System Routing & Pages Block โœ… Done
17 Type System & Validasi ๐Ÿ”ฒ Planned
18 Real-Time & WebSocket ๐Ÿ”ฒ Planned
19 Testing Framework ๐Ÿ”ฒ Planned
20 VSCode Extension ๐Ÿ”ฒ Planned
21 PyReact Cloud ๐Ÿ”ฒ Planned

License

MIT ยฉ Yuda Hasibuan

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

pyreact_web-0.1.0.tar.gz (96.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyreact_web-0.1.0-py3-none-any.whl (90.9 kB view details)

Uploaded Python 3

File details

Details for the file pyreact_web-0.1.0.tar.gz.

File metadata

  • Download URL: pyreact_web-0.1.0.tar.gz
  • Upload date:
  • Size: 96.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pyreact_web-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5babd7679abb7aaf8156917babf0cae4a0e60cd4d3af0428bababf6819f06afb
MD5 74f14fe35d62c034ba48dc9044344610
BLAKE2b-256 3c9166cdc4ad0b33a0d383f1862fb6b7eed2b75aa9b8c8f700d72b2d847e18e8

See more details on using hashes here.

File details

Details for the file pyreact_web-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyreact_web-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 90.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pyreact_web-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 039735529e20efd4e9488c09f92667163e5926d88890a88e1855ef818afacbf5
MD5 f55c120190da2775d04133b9ce78bc58
BLAKE2b-256 7beb346d9716c36858c1bd37126c75c8ce85a765c18375174daa8e1ee6b7a10c

See more details on using hashes here.

Supported by

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