faststudio 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.
- faststudio-0.1.0/.gitignore +40 -0
- faststudio-0.1.0/CHANGELOG.md +173 -0
- faststudio-0.1.0/LICENSE +21 -0
- faststudio-0.1.0/PKG-INFO +236 -0
- faststudio-0.1.0/README.md +199 -0
- faststudio-0.1.0/examples/basic/README.md +53 -0
- faststudio-0.1.0/hatch_build.py +34 -0
- faststudio-0.1.0/pyproject.toml +163 -0
- faststudio-0.1.0/src/faststudio/__init__.py +26 -0
- faststudio-0.1.0/src/faststudio/_spa.py +163 -0
- faststudio-0.1.0/src/faststudio/admin.py +227 -0
- faststudio-0.1.0/src/faststudio/api/__init__.py +1 -0
- faststudio-0.1.0/src/faststudio/api/_app.py +52 -0
- faststudio-0.1.0/src/faststudio/api/_context.py +31 -0
- faststudio-0.1.0/src/faststudio/api/_deps.py +31 -0
- faststudio-0.1.0/src/faststudio/api/_paths.py +4 -0
- faststudio-0.1.0/src/faststudio/api/_records.py +28 -0
- faststudio-0.1.0/src/faststudio/api/_serialize.py +180 -0
- faststudio-0.1.0/src/faststudio/api/auth.py +135 -0
- faststudio-0.1.0/src/faststudio/api/errors.py +176 -0
- faststudio-0.1.0/src/faststudio/api/models.py +95 -0
- faststudio-0.1.0/src/faststudio/api/write.py +159 -0
- faststudio-0.1.0/src/faststudio/auth/__init__.py +0 -0
- faststudio-0.1.0/src/faststudio/auth/backend.py +70 -0
- faststudio-0.1.0/src/faststudio/auth/cookies.py +70 -0
- faststudio-0.1.0/src/faststudio/auth/csrf.py +47 -0
- faststudio-0.1.0/src/faststudio/auth/model_backend.py +207 -0
- faststudio-0.1.0/src/faststudio/auth/passwords.py +88 -0
- faststudio-0.1.0/src/faststudio/auth/session.py +78 -0
- faststudio-0.1.0/src/faststudio/config.py +123 -0
- faststudio-0.1.0/src/faststudio/exceptions.py +15 -0
- faststudio-0.1.0/src/faststudio/introspection/__init__.py +1 -0
- faststudio-0.1.0/src/faststudio/introspection/_columns.py +102 -0
- faststudio-0.1.0/src/faststudio/introspection/_fields.py +271 -0
- faststudio-0.1.0/src/faststudio/introspection/_types.py +106 -0
- faststudio-0.1.0/src/faststudio/model_admin.py +89 -0
- faststudio-0.1.0/src/faststudio/py.typed +0 -0
- faststudio-0.1.0/src/faststudio/query/__init__.py +5 -0
- faststudio-0.1.0/src/faststudio/query/_list.py +108 -0
- faststudio-0.1.0/src/faststudio/query/_params.py +150 -0
- faststudio-0.1.0/src/faststudio/query/_write.py +44 -0
- faststudio-0.1.0/src/faststudio/registry.py +579 -0
- faststudio-0.1.0/src/faststudio/schemas/__init__.py +1 -0
- faststudio-0.1.0/src/faststudio/schemas/_dynamic.py +209 -0
- faststudio-0.1.0/src/faststudio/schemas/_meta.py +101 -0
- faststudio-0.1.0/src/faststudio/schemas/contract.py +240 -0
- faststudio-0.1.0/src/faststudio/schemas/contract.schema.json +674 -0
- faststudio-0.1.0/src/faststudio/security/__init__.py +0 -0
- faststudio-0.1.0/src/faststudio/security/csrf.py +104 -0
- faststudio-0.1.0/src/faststudio/security/headers.py +60 -0
- faststudio-0.1.0/src/faststudio/security/origin.py +86 -0
- faststudio-0.1.0/src/faststudio/security/rate_limit.py +103 -0
- faststudio-0.1.0/src/faststudio/security/secret.py +133 -0
- faststudio-0.1.0/src/faststudio/static/assets/ListPage-_dV1b5eQ.js +1 -0
- faststudio-0.1.0/src/faststudio/static/assets/RecordPages-DqN2e2EH.js +1 -0
- faststudio-0.1.0/src/faststudio/static/assets/index-BQwHVfIa.js +66 -0
- faststudio-0.1.0/src/faststudio/static/assets/index-Ch4jsWay.css +2 -0
- faststudio-0.1.0/src/faststudio/static/assets/query-56TKFQKO.js +1 -0
- faststudio-0.1.0/src/faststudio/static/index.html +14 -0
- faststudio-0.1.0/tests/__init__.py +0 -0
- faststudio-0.1.0/tests/_stubs.py +29 -0
- faststudio-0.1.0/tests/conftest.py +50 -0
- faststudio-0.1.0/tests/e2e/__init__.py +0 -0
- faststudio-0.1.0/tests/e2e/conftest.py +8 -0
- faststudio-0.1.0/tests/e2e/test_wheel_smoke.py +108 -0
- faststudio-0.1.0/tests/factories/__init__.py +0 -0
- faststudio-0.1.0/tests/factories/models.py +622 -0
- faststudio-0.1.0/tests/integration/__init__.py +0 -0
- faststudio-0.1.0/tests/integration/api/__init__.py +0 -0
- faststudio-0.1.0/tests/integration/api/conftest.py +259 -0
- faststudio-0.1.0/tests/integration/api/test_list.py +156 -0
- faststudio-0.1.0/tests/integration/api/test_list_injection.py +62 -0
- faststudio-0.1.0/tests/integration/api/test_meta.py +61 -0
- faststudio-0.1.0/tests/integration/api/test_retrieve_and_choices.py +135 -0
- faststudio-0.1.0/tests/integration/api/test_write.py +435 -0
- faststudio-0.1.0/tests/integration/conftest.py +99 -0
- faststudio-0.1.0/tests/integration/security/__init__.py +0 -0
- faststudio-0.1.0/tests/integration/security/test_auth.py +579 -0
- faststudio-0.1.0/tests/integration/security/test_headers.py +157 -0
- faststudio-0.1.0/tests/integration/security/test_origin.py +132 -0
- faststudio-0.1.0/tests/integration/test_errors.py +163 -0
- faststudio-0.1.0/tests/integration/test_example_app.py +221 -0
- faststudio-0.1.0/tests/integration/test_spa.py +312 -0
- faststudio-0.1.0/tests/unit/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/api/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/api/test_errors.py +16 -0
- faststudio-0.1.0/tests/unit/api/test_serialize.py +142 -0
- faststudio-0.1.0/tests/unit/api/test_write_commit.py +53 -0
- faststudio-0.1.0/tests/unit/auth/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/auth/test_model_backend.py +274 -0
- faststudio-0.1.0/tests/unit/auth/test_passwords.py +102 -0
- faststudio-0.1.0/tests/unit/auth/test_tokens.py +152 -0
- faststudio-0.1.0/tests/unit/introspection/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/introspection/test_fields.py +598 -0
- faststudio-0.1.0/tests/unit/query/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/query/test_params.py +80 -0
- faststudio-0.1.0/tests/unit/schemas/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/schemas/test_contract.py +403 -0
- faststudio-0.1.0/tests/unit/schemas/test_dynamic.py +191 -0
- faststudio-0.1.0/tests/unit/schemas/test_export_contract.py +109 -0
- faststudio-0.1.0/tests/unit/security/__init__.py +0 -0
- faststudio-0.1.0/tests/unit/security/test_asgi_wrappers.py +67 -0
- faststudio-0.1.0/tests/unit/security/test_rate_limit.py +68 -0
- faststudio-0.1.0/tests/unit/security/test_secret.py +224 -0
- faststudio-0.1.0/tests/unit/test_admin_init.py +167 -0
- faststudio-0.1.0/tests/unit/test_authenticated_user.py +27 -0
- faststudio-0.1.0/tests/unit/test_changelog_notes.py +48 -0
- faststudio-0.1.0/tests/unit/test_check_commit_msg.py +41 -0
- faststudio-0.1.0/tests/unit/test_config.py +152 -0
- faststudio-0.1.0/tests/unit/test_docs.py +145 -0
- faststudio-0.1.0/tests/unit/test_model_admin_validation.py +646 -0
- faststudio-0.1.0/tests/unit/test_package.py +29 -0
- faststudio-0.1.0/tests/unit/test_spa.py +78 -0
- faststudio-0.1.0/tests/unit/test_verify_wheel.py +53 -0
- faststudio-0.1.0/tools/name-reservation/LICENSE +21 -0
- faststudio-0.1.0/tools/name-reservation/README.md +15 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.coverage
|
|
9
|
+
.coverage.*
|
|
10
|
+
coverage.xml
|
|
11
|
+
htmlcov/
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
|
|
16
|
+
# Built SPA: produced by `pnpm -C frontend build`, never committed (ADR-0002)
|
|
17
|
+
src/faststudio/static/
|
|
18
|
+
|
|
19
|
+
# Frontend
|
|
20
|
+
node_modules/
|
|
21
|
+
frontend/coverage/
|
|
22
|
+
frontend/test-results/
|
|
23
|
+
frontend/playwright-report/
|
|
24
|
+
frontend/blob-report/
|
|
25
|
+
*.tsbuildinfo
|
|
26
|
+
|
|
27
|
+
# Local data / secrets
|
|
28
|
+
*.sqlite3
|
|
29
|
+
*.db
|
|
30
|
+
.env
|
|
31
|
+
.env.*
|
|
32
|
+
!.env.example
|
|
33
|
+
|
|
34
|
+
# Editors / OS
|
|
35
|
+
.idea/
|
|
36
|
+
.vscode/
|
|
37
|
+
.DS_Store
|
|
38
|
+
|
|
39
|
+
# Claude Code local settings
|
|
40
|
+
.claude/settings.local.json
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
While in `0.x`, minor releases may contain breaking changes; they are always
|
|
8
|
+
listed under **Changed** or **Removed** with migration notes.
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-11-24
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Project scaffold: packaging with a wheel build hook that bundles the React SPA,
|
|
15
|
+
CI (lint, mypy, tests on Python 3.11–3.13, security scans, wheel smoke test,
|
|
16
|
+
Playwright E2E), release workflow with PyPI Trusted Publishing, CodeQL and
|
|
17
|
+
Dependabot.
|
|
18
|
+
- Architecture docs, threat model and ADRs 0001–0008.
|
|
19
|
+
- `Admin` validates all options (values and types) at startup and raises
|
|
20
|
+
`ConfigurationError` on misconfiguration: exactly one of `engine` (must be an
|
|
21
|
+
`AsyncEngine`) or `session_maker`, an `AuthBackend` instance with async
|
|
22
|
+
methods, title, `base_url`, `session_max_age` and `max_page_size` bounds.
|
|
23
|
+
- Secret key resolution from `secret_key=` or `FASTSTUDIO_SECRET_KEY`; startup
|
|
24
|
+
fails if it is missing, too short, a known placeholder, sequential or a
|
|
25
|
+
keyboard run, low diversity, hand-written and under 43 characters, or has
|
|
26
|
+
surrounding whitespace. The secret never appears in error messages or `repr`.
|
|
27
|
+
- Public `AuthBackend` protocol and `AuthenticatedUser` dataclass with a
|
|
28
|
+
required, non-empty `auth_version` for session revocation.
|
|
29
|
+
- `ModelAdmin` declarative options and `Admin.register()` (also usable as a
|
|
30
|
+
class decorator). Registration validates everything at startup: mapped
|
|
31
|
+
model, single-column primary key, unique identity and model, field names
|
|
32
|
+
(with the list of available fields in the error), text-only
|
|
33
|
+
`search_fields`, boolean/enum-only `list_filter`, `ordering` syntax,
|
|
34
|
+
`page_size` within `max_page_size`, and that `exclude`d fields are not
|
|
35
|
+
displayed, searched, filtered, sorted, made readonly or labelled (including
|
|
36
|
+
through another attribute mapped to the same column). Unknown public class
|
|
37
|
+
attributes are rejected so a misspelled option never fails open; typos and
|
|
38
|
+
Django/SQLAdmin option names get a suggestion. Joined-table inheritance is
|
|
39
|
+
supported. Visible fields with sensitive-looking names log a warning.
|
|
40
|
+
- Introspection of every visible column into a field description: type
|
|
41
|
+
(`string`, `text`, `integer`, `float`, `decimal`, `boolean`, `date`,
|
|
42
|
+
`datetime`, `enum`, `json`, `uuid`, `foreign_key`, `unsupported`),
|
|
43
|
+
label, nullable/required/readonly flags, JSON-safe default, max length,
|
|
44
|
+
enum choices, many-to-one relation target, timezone, precision/scale and
|
|
45
|
+
help text from the column comment, integer ranges, and a `create_only` flag
|
|
46
|
+
for natural primary keys. Writability fails closed: database- or
|
|
47
|
+
SQLAlchemy-maintained columns, value-converting `TypeDecorator`s and
|
|
48
|
+
unsupported types are read-only; relations only target primary keys;
|
|
49
|
+
sensitive and unsupported defaults are not published. A warning is logged
|
|
50
|
+
when `can_create` is enabled but a required column can never be supplied.
|
|
51
|
+
- Versioned API contract (`schema_version` "1") as frozen Pydantic models
|
|
52
|
+
(`MetaResponse`, `ModelMeta`, `FieldMeta`, `ListResponse`, `Row`,
|
|
53
|
+
`ChoicesResponse`, `UserResponse`, `LoginRequest`, `ErrorResponse`), with
|
|
54
|
+
`ModelMeta` built from registered models (relation targets resolved
|
|
55
|
+
across the registry, preferring the table owner under single-table
|
|
56
|
+
inheritance; sortable-field allowlist computed at registration). Login
|
|
57
|
+
passwords never appear in `repr` or errors, usernames reject control
|
|
58
|
+
characters, error details never echo inputs, and unsafe integer bounds
|
|
59
|
+
are not published.
|
|
60
|
+
- `scripts/export_contract.py` exports the contract to a committed,
|
|
61
|
+
deterministic JSON Schema; `pnpm gen:contract` generates
|
|
62
|
+
`frontend/src/api/contract.gen.ts` from it. CI and pre-commit fail on drift.
|
|
63
|
+
- `Admin` mounts an isolated sub-application at `base_url`: the bundled SPA
|
|
64
|
+
with history fallback, runtime config injected into `index.html`
|
|
65
|
+
(`SpaConfig`, escaped), hashed assets, a JSON-only `/api` namespace, and
|
|
66
|
+
every error in the contract format (new code `method_not_allowed`; 422s
|
|
67
|
+
list `loc`/`msg`/`type` only; 500s are generic and logged).
|
|
68
|
+
- Security headers on every admin response, including redirects and 500s:
|
|
69
|
+
strict CSP, `nosniff`, `Referrer-Policy`, `X-Frame-Options: DENY`,
|
|
70
|
+
COOP/CORP, `Permissions-Policy`, HSTS over HTTPS and `Cache-Control`.
|
|
71
|
+
- Same-origin guard on every `/api/*` request, including reads, so a
|
|
72
|
+
permissive host CORS policy cannot expose admin data (ADR-0008).
|
|
73
|
+
- Works behind path-prefix proxies (`--root-path`): the SPA shell, assets,
|
|
74
|
+
API URLs and the trailing-slash redirect include the prefix.
|
|
75
|
+
- Authentication: `POST /auth/login`, `POST /auth/logout`, `GET /auth/me`;
|
|
76
|
+
every other API route requires a session. Public `ModelUserBackend`
|
|
77
|
+
(admins from your own user model, argon2id, timing-equalized failures),
|
|
78
|
+
`hash_password()`, `RateLimiter`, `RateLimitDecision` and
|
|
79
|
+
`InMemoryRateLimiter` (default 5 attempts / 15 min per IP + username).
|
|
80
|
+
- Signed, HttpOnly, SameSite=Lax session cookies with absolute expiry and
|
|
81
|
+
revocation when a user's password or access changes.
|
|
82
|
+
- CSRF protection for every unsafe API request: signed double-submit tokens
|
|
83
|
+
bound to the session, rotated on login and logout.
|
|
84
|
+
- Read API (session required): `GET /meta`, `GET /models/{identity}/items`
|
|
85
|
+
(pagination, case-insensitive search, sorting and filters, all validated
|
|
86
|
+
against the `ModelAdmin` allowlists; anything else is `400`),
|
|
87
|
+
`GET /models/{identity}/items/{pk}` and foreign-key
|
|
88
|
+
`GET /models/{identity}/fields/{field}/choices`. Rows carry relation labels
|
|
89
|
+
from visible fields; large integers are sent as strings.
|
|
90
|
+
- Write API (session + CSRF required): `POST`, `PATCH` and `DELETE` on
|
|
91
|
+
`/models/{identity}/items`. Bodies are validated by write schemas generated
|
|
92
|
+
at registration (unknown, readonly, excluded, managed and primary-key
|
|
93
|
+
fields rejected with 422), values at least as strictly as the database,
|
|
94
|
+
foreign keys checked, `can_*` flags enforced server-side, integrity errors
|
|
95
|
+
returned as 409, bodies capped at 1 MiB (new error code
|
|
96
|
+
`payload_too_large`).
|
|
97
|
+
- `Admin(title=...)` rejects control and invisible formatting characters.
|
|
98
|
+
- Playwright E2E now runs the built SPA through the real admin mount and
|
|
99
|
+
fails on any CSP violation.
|
|
100
|
+
- Frontend foundation: login page (React Hook Form + Zod, generic errors,
|
|
101
|
+
`next` limited to in-app paths), authenticated layout with sidebar built
|
|
102
|
+
from `/meta`, dashboard of registered models, light/dark/system theme
|
|
103
|
+
(`faststudio:theme`), typed API client that sends the CSRF header on writes
|
|
104
|
+
and returns to login when a session expires mid-use. Toasts use a small
|
|
105
|
+
in-house component because toast libraries that inject `<style>` elements
|
|
106
|
+
violate the admin's strict CSP, and zod runs without its `eval` probe.
|
|
107
|
+
The theme toggle cycles light, dark and system (system follows OS changes).
|
|
108
|
+
Playwright now signs in end to end, covers session expiry, and fails on any
|
|
109
|
+
`securitypolicyviolation` event, unexpected 401 or console error.
|
|
110
|
+
- List view: a table per model built from `list_display` with type-aware
|
|
111
|
+
cells (booleans, enum labels, foreign-key labels, localised datetimes,
|
|
112
|
+
exact big integers, truncated text and JSON), sortable headers
|
|
113
|
+
(`aria-sort`), debounced search, boolean/choice filters (including
|
|
114
|
+
"Empty" for nullable fields) and pagination. View state lives in the URL
|
|
115
|
+
and is validated against the model metadata before any request, so
|
|
116
|
+
shared links, reload and the back button work and tampered links never
|
|
117
|
+
produce a `400`. Starting a search adds a history entry (Back undoes it);
|
|
118
|
+
refining it does not. Previous results stay visible while the next page
|
|
119
|
+
loads (with a notice if a refresh fails), and stale requests are cancelled.
|
|
120
|
+
- A signed-in admin who opens the login page is sent straight to `next`.
|
|
121
|
+
- Create and edit forms generated from the model metadata: one widget per
|
|
122
|
+
field type (text, numbers, decimals, switches, tri-state booleans, enum
|
|
123
|
+
selects, date/datetime pickers, JSON and UUID inputs) and a searchable
|
|
124
|
+
picker for foreign keys backed by the choices endpoint. The browser
|
|
125
|
+
applies the same rules as the server (lengths in characters, integer
|
|
126
|
+
ranges with exact big integers, decimal precision/scale, timezone-aware
|
|
127
|
+
datetimes) and server validation errors appear next to their fields.
|
|
128
|
+
Edits send only changed fields; readonly and create-only fields are
|
|
129
|
+
shown but locked; models with editing disabled are read-only.
|
|
130
|
+
- Delete with a confirmation dialog built on the native `<dialog>` element
|
|
131
|
+
(no injected styles, so it works under the strict CSP); refused deletes
|
|
132
|
+
(`409`) are explained. Leaving a form or signing out with unsaved changes
|
|
133
|
+
asks first; deleting the record and session-expiry redirects are never
|
|
134
|
+
blocked.
|
|
135
|
+
- Toasts confirm creates, saves and deletes. Records link from the first
|
|
136
|
+
list column; an "Add" button appears when creating is allowed.
|
|
137
|
+
- Model pages are loaded on demand, keeping the initial bundle small; a
|
|
138
|
+
page whose code cannot be loaded (e.g. a tab opened before an upgrade)
|
|
139
|
+
offers a reload, and a progress bar shows while pages load.
|
|
140
|
+
- `examples/basic`: a runnable shop back office (users, categories,
|
|
141
|
+
products, tasks) covering every supported field type, with demo data, a
|
|
142
|
+
`create_admin` command and a throwaway `--ephemeral` mode. Playwright now
|
|
143
|
+
runs against it, and the wheel smoke test runs it on the installed wheel
|
|
144
|
+
(SPA shell, every referenced asset, sign-in, list, create, delete).
|
|
145
|
+
|
|
146
|
+
### Security
|
|
147
|
+
|
|
148
|
+
- Login verifies passwords in worker threads (at most 4 at a time per event
|
|
149
|
+
loop), so login floods no longer block the event loop shared with the host
|
|
150
|
+
application.
|
|
151
|
+
- Each client address gets at most 30 login attempts per 15 minutes across
|
|
152
|
+
all usernames (on top of the per-username limit), stopping password
|
|
153
|
+
spraying from one address.
|
|
154
|
+
- A session or CSRF cookie sent more than once (planted by a sibling
|
|
155
|
+
subdomain) is refused by the server and the UI.
|
|
156
|
+
- Requires `starlette>=0.49.1` (Range-header DoS, CVE-2025-62727),
|
|
157
|
+
`fastapi>=0.120.1` and `pydantic>=2.10`; CI now also tests the minimum
|
|
158
|
+
supported versions.
|
|
159
|
+
- Logged request paths are escaped (no terminal control sequences in logs).
|
|
160
|
+
- Release workflow re-runs every check on the tagged commit, uses no
|
|
161
|
+
dependency caches and does not persist checkout credentials; the build
|
|
162
|
+
backend is pinned.
|
|
163
|
+
|
|
164
|
+
### Fixed
|
|
165
|
+
|
|
166
|
+
- List cells show offset-less values of timezone-aware datetime columns
|
|
167
|
+
(e.g. from SQLite) as UTC, consistent with the edit form; they were shown
|
|
168
|
+
as local time.
|
|
169
|
+
- Model display names keep acronyms that contain digits together
|
|
170
|
+
(`E2EUser` -> "E2E users", previously "E2 E users").
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
[0.1.0]: https://github.com/bekzod818/faststudio/releases/tag/v0.1.0
|
faststudio-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bekzod
|
|
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.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: faststudio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Plug-and-play admin panel for FastAPI and SQLAlchemy 2.0 with a modern React UI.
|
|
5
|
+
Project-URL: Homepage, https://github.com/bekzod818/faststudio
|
|
6
|
+
Project-URL: Repository, https://github.com/bekzod818/faststudio
|
|
7
|
+
Project-URL: Issues, https://github.com/bekzod818/faststudio/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/bekzod818/faststudio/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Bekzod
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: admin,admin-panel,crud,dashboard,fastapi,react,sqlalchemy,starlette
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Web Environment
|
|
15
|
+
Classifier: Framework :: AsyncIO
|
|
16
|
+
Classifier: Framework :: FastAPI
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.11
|
|
29
|
+
Requires-Dist: anyio>=4.0
|
|
30
|
+
Requires-Dist: argon2-cffi>=23.1
|
|
31
|
+
Requires-Dist: fastapi>=0.120.1
|
|
32
|
+
Requires-Dist: itsdangerous>=2.1
|
|
33
|
+
Requires-Dist: pydantic<3,>=2.10
|
|
34
|
+
Requires-Dist: sqlalchemy[asyncio]<3,>=2.0.30
|
|
35
|
+
Requires-Dist: starlette>=0.49.1
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
<p align="center"><strong>FastStudio</strong></p>
|
|
39
|
+
|
|
40
|
+
<p align="center"><em>A modern, beautiful admin studio for FastAPI.</em></p>
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<a href="https://github.com/bekzod818/faststudio/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/bekzod818/faststudio/actions/workflows/ci.yml/badge.svg"></a>
|
|
44
|
+
<a href="https://codecov.io/gh/bekzod818/faststudio"><img alt="Coverage" src="https://codecov.io/gh/bekzod818/faststudio/branch/main/graph/badge.svg"></a>
|
|
45
|
+
<a href="https://pypi.org/project/faststudio/"><img alt="PyPI" src="https://img.shields.io/pypi/v/faststudio"></a>
|
|
46
|
+
<a href="https://pypi.org/project/faststudio/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/faststudio"></a>
|
|
47
|
+
<a href="https://github.com/bekzod818/faststudio/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
|
|
48
|
+
<a href="https://github.com/astral-sh/ruff"><img alt="Code style: ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
> **Status: alpha.** The public API may change in any `0.x` release until `1.0`.
|
|
52
|
+
|
|
53
|
+
FastStudio adds a polished, Django-Admin-style admin panel to any FastAPI
|
|
54
|
+
application backed by SQLAlchemy 2.0 (async). Register your models with a few
|
|
55
|
+
lines of declarative Python and get a fast React UI for browsing, searching,
|
|
56
|
+
filtering and editing your data. No Node.js required: the UI ships pre-built
|
|
57
|
+
inside the Python wheel.
|
|
58
|
+
|
|
59
|
+
<p align="center">
|
|
60
|
+
<img alt="The products list in FastStudio: search, filters, sortable columns and pagination" src="https://raw.githubusercontent.com/bekzod818/faststudio/v0.1.0/docs/assets/screenshot-list.png" width="860">
|
|
61
|
+
</p>
|
|
62
|
+
|
|
63
|
+
## Features
|
|
64
|
+
|
|
65
|
+
- **pip install and go**: the React SPA is bundled in the wheel.
|
|
66
|
+
- **Declarative `ModelAdmin`**: `list_display`, `search_fields`, `list_filter`,
|
|
67
|
+
`ordering`, `readonly_fields`, `exclude`, `can_create` / `can_edit` / `can_delete`.
|
|
68
|
+
- **Schema-driven UI**: tables and forms are generated from your SQLAlchemy
|
|
69
|
+
models. No per-model frontend code.
|
|
70
|
+
- **Server-side everything**: pagination, sorting, search and filters run in
|
|
71
|
+
the database through SQLAlchemy expressions, never string-built SQL.
|
|
72
|
+
- **Secure by default**: argon2 password hashing, signed HTTP-only session
|
|
73
|
+
cookies, CSRF protection, login rate limiting, strict security headers and CSP.
|
|
74
|
+
- **Typed end to end**: `mypy --strict` clean, ships `py.typed`; the
|
|
75
|
+
frontend's API types are generated from the backend's Pydantic contract.
|
|
76
|
+
- Light and dark mode, responsive layout, accessible components.
|
|
77
|
+
|
|
78
|
+
## Quickstart
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install faststudio aiosqlite uvicorn # aiosqlite: or asyncpg / aiomysql
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Save as `main.py`:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from fastapi import FastAPI
|
|
88
|
+
from sqlalchemy import String
|
|
89
|
+
from sqlalchemy.ext.asyncio import create_async_engine
|
|
90
|
+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
91
|
+
|
|
92
|
+
from faststudio import Admin, ModelAdmin, ModelUserBackend
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Base(DeclarativeBase):
|
|
96
|
+
pass
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class User(Base): # your own model: FastStudio signs admins in from it
|
|
100
|
+
__tablename__ = "users"
|
|
101
|
+
|
|
102
|
+
id: Mapped[int] = mapped_column(primary_key=True)
|
|
103
|
+
username: Mapped[str] = mapped_column(String(150), unique=True)
|
|
104
|
+
email: Mapped[str] = mapped_column(String(254))
|
|
105
|
+
password_hash: Mapped[str] = mapped_column(String(255))
|
|
106
|
+
is_active: Mapped[bool] = mapped_column(default=True)
|
|
107
|
+
is_admin: Mapped[bool] = mapped_column(default=False)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
engine = create_async_engine("sqlite+aiosqlite:///app.db")
|
|
111
|
+
app = FastAPI()
|
|
112
|
+
# secret_key defaults to the FASTSTUDIO_SECRET_KEY environment variable
|
|
113
|
+
admin = Admin(app, engine=engine, auth_backend=ModelUserBackend(User))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@admin.register
|
|
117
|
+
class UserAdmin(ModelAdmin, model=User):
|
|
118
|
+
list_display = ["id", "username", "email", "is_active", "is_admin"]
|
|
119
|
+
search_fields = ["username", "email"]
|
|
120
|
+
list_filter = ["is_active", "is_admin"]
|
|
121
|
+
exclude = ["password_hash"] # never show or accept credentials
|
|
122
|
+
can_create = False # accounts are created in code (see create_admin.py)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Save as `create_admin.py` (creates the table and your first admin; run it once
|
|
126
|
+
per account, since usernames are unique):
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
import asyncio
|
|
130
|
+
import getpass
|
|
131
|
+
|
|
132
|
+
from sqlalchemy.ext.asyncio import async_sessionmaker
|
|
133
|
+
|
|
134
|
+
from faststudio import hash_password
|
|
135
|
+
from main import Base, User, engine
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
async def create_admin() -> None:
|
|
139
|
+
try:
|
|
140
|
+
async with engine.begin() as conn:
|
|
141
|
+
await conn.run_sync(Base.metadata.create_all)
|
|
142
|
+
async with async_sessionmaker(engine)() as session:
|
|
143
|
+
session.add(
|
|
144
|
+
User(
|
|
145
|
+
username=input("Username: "),
|
|
146
|
+
email=input("Email: "),
|
|
147
|
+
password_hash=hash_password(getpass.getpass("Password: ")),
|
|
148
|
+
is_admin=True,
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
await session.commit()
|
|
152
|
+
finally:
|
|
153
|
+
await engine.dispose()
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
asyncio.run(create_admin())
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Then:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
export FASTSTUDIO_SECRET_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(48))')"
|
|
163
|
+
python create_admin.py
|
|
164
|
+
uvicorn main:app
|
|
165
|
+
# open http://127.0.0.1:8000/admin
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The [getting-started guide](https://github.com/bekzod818/faststudio/blob/main/docs/getting-started.md) explains each
|
|
169
|
+
step, and [`examples/basic`](https://github.com/bekzod818/faststudio/blob/main/examples/basic/README.md) is a complete
|
|
170
|
+
app covering every field type:
|
|
171
|
+
|
|
172
|
+
<p align="center">
|
|
173
|
+
<img alt="Editing a product: typed inputs, a related-record picker and a JSON field" src="https://raw.githubusercontent.com/bekzod818/faststudio/v0.1.0/docs/assets/screenshot-form.png" width="420">
|
|
174
|
+
<img alt="The products list in dark mode with an active filter" src="https://raw.githubusercontent.com/bekzod818/faststudio/v0.1.0/docs/assets/screenshot-list-dark.png" width="420">
|
|
175
|
+
</p>
|
|
176
|
+
|
|
177
|
+
## Configuration
|
|
178
|
+
|
|
179
|
+
| Option (`Admin(...)`) | Env var | Default | Notes |
|
|
180
|
+
|---|---|---|---|
|
|
181
|
+
| `secret_key` | `FASTSTUDIO_SECRET_KEY` | required | ≥ 32 chars, random. Startup fails if missing or weak. |
|
|
182
|
+
| `base_url` | – | `/admin` | Mount path. The UI works under any path. |
|
|
183
|
+
| `title` | – | `"FastStudio"` | Shown in the header and browser tab. |
|
|
184
|
+
| `session_max_age` | – | 8 hours | Absolute session lifetime. |
|
|
185
|
+
| `secure_cookies` | – | `True` | Chrome and Firefox accept secure cookies on `http://localhost` and `127.0.0.1`; elsewhere serve over HTTPS. |
|
|
186
|
+
| `max_page_size` | – | `100` | Upper bound for any list request and for `ModelAdmin.page_size`. |
|
|
187
|
+
| `rate_limiter` | – | in-memory | Use a shared limiter when running several workers. |
|
|
188
|
+
| `show_powered_by` | – | `True` | "Powered by FastStudio" footer. |
|
|
189
|
+
|
|
190
|
+
Full reference: [docs/configuration.md](https://github.com/bekzod818/faststudio/blob/main/docs/configuration.md).
|
|
191
|
+
|
|
192
|
+
## Security
|
|
193
|
+
|
|
194
|
+
FastStudio treats the admin as a high-value target. Every API route except
|
|
195
|
+
login requires a session; state-changing requests require a CSRF token; search,
|
|
196
|
+
filter and sort parameters are validated against the fields you declared;
|
|
197
|
+
writes respect `readonly_fields` and `exclude`; logins are throttled per
|
|
198
|
+
account and per client. Run behind a proxy with trusted proxy headers
|
|
199
|
+
(`uvicorn --proxy-headers --forwarded-allow-ips=...`) so client addresses are
|
|
200
|
+
real, and mount the admin on its own subdomain if the host serves untrusted
|
|
201
|
+
content. Read the
|
|
202
|
+
[threat model](https://github.com/bekzod818/faststudio/blob/main/docs/threat-model.md) and report vulnerabilities privately as
|
|
203
|
+
described in [SECURITY.md](https://github.com/bekzod818/faststudio/blob/main/SECURITY.md).
|
|
204
|
+
|
|
205
|
+
## How it compares
|
|
206
|
+
|
|
207
|
+
FastStudio stands on the shoulders of excellent existing projects:
|
|
208
|
+
|
|
209
|
+
- **[SQLAdmin](https://github.com/aminalaee/sqladmin)** is a mature, widely used
|
|
210
|
+
admin for SQLAlchemy built on Starlette with server-rendered Jinja2
|
|
211
|
+
templates. It supports sync and async engines and offers many more features
|
|
212
|
+
than FastStudio does today.
|
|
213
|
+
- **[Starlette-Admin](https://github.com/jowilf/starlette-admin)** is a flexible
|
|
214
|
+
admin framework supporting several ORMs/ODMs (SQLAlchemy, SQLModel,
|
|
215
|
+
MongoEngine, ODMantic, Beanie), with file handling and data export, using
|
|
216
|
+
server-rendered templates.
|
|
217
|
+
|
|
218
|
+
FastStudio takes a different approach: a **single-page React application**
|
|
219
|
+
driven by a versioned JSON metadata contract, with a typed REST API between
|
|
220
|
+
them. It is narrower in scope (SQLAlchemy 2.0 async only) and younger. If you
|
|
221
|
+
need a proven tool today, both projects above are great choices.
|
|
222
|
+
|
|
223
|
+
## Roadmap
|
|
224
|
+
|
|
225
|
+
See [ROADMAP.md](https://github.com/bekzod818/faststudio/blob/main/ROADMAP.md). Highlights after v0.1.0: relationship editing,
|
|
226
|
+
custom actions, file uploads, role-based permissions, audit log, i18n
|
|
227
|
+
(English, Uzbek, Russian).
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
Contributions are welcome. Start with [CONTRIBUTING.md](https://github.com/bekzod818/faststudio/blob/main/CONTRIBUTING.md) and
|
|
232
|
+
the [architecture overview](https://github.com/bekzod818/faststudio/blob/main/docs/architecture.md).
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
[MIT](https://github.com/bekzod818/faststudio/blob/main/LICENSE) © 2026 Bekzod
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<p align="center"><strong>FastStudio</strong></p>
|
|
2
|
+
|
|
3
|
+
<p align="center"><em>A modern, beautiful admin studio for FastAPI.</em></p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://github.com/bekzod818/faststudio/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/bekzod818/faststudio/actions/workflows/ci.yml/badge.svg"></a>
|
|
7
|
+
<a href="https://codecov.io/gh/bekzod818/faststudio"><img alt="Coverage" src="https://codecov.io/gh/bekzod818/faststudio/branch/main/graph/badge.svg"></a>
|
|
8
|
+
<a href="https://pypi.org/project/faststudio/"><img alt="PyPI" src="https://img.shields.io/pypi/v/faststudio"></a>
|
|
9
|
+
<a href="https://pypi.org/project/faststudio/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/faststudio"></a>
|
|
10
|
+
<a href="https://github.com/bekzod818/faststudio/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
|
|
11
|
+
<a href="https://github.com/astral-sh/ruff"><img alt="Code style: ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
> **Status: alpha.** The public API may change in any `0.x` release until `1.0`.
|
|
15
|
+
|
|
16
|
+
FastStudio adds a polished, Django-Admin-style admin panel to any FastAPI
|
|
17
|
+
application backed by SQLAlchemy 2.0 (async). Register your models with a few
|
|
18
|
+
lines of declarative Python and get a fast React UI for browsing, searching,
|
|
19
|
+
filtering and editing your data. No Node.js required: the UI ships pre-built
|
|
20
|
+
inside the Python wheel.
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img alt="The products list in FastStudio: search, filters, sortable columns and pagination" src="https://raw.githubusercontent.com/bekzod818/faststudio/v0.1.0/docs/assets/screenshot-list.png" width="860">
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **pip install and go**: the React SPA is bundled in the wheel.
|
|
29
|
+
- **Declarative `ModelAdmin`**: `list_display`, `search_fields`, `list_filter`,
|
|
30
|
+
`ordering`, `readonly_fields`, `exclude`, `can_create` / `can_edit` / `can_delete`.
|
|
31
|
+
- **Schema-driven UI**: tables and forms are generated from your SQLAlchemy
|
|
32
|
+
models. No per-model frontend code.
|
|
33
|
+
- **Server-side everything**: pagination, sorting, search and filters run in
|
|
34
|
+
the database through SQLAlchemy expressions, never string-built SQL.
|
|
35
|
+
- **Secure by default**: argon2 password hashing, signed HTTP-only session
|
|
36
|
+
cookies, CSRF protection, login rate limiting, strict security headers and CSP.
|
|
37
|
+
- **Typed end to end**: `mypy --strict` clean, ships `py.typed`; the
|
|
38
|
+
frontend's API types are generated from the backend's Pydantic contract.
|
|
39
|
+
- Light and dark mode, responsive layout, accessible components.
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install faststudio aiosqlite uvicorn # aiosqlite: or asyncpg / aiomysql
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Save as `main.py`:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from fastapi import FastAPI
|
|
51
|
+
from sqlalchemy import String
|
|
52
|
+
from sqlalchemy.ext.asyncio import create_async_engine
|
|
53
|
+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
54
|
+
|
|
55
|
+
from faststudio import Admin, ModelAdmin, ModelUserBackend
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Base(DeclarativeBase):
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class User(Base): # your own model: FastStudio signs admins in from it
|
|
63
|
+
__tablename__ = "users"
|
|
64
|
+
|
|
65
|
+
id: Mapped[int] = mapped_column(primary_key=True)
|
|
66
|
+
username: Mapped[str] = mapped_column(String(150), unique=True)
|
|
67
|
+
email: Mapped[str] = mapped_column(String(254))
|
|
68
|
+
password_hash: Mapped[str] = mapped_column(String(255))
|
|
69
|
+
is_active: Mapped[bool] = mapped_column(default=True)
|
|
70
|
+
is_admin: Mapped[bool] = mapped_column(default=False)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
engine = create_async_engine("sqlite+aiosqlite:///app.db")
|
|
74
|
+
app = FastAPI()
|
|
75
|
+
# secret_key defaults to the FASTSTUDIO_SECRET_KEY environment variable
|
|
76
|
+
admin = Admin(app, engine=engine, auth_backend=ModelUserBackend(User))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@admin.register
|
|
80
|
+
class UserAdmin(ModelAdmin, model=User):
|
|
81
|
+
list_display = ["id", "username", "email", "is_active", "is_admin"]
|
|
82
|
+
search_fields = ["username", "email"]
|
|
83
|
+
list_filter = ["is_active", "is_admin"]
|
|
84
|
+
exclude = ["password_hash"] # never show or accept credentials
|
|
85
|
+
can_create = False # accounts are created in code (see create_admin.py)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Save as `create_admin.py` (creates the table and your first admin; run it once
|
|
89
|
+
per account, since usernames are unique):
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import asyncio
|
|
93
|
+
import getpass
|
|
94
|
+
|
|
95
|
+
from sqlalchemy.ext.asyncio import async_sessionmaker
|
|
96
|
+
|
|
97
|
+
from faststudio import hash_password
|
|
98
|
+
from main import Base, User, engine
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
async def create_admin() -> None:
|
|
102
|
+
try:
|
|
103
|
+
async with engine.begin() as conn:
|
|
104
|
+
await conn.run_sync(Base.metadata.create_all)
|
|
105
|
+
async with async_sessionmaker(engine)() as session:
|
|
106
|
+
session.add(
|
|
107
|
+
User(
|
|
108
|
+
username=input("Username: "),
|
|
109
|
+
email=input("Email: "),
|
|
110
|
+
password_hash=hash_password(getpass.getpass("Password: ")),
|
|
111
|
+
is_admin=True,
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
await session.commit()
|
|
115
|
+
finally:
|
|
116
|
+
await engine.dispose()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
asyncio.run(create_admin())
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Then:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
export FASTSTUDIO_SECRET_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(48))')"
|
|
126
|
+
python create_admin.py
|
|
127
|
+
uvicorn main:app
|
|
128
|
+
# open http://127.0.0.1:8000/admin
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The [getting-started guide](https://github.com/bekzod818/faststudio/blob/main/docs/getting-started.md) explains each
|
|
132
|
+
step, and [`examples/basic`](https://github.com/bekzod818/faststudio/blob/main/examples/basic/README.md) is a complete
|
|
133
|
+
app covering every field type:
|
|
134
|
+
|
|
135
|
+
<p align="center">
|
|
136
|
+
<img alt="Editing a product: typed inputs, a related-record picker and a JSON field" src="https://raw.githubusercontent.com/bekzod818/faststudio/v0.1.0/docs/assets/screenshot-form.png" width="420">
|
|
137
|
+
<img alt="The products list in dark mode with an active filter" src="https://raw.githubusercontent.com/bekzod818/faststudio/v0.1.0/docs/assets/screenshot-list-dark.png" width="420">
|
|
138
|
+
</p>
|
|
139
|
+
|
|
140
|
+
## Configuration
|
|
141
|
+
|
|
142
|
+
| Option (`Admin(...)`) | Env var | Default | Notes |
|
|
143
|
+
|---|---|---|---|
|
|
144
|
+
| `secret_key` | `FASTSTUDIO_SECRET_KEY` | required | ≥ 32 chars, random. Startup fails if missing or weak. |
|
|
145
|
+
| `base_url` | – | `/admin` | Mount path. The UI works under any path. |
|
|
146
|
+
| `title` | – | `"FastStudio"` | Shown in the header and browser tab. |
|
|
147
|
+
| `session_max_age` | – | 8 hours | Absolute session lifetime. |
|
|
148
|
+
| `secure_cookies` | – | `True` | Chrome and Firefox accept secure cookies on `http://localhost` and `127.0.0.1`; elsewhere serve over HTTPS. |
|
|
149
|
+
| `max_page_size` | – | `100` | Upper bound for any list request and for `ModelAdmin.page_size`. |
|
|
150
|
+
| `rate_limiter` | – | in-memory | Use a shared limiter when running several workers. |
|
|
151
|
+
| `show_powered_by` | – | `True` | "Powered by FastStudio" footer. |
|
|
152
|
+
|
|
153
|
+
Full reference: [docs/configuration.md](https://github.com/bekzod818/faststudio/blob/main/docs/configuration.md).
|
|
154
|
+
|
|
155
|
+
## Security
|
|
156
|
+
|
|
157
|
+
FastStudio treats the admin as a high-value target. Every API route except
|
|
158
|
+
login requires a session; state-changing requests require a CSRF token; search,
|
|
159
|
+
filter and sort parameters are validated against the fields you declared;
|
|
160
|
+
writes respect `readonly_fields` and `exclude`; logins are throttled per
|
|
161
|
+
account and per client. Run behind a proxy with trusted proxy headers
|
|
162
|
+
(`uvicorn --proxy-headers --forwarded-allow-ips=...`) so client addresses are
|
|
163
|
+
real, and mount the admin on its own subdomain if the host serves untrusted
|
|
164
|
+
content. Read the
|
|
165
|
+
[threat model](https://github.com/bekzod818/faststudio/blob/main/docs/threat-model.md) and report vulnerabilities privately as
|
|
166
|
+
described in [SECURITY.md](https://github.com/bekzod818/faststudio/blob/main/SECURITY.md).
|
|
167
|
+
|
|
168
|
+
## How it compares
|
|
169
|
+
|
|
170
|
+
FastStudio stands on the shoulders of excellent existing projects:
|
|
171
|
+
|
|
172
|
+
- **[SQLAdmin](https://github.com/aminalaee/sqladmin)** is a mature, widely used
|
|
173
|
+
admin for SQLAlchemy built on Starlette with server-rendered Jinja2
|
|
174
|
+
templates. It supports sync and async engines and offers many more features
|
|
175
|
+
than FastStudio does today.
|
|
176
|
+
- **[Starlette-Admin](https://github.com/jowilf/starlette-admin)** is a flexible
|
|
177
|
+
admin framework supporting several ORMs/ODMs (SQLAlchemy, SQLModel,
|
|
178
|
+
MongoEngine, ODMantic, Beanie), with file handling and data export, using
|
|
179
|
+
server-rendered templates.
|
|
180
|
+
|
|
181
|
+
FastStudio takes a different approach: a **single-page React application**
|
|
182
|
+
driven by a versioned JSON metadata contract, with a typed REST API between
|
|
183
|
+
them. It is narrower in scope (SQLAlchemy 2.0 async only) and younger. If you
|
|
184
|
+
need a proven tool today, both projects above are great choices.
|
|
185
|
+
|
|
186
|
+
## Roadmap
|
|
187
|
+
|
|
188
|
+
See [ROADMAP.md](https://github.com/bekzod818/faststudio/blob/main/ROADMAP.md). Highlights after v0.1.0: relationship editing,
|
|
189
|
+
custom actions, file uploads, role-based permissions, audit log, i18n
|
|
190
|
+
(English, Uzbek, Russian).
|
|
191
|
+
|
|
192
|
+
## Contributing
|
|
193
|
+
|
|
194
|
+
Contributions are welcome. Start with [CONTRIBUTING.md](https://github.com/bekzod818/faststudio/blob/main/CONTRIBUTING.md) and
|
|
195
|
+
the [architecture overview](https://github.com/bekzod818/faststudio/blob/main/docs/architecture.md).
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
[MIT](https://github.com/bekzod818/faststudio/blob/main/LICENSE) © 2026 Bekzod
|