HOW REFLEX
ACTUALLY WORKS
Build full-stack web apps in pure Python. Conventions, patterns, and architecture extracted from the reflex-dev/reflex repository by sourcebook.
WHAT_MATTERS
-
→
FastAPI project — use Pydantic models for request/response schemas, not raw dicts
-
→
reflex/__init__.py is a hub file (imported by 53 files) — changes here ripple everywhere
-
→
This is both a monorepo and a publishable library — check workspace dependencies and avoid breaking the public API
KEY_FINDINGS
FastAPI project. Use Pydantic models for request/response schemas, not raw dicts.
HIGHUses SQLAlchemy/SQLModel for ORM. Database sessions must be properly closed (use dependency injection).
HIGHUses pytest. Test files should be named test_*.py or *_test.py.
HIGH16 test files
This is a monorepo. Changes may affect multiple packages.
HIGHTests live in a separate test/ directory, mirroring src/ structure. New tests go there, not next to source files.
HIGHThis is a publishable library. Focus changes on the public API surface.
HIGHUses __init__.py as barrel exports. Import from the package, not from internal modules.
HIGH14 non-empty __init__.py files
Use @dataclass for data structures.
HIGH14 files use dataclasses
Database access uses SQLAlchemy. Look for schemas in models/.
HIGH2 files
UI components live in: docs/app/assets/components.
HIGH1 component directory
Hub files: reflex/__init__.py (53 files); reflex/vars/base.py (33 files); reflex/utils/__init__.py (29 files); reflex/components/component.py (29 files); reflex/event.py (22 files). Changes here have the widest blast radius.
HIGHCircular imports: experimental/__init__.py; reflex_components_react_player/__init__.py; el/__init__.py. Avoid adding to these cycles.
HIGH