uigen 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
uigen-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SaadEddine-ware
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
uigen-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,453 @@
1
+ Metadata-Version: 2.4
2
+ Name: uigen
3
+ Version: 0.1.0
4
+ Summary: Write UI logic once, deploy anywhere — generate HTML, React, Flask, and Django UIs from Python.
5
+ Author-email: Your Name <you@example.com>
6
+ License: MIT
7
+ Keywords: ui,frontend,code-generation,html,react,flask,django
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Code Generators
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7.0; extra == "dev"
21
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
22
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
23
+ Requires-Dist: mypy>=1.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # uigen
27
+
28
+ **Write UI logic once, deploy anywhere.**
29
+
30
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
32
+ [![Tests](https://img.shields.io/badge/tests-88%20passing-brightgreen.svg)](#testing)
33
+ [![GitHub Stars](https://img.shields.io/github/stars/SaadEddine-ware/uigen.svg?style=social)](https://github.com/SaadEddine-ware/uigen)
34
+
35
+ ---
36
+
37
+ ## Demo
38
+
39
+ ### The Problem
40
+
41
+ Backend devs need to build UIs but hate writing HTML. A simple table takes 35+ lines:
42
+
43
+ ```html
44
+ <!-- 35+ lines of HTML for a basic table -->
45
+ <div class="bg-white rounded-lg shadow-md p-6">
46
+ <h2 class="text-2xl font-semibold text-gray-900 mb-4">Users</h2>
47
+ <table class="w-full">
48
+ <thead>
49
+ <tr class="border-b border-gray-200">
50
+ <th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Name</th>
51
+ <th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Email</th>
52
+ <th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Role</th>
53
+ </tr>
54
+ </thead>
55
+ <tbody>
56
+ <tr class="border-t border-gray-200">
57
+ <td class="px-4 py-2 text-sm text-gray-600">Alice Johnson</td>
58
+ <td class="px-4 py-2 text-sm text-gray-600">alice@example.com</td>
59
+ <td class="px-4 py-2 text-sm text-gray-600">admin</td>
60
+ </tr>
61
+ <tr class="border-t border-gray-200">
62
+ <td class="px-4 py-2 text-sm text-gray-600">Bob Smith</td>
63
+ <td class="px-4 py-2 text-sm text-gray-600">bob@example.com</td>
64
+ <td class="px-4 py-2 text-sm text-gray-600">viewer</td>
65
+ </tr>
66
+ </tbody>
67
+ </table>
68
+ <button class="mt-4 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
69
+ Add User
70
+ </button>
71
+ </div>
72
+ ```
73
+
74
+ ### The Solution
75
+
76
+ Write 15 lines of Python instead:
77
+
78
+ ```python
79
+ from uigen import App, Model, ui
80
+
81
+ class User(Model):
82
+ name: str
83
+ email: str
84
+ role: str = "viewer"
85
+
86
+ page = ui.page(
87
+ ui.card(
88
+ ui.heading("Users"),
89
+ ui.table(data=[
90
+ {"name": "Alice Johnson", "email": "alice@example.com", "role": "admin"},
91
+ {"name": "Bob Smith", "email": "bob@example.com", "role": "viewer"},
92
+ ]),
93
+ ui.button("Add User"),
94
+ ),
95
+ title="User Management",
96
+ )
97
+
98
+ app = App(title="My App", pages=[page])
99
+ app.render("lnative", output="./dist")
100
+ ```
101
+
102
+ ### The Result
103
+
104
+ Same output. **57% less code.**
105
+
106
+ ```
107
+ ┌─────────────────────────────────────────────────────────┐
108
+ │ Metric HTML Python (uigen) │
109
+ ├─────────────────────────────────────────────────────────┤
110
+ │ Lines of code 35+ 15 │
111
+ │ Characters ~1,500 ~500 │
112
+ │ Time to write 10-15 min 2-3 min │
113
+ │ Reduction — 57% │
114
+ └─────────────────────────────────────────────────────────┘
115
+ ```
116
+
117
+ <!-- [![Demo](https://github.com/SaadEddine-ware/uigen/raw/main/docs/demo.gif)](https://github.com/SaadEddine-ware/uigen/raw/main/docs/demo.gif) -->
118
+
119
+ *Run `python examples/demo.py` to see the full transformation*
120
+
121
+ ---
122
+
123
+ ## What is uigen?
124
+
125
+ uigen is a Python library that lets backend developers define UIs using Python functions, then generate production-ready frontend code for multiple targets.
126
+
127
+ **Stop writing HTML boilerplate. Start writing Python.**
128
+
129
+ ### The Problem
130
+
131
+ Backend devs constantly need to build admin panels, dashboards, or simple web UIs. But setting up React, writing HTML, configuring Tailwind — it's a different world. A simple table takes 100+ lines of HTML.
132
+
133
+ ### The Solution
134
+
135
+ Write Python functions that generate clean, production-ready HTML, React, Flask, or Django code. The generated code is yours — edit it freely after generation.
136
+
137
+ ---
138
+
139
+ ## Features
140
+
141
+ - **Pythonic API** — Define UIs using familiar Python syntax
142
+ - **Multiple Renderers** — Generate HTML, React, Flask, or Django code
143
+ - **Model System** — Define data schemas that auto-generate forms and tables
144
+ - **Component Library** — Cards, tables, forms, modals, grids, and more
145
+ - **CLI Support** — Initialize projects and generate code from the command line
146
+ - **No Runtime Dependency** — Generated code is standalone, you own it
147
+ - **Fast** — C-powered template engine for blazing fast generation
148
+
149
+ ---
150
+
151
+ ## Renderers
152
+
153
+ | Renderer | Status | Output | Best For |
154
+ |----------|--------|--------|----------|
155
+ | `lnative` | Ready | Static HTML/CSS/JS | Landing pages, admin panels |
156
+ | `lreact` | Ready | React components | Complex SPAs |
157
+ | `lflask` | Ready | Flask/Jinja2 templates | Python web apps |
158
+ | `ldjango` | Ready | Django templates | Enterprise apps |
159
+
160
+ ---
161
+
162
+ ## Installation
163
+
164
+ ```bash
165
+ pip install uigen
166
+ ```
167
+
168
+ Or from source:
169
+
170
+ ```bash
171
+ git clone https://github.com/SaadEddine-ware/uigen.git
172
+ cd uigen
173
+ pip install -e ".[dev]"
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Quick Start
179
+
180
+ ### 1. Create a Project
181
+
182
+ ```bash
183
+ uigen init my-app
184
+ cd my-app
185
+ ```
186
+
187
+ ### 2. Edit `main.py`
188
+
189
+ ```python
190
+ from uigen import App, Model, ui
191
+
192
+ class Product(Model):
193
+ name: str
194
+ price: float
195
+ category: str
196
+
197
+ page = ui.page(
198
+ ui.card(
199
+ ui.heading("Products"),
200
+ ui.table(data=[
201
+ {"name": "Laptop", "price": 999.99, "category": "Electronics"},
202
+ {"name": "Mouse", "price": 29.99, "category": "Accessories"},
203
+ ]),
204
+ ),
205
+ title="Product Catalog",
206
+ )
207
+
208
+ app = App(title="My Store", pages=[page])
209
+ ```
210
+
211
+ ### 3. Generate
212
+
213
+ ```bash
214
+ python main.py
215
+ # or
216
+ uigen generate --renderer lnative --output ./dist
217
+ ```
218
+
219
+ ### 4. Preview
220
+
221
+ Open `dist/index.html` in your browser.
222
+
223
+ ---
224
+
225
+ ## Themes
226
+
227
+ uigen includes a theme customization system with built-in themes:
228
+
229
+ ```python
230
+ from uigen import App, ui, get_theme, list_themes
231
+
232
+ # List available themes
233
+ print(list_themes()) # ['default', 'dark', 'emerald', 'purple', 'rose']
234
+
235
+ # Use a theme
236
+ app = App(title="My App", pages=[page], theme="emerald")
237
+ app.render("lnative", output="./dist")
238
+ ```
239
+
240
+ ### Built-in Themes
241
+
242
+ | Theme | Primary Color | Use Case |
243
+ |-------|--------------|----------|
244
+ | `default` | Blue | General purpose |
245
+ | `dark` | Blue | Dark mode interfaces |
246
+ | `emerald` | Green | Success, nature, finance |
247
+ | `purple` | Purple | Creative, luxury |
248
+ | `rose` | Rose | Fashion, beauty |
249
+
250
+ ### Custom Themes
251
+
252
+ ```python
253
+ from uigen import Theme, register_theme, ColorPalette
254
+
255
+ # Create a custom theme
256
+ custom = Theme(
257
+ name="my-brand",
258
+ colors=ColorPalette(
259
+ primary="indigo",
260
+ primary_500="#6366f1",
261
+ primary_600="#4f46e5",
262
+ primary_700="#4338ca",
263
+ ),
264
+ )
265
+
266
+ # Register and use it
267
+ register_theme("my-brand", custom)
268
+ app = App(title="My App", pages=[page], theme="my-brand")
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Components
274
+
275
+ uigen provides a rich set of UI components:
276
+
277
+ ```python
278
+ # Layout
279
+ ui.page(...) # Top-level page container
280
+ ui.card(...) # Card with shadow and padding
281
+ ui.grid(..., columns=3) # Grid layout
282
+ ui.stack(..., spacing="md") # Vertical stack
283
+
284
+ # Content
285
+ ui.heading("Title", level=1) # Headings (h1-h6)
286
+ ui.text("Paragraph text") # Paragraph text
287
+
288
+ # Interactive
289
+ ui.button("Click me", variant="primary") # Buttons
290
+ ui.modal(...) # Modal dialogs
291
+ ui.form(...) # Form containers
292
+
293
+ # Data
294
+ ui.table(data=[...], columns=["name", "email"]) # Data tables
295
+ ui.input("email", label="Email", type="email") # Form inputs
296
+ ui.select("role", options=["admin", "user"]) # Dropdowns
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Model System
302
+
303
+ Define data schemas that auto-generate forms and tables:
304
+
305
+ ```python
306
+ from uigen import Model
307
+
308
+ class User(Model):
309
+ name: str
310
+ email: str
311
+ role: str = "viewer"
312
+ active: bool = True
313
+
314
+ # Use in tables
315
+ ui.table(data=users, columns=User.field_names())
316
+
317
+ # Auto-generate forms
318
+ ui.form(
319
+ ui.input("name", label="Name"),
320
+ ui.input("email", label="Email", type="email"),
321
+ ui.select("role", options=["admin", "editor", "viewer"]),
322
+ )
323
+ ```
324
+
325
+ ---
326
+
327
+ ## CLI Commands
328
+
329
+ ```bash
330
+ # Initialize a new project
331
+ uigen init my-project
332
+
333
+ # Generate frontend code
334
+ uigen generate --renderer lnative --output ./dist
335
+
336
+ # List available renderers
337
+ uigen renderers
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Architecture
343
+
344
+ ```
345
+ uigen/
346
+ ├── src/uigen/
347
+ │ ├── core/
348
+ │ │ ├── schema.py # Model system
349
+ │ │ ├── components.py # UI components
350
+ │ │ ├── api.py # ui namespace
351
+ │ │ └── compiler.py # App compilation
352
+ │ ├── renderers/
353
+ │ │ ├── base.py # Abstract renderer
354
+ │ │ ├── lnative.py # HTML/CSS/JS generator
355
+ │ │ ├── lreact.py # React generator
356
+ │ │ ├── lflask.py # Flask generator
357
+ │ │ └── ldjango.py # Django generator
358
+ │ └── cli.py # Command-line interface
359
+ ├── tests/
360
+ ├── examples/
361
+ └── pyproject.toml
362
+ ```
363
+
364
+ ---
365
+
366
+ ## Examples
367
+
368
+ See the [`examples/`](examples/) directory for complete examples:
369
+
370
+ - [`dashboard.py`](examples/dashboard.py) — Admin dashboard with stats, tables, and modals
371
+ - [`perfume_store.py`](examples/perfume_store.py) — E-commerce perfume store website
372
+
373
+ ### Perfume Store Demo
374
+
375
+ A complete perfume store with:
376
+ - Home page with hero section, featured products, and newsletter
377
+ - Shop page with product grid and filters
378
+ - About page with story, values, and contact form
379
+
380
+ ```bash
381
+ cd examples
382
+
383
+ # Generate static HTML
384
+ python perfume_store.py lnative
385
+
386
+ # Generate React app
387
+ python perfume_store.py lreact
388
+
389
+ # Generate Flask app
390
+ python perfume_store.py lflask
391
+
392
+ # Generate Django app
393
+ python perfume_store.py ldjango
394
+ ```
395
+
396
+ ---
397
+
398
+ ## Testing
399
+
400
+ ```bash
401
+ # Run all tests
402
+ pytest
403
+
404
+ # Run with coverage
405
+ pytest --cov=uigen
406
+
407
+ # Run specific test file
408
+ pytest tests/test_core.py -v
409
+ ```
410
+
411
+ ---
412
+
413
+ ## Roadmap
414
+
415
+ - [x] Core API and Model system
416
+ - [x] `lnative` renderer (HTML/CSS/JS)
417
+ - [x] `lreact` renderer (React)
418
+ - [x] `lflask` renderer (Flask)
419
+ - [x] `ldjango` renderer (Django)
420
+ - [x] CLI support
421
+ - [x] Theme customization (5 built-in themes)
422
+ - [x] C extension for HTML escaping
423
+ - [x] Tests (88 passing)
424
+ - [x] Examples (dashboard, perfume store)
425
+ - [ ] More components (charts, calendars, etc.)
426
+ - [ ] VS Code extension
427
+ - [ ] Demo GIF recording
428
+
429
+ ---
430
+
431
+ ## Contributing
432
+
433
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
434
+
435
+ ---
436
+
437
+ ## License
438
+
439
+ This project is licensed under the MIT License — see [LICENSE](LICENSE) for details.
440
+
441
+ ---
442
+
443
+ ## Author
444
+
445
+ **SaadEddine-ware** — [GitHub](https://github.com/SaadEddine-ware)
446
+
447
+ ---
448
+
449
+ ## Acknowledgments
450
+
451
+ - Built with Python 3.10+
452
+ - Styled with [Tailwind CSS](https://tailwindcss.com/)
453
+ - Inspired by the need for simpler frontend tooling for backend developers