$ show pydantic/FastUI
FastUI is a Python/TypeScript framework for building web UIs declaratively from Python code, using React as the frontend renderer. The backend defines the entire UI as a list of Pydantic-validated component models, which are sent to the frontend via a REST API. The frontend (React) receives these component definitions and renders them using Bootstrap or custom components. The architecture enforces a strict separation of concerns: the backend describes the interface, the frontend implements the rendering. The project includes a Python package (fastui) with component models, form generation, authentication helpers, and a dev server; three npm packages (@pydantic/fastui, @pydantic/fastui-bootstrap, @pydantic/fastui-prebuilt) for the React frontend; and a demo application. The code is well-structured, fully typed, and includes comprehensive tests. However, the project has been officially declared inactive (see issue #368), so no further development is expected. The codebase remains functional and is a good example of declarative UI patterns, but reuse should account for the lack of ongoing maintenance.
The LLM identified 4 files worth highlighting for reuse:
Provides the `FormFile` class, a custom Pydantic annotation that validates file uploads (size, content type, extension) and integrates with FastAPI's dependency injection. Also includes `fastui_form` to convert form data into Pydantic models. The `unflatten` function efficiently reconstructs nested dicts from flat form data. This module is a self-contained, reusable pattern for file validation and form handling in FastAPI.
Implements a complete GitHub OAuth authentication provider with state management via JWT, caching of access token exchanges, and methods to fetch user info and emails. The `GitHubAuthProvider` class is fully self-contained, requiring only an httpx client and credentials. It can be reused in any FastAPI (or similar) application with minimal adaptation.
Converts Pydantic model JSON schemas into a list of form field components (FormFieldInput, FormFieldSelect, etc.). Handles nested models, tuples, enums, file uploads, and textareas. The logic is complex but well-encapsulated; the `model_json_schema_to_fields` function is the main entry point. This module is the core of the `ModelForm` component and could be extracted to auto-generate forms from any Pydantic model.
Provides a flexible class name generation system for React components. The `useClassName` hook merges backend-provided class names with generator-produced class names, supporting string, array, and object formats. The `renderClassName` utility normalizes class names. This pattern enables themeable, customizable components without tight coupling to any CSS framework. It is a standalone, reusable piece of React infrastructure.