@@ -54,8 +54,11 @@ uv pip install myfy-core
5454# Core + Web (for HTTP APIs)
5555uv pip install myfy-core myfy-web
5656
57- # Everything
57+ # Core + Web + CLI
5858uv pip install myfy-core myfy-web myfy-cli
59+
60+ # Full-stack with frontend
61+ uv pip install myfy-core myfy-web myfy-cli myfy-frontend
5962```
6063
6164---
@@ -119,6 +122,114 @@ Visit `http://127.0.0.1:8000/` - you should see:
119122
120123---
121124
125+ ## Example: Full-Stack App with Frontend
126+
127+ Want to build a web app with UI? Add the frontend module:
128+
129+ ### 1. Install with Frontend Support
130+
131+ ``` bash
132+ uv pip install myfy-core myfy-web myfy-cli myfy-frontend
133+ ```
134+
135+ ### 2. Create ` app.py `
136+
137+ ``` python
138+ from myfy.core import Application, BaseSettings
139+ from myfy.web import route, WebModule
140+ from myfy.frontend import FrontendModule, render_template
141+
142+
143+ class Settings (BaseSettings ):
144+ app_name: str = " My Web App"
145+
146+
147+ @route.get (" /" )
148+ async def home ():
149+ return render_template(
150+ " home.html" ,
151+ title = " Welcome" ,
152+ message = " Hello from myfy!"
153+ )
154+
155+
156+ @route.get (" /api/hello" )
157+ async def api_hello () -> dict :
158+ return {" message" : " Hello from API!" }
159+
160+
161+ app = Application(settings_class = Settings, auto_discover = False )
162+ app.add_module(WebModule())
163+ app.add_module(FrontendModule())
164+
165+
166+ if __name__ == " __main__" :
167+ import asyncio
168+ asyncio.run(app.run())
169+ ```
170+
171+ ### 3. Initialize Frontend
172+
173+ ``` bash
174+ # Initialize frontend (creates templates, CSS, JS)
175+ uv run myfy frontend init
176+ ```
177+
178+ This creates:
179+ ```
180+ my-app/
181+ ├── frontend/
182+ │ ├── css/
183+ │ │ └── input.css # Tailwind CSS
184+ │ ├── js/
185+ │ │ └── main.js # JavaScript entry
186+ │ ├── templates/
187+ │ │ ├── base.html # Base layout
188+ │ │ └── home.html # Home page
189+ │ └── static/
190+ │ └── dist/ # Built assets
191+ ├── package.json # Node dependencies
192+ ├── vite.config.js # Vite config
193+ └── app.py
194+ ```
195+
196+ ### 4. Create ` frontend/templates/home.html `
197+
198+ ``` jinja2
199+ {% extends "base.html" %}
200+
201+ {% block title %}{{ title }}{% endblock %}
202+
203+ {% block content %}
204+ <div class="hero min-h-screen bg-gradient-to-r from-primary to-secondary">
205+ <div class="hero-content text-center text-neutral-content">
206+ <div class="max-w-md">
207+ <h1 class="mb-5 text-5xl font-bold">{{ message }}</h1>
208+ <p class="mb-5">
209+ Build modern web apps with Python backend and beautiful UI.
210+ </p>
211+ <button class="btn btn-accent">Get Started</button>
212+ </div>
213+ </div>
214+ </div>
215+ {% endblock %}
216+ ```
217+
218+ ### 5. Run Your App
219+
220+ ``` bash
221+ uv run myfy run
222+ ```
223+
224+ Visit ` http://127.0.0.1:8000/ ` to see your app with:
225+ - ** Server-side rendering** with Jinja2
226+ - ** Tailwind CSS 4** for styling
227+ - ** DaisyUI 5** components
228+ - ** Vite** for hot module replacement
229+ - ** Dark mode** built-in
230+
231+ ---
232+
122233## Project Structure
123234
124235For larger applications, we recommend this structure:
0 commit comments