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_fullstack_framework-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_fullstack_framework-0.1.0-py3-none-any.whl (91.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pyreact_fullstack_framework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e947e0e5b07ffce60edce3ce6172ee57f5e297b30da8142d11d90c73fe9031e8
MD5 513a206cd1207f5d229513c7d470d80f
BLAKE2b-256 ea20be852641d660121221a97bce0722098a803a926ebbf28b3911f822ed8b54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreact_fullstack_framework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e92fb6a621073213a862d37c98dbf958615b93e39b411d0724cd99f5fa4f17c
MD5 8847442c95886de70dd61bd0b858277d
BLAKE2b-256 db2a27c6665f6bf8a75ed0dda4d7e2ee939a4e4aea7590a761bf34551b8fc19f

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