https://github.com/aswanthmanoj/fluidkit
Full-stack web development for the pythoniers with the power of svelte
https://github.com/aswanthmanoj/fluidkit
code-generation fastapi fullstack-development python-fullstack python-with-sveltekit sveltekit
Last synced: 24 days ago
JSON representation
Full-stack web development for the pythoniers with the power of svelte
- Host: GitHub
- URL: https://github.com/aswanthmanoj/fluidkit
- Owner: AswanthManoj
- Created: 2025-07-04T19:35:30.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2026-02-27T09:57:09.000Z (30 days ago)
- Last Synced: 2026-02-27T15:14:43.616Z (30 days ago)
- Topics: code-generation, fastapi, fullstack-development, python-fullstack, python-with-sveltekit, sveltekit
- Language: Python
- Homepage:
- Size: 757 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FluidKit
Web development for the Pythonist
FluidKit bridges Python and SvelteKit into a unified fullstack framework. Write backend functions in Python — FluidKit registers them as FastAPI endpoints and wraps them in SvelteKit-native remote functions with full type safety, cookie forwarding, file uploads, redirects, and single-flight cache invalidation.
```bash
pip install fluidkit
```
## How it works
Decorate Python functions. FluidKit registers them as FastAPI endpoints internally and generates colocated `.remote.ts` files that SvelteKit imports as [remote functions](https://svelte.dev/docs/kit/remote-functions) directly.
```python
# src/lib/demo.py
from fluidkit import query, command, form
db = {
"posts": [
{"id": 1, "title": "Hello World", "content": "This is the first post.", "likes": 10},
{"id": 2, "title": "Fluidkit", "content": "Fluidkit is awesome!", "likes": 50},
{"id": 3, "title": "Python and Svelte", "content": "Using Python with Svelte is great!", "likes": 25},
]
}
@query
async def get_posts():
return db["posts"]
@command
async def like_post(post_id: int):
for post in db["posts"]:
if post["id"] == post_id:
post["likes"] += 1
# invalidates client cache in the same request with single flight mutations
await get_posts().refresh()
return True
return None
@form
async def add_post(title: str, content: str):
new_post = {
"id": len(db["posts"]) + 1,
"title": title,
"content": content,
"likes": 0,
}
db["posts"].append(new_post)
await get_posts().refresh() # invalidates client cache in the same request with single flight mutations
```
```svelte
import { get_posts, like_post, add_post } from '$lib/demo.remote';
Add Post
{#each await get_posts() as post}
{post.title}
{post.content}
await like_post(post.id)}>
👍 {post.likes}
{/each}
```
No manual fetch calls. No duplicated types. No glue code.
🤫 how does this work?
FluidKit reflects on your decorated functions at import time — inspecting parameters, return types, and Pydantic models — and generates colocated `.remote.ts` files wrapping each function in a SvelteKit-native `query`, `command`, `form`, or `prerender` remote function call. In dev mode this re-runs on every save via HMR. The generated files are real TypeScript you can inspect, import, and version control.
## Decorators
| Decorator | Use case | SvelteKit docs |
|---|---|---|
| `@query` | Read data — cached, refreshable | [query](https://svelte.dev/docs/kit/remote-functions#query) |
| `@command` | Write data — single-flight cache invalidation | [command](https://svelte.dev/docs/kit/remote-functions#command) |
| `@form` | Form actions — file uploads, progressive enhancement, redirects | [form](https://svelte.dev/docs/kit/remote-functions#form) |
| `@prerender` | Build-time data fetching with optional runtime fallback | [prerender](https://svelte.dev/docs/kit/remote-functions#prerender) |
## CLI
```bash
fluidkit init # scaffold SvelteKit project with FluidKit wired in
fluidkit dev # run FastAPI + Vite together with HMR
fluidkit build # codegen + npm run build
fluidkit preview # preview production build locally
```
No system Node.js required — FluidKit uses `nodejs-wheel` for all Node operations. npm, npx, and node are available through the CLI:
```bash
fluidkit install tailwindcss # shorthand for npm install
fluidkit install -D prettier # install as dev dependency
fluidkit npm run build # any npm command
fluidkit npx sv add tailwindcss # any npx command
fluidkit node scripts/seed.js # run node directly
```
## Project config
```json
// fluidkit.config.json
{
"entry": "src/app.py",
"host": "0.0.0.0",
"backend_port": 8000,
"frontend_port": 5173,
"schema_output": "src/lib/fluidkit",
"watch_pattern": "./*.py"
}
```
> NOTE: Flags override config. Config overrides defaults.
## Built with
- [SvelteKit](https://svelte.dev/docs/kit) — frontend framework with remote functions
- [FastAPI](https://fastapi.tiangolo.com/) — API layer and request handling
- [Pydantic](https://docs.pydantic.dev/) — type extraction and validation
- [Jurigged](https://github.com/breuleux/jurigged) — hot module reloading in dev mode
- [nodejs-wheel](https://github.com/nicolo-ribaudo/nodejs-wheel) — bundled Node.js, no system install needed