-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
📌 Summary
📌 Proposal: A Tauri desktop app. It uses a Svelte (or SvelteKit) frontend and a FastAPI backend.
🧩 The layout follows MVC principles for clear separation of concerns. This makes the app maintainable and scalable.
🚫 Svelte avoids React’s “website obesity,” dependency bloat, and performance issues. It reduces security risks from third‑party library dependencies.
📦 Tauri provides small bundle sizes and a secure native shell.
🧭 Recommended MVC-ish Layout (Option A)
my-farm-app/
├─ src/ # Tauri frontend (View: React/Vue/Svelte)
├─ src-tauri/ # Tauri shell, native config & helpers
│ ├─ src/
│ └─ tauri.conf.json
├─ backend/ # FastAPI (Controller + Model + Services)
│ ├─ app/
│ └─ alembic/ # Migrations (or migration notes for MongoDB)
└─ scripts/
└─ run_fastapi.py # Entrypoint Tauri can spawn
📈 Overview
+-----------------------------+ +------------------------------+
| Tauri UI | HTTP/WS | FastAPI |
| SvelteKit (View) +------------>+ Controllers (Routers) |
| State/Store (ViewModel*) | | Services (Business Logic) |
| | | Models (Pydantic) |
+-----------------------------+ | DB (SQLite/Postgres/MongoDB) |
^ +------------------------------+
| IPC (process mgmt) via Tauri
+------------------------------- start/stop backend
Component (Architecture) Diagram
+--------------------+ HTTP/JSON +----------------------+ ODM +-------------------+
| Browser (Svelte) | ---> http://127.0.0.1:5173 | FastAPI (Uvicorn) | <-----> Beanie | MongoDB Server |
| Vite dev:5174 | CORS allowed | app.main / routers | (models) | movies_db |
+--------------------+ +----------+-----------+ +---------+---------+
| |
| (CRUD /movies) | (collection "movies")
v v
Controllers (api/movies.py) Collection: movies
Activity Diagram (Add Movie)
+--------------------+
| User enters title |
+---------+----------+
|
v
+--------------------+
| Click "Add" |
+---------+----------+
|
v
+--------------------+
| UI POST /movies |
| {title} |
+---------+----------+
|
v
+-----------------------------+
| FastAPI: validate payload |
| (MovieCreate via Pydantic) |
+---------+-------------------+
|
[valid] | [invalid]
| | |
v | v
+------------------+| +-------------------+
| Insert with || | 400/422 response |
| Beanie -> MongoDB || +-------------------+
+---------+---------+|
| |
v |
+--------------------+ (invalid path ends)
| Return MovieRead |
| {id, title} |
+---------+----------+
|
v
+--------------------+
| UI updates list |
+--------------------+
🧰 Useful Libraries
- FastAPI: routers, DI, OpenAPI
- Pydantic v2: schemas
- Motor: async MongoDB driver
- Alembic: migrations (for relational DBs; MongoDB uses manual migration scripts)
- Uvicorn: ASGI server
- Tauri: process management, secure FS APIs, updater, autostart
- Frontend: SvelteKit (or React/Vue alternatives)
🧩 Why MVC? (Model–View–Controller)
- Model: Data + business rules (Pydantic schemas, MongoDB collections or SQLAlchemy for relational DBs).
- View: UI and presentation (SvelteKit in Tauri window).
- Controller: FastAPI routers orchestrating requests and responses.
Benefits
- Clear separation of concerns → maintainable, testable, scalable.
- Swap UI frameworks or DB backends (SQLite/Postgres ↔ MongoDB) without rewriting the whole app.
- Keep frontend lean; backend handles heavy logic.
🔧 Decision Proposal: Prefer SvelteKit for the View
- Lightweight, fast, compiles to minimal JS, works perfectly with Tauri.
- Alternatives: SolidJS, Vanilla JS, React (heavier).
🧱 Data & Backend Choices
- Backend: FastAPI (Controllers + Services + Models).
- Database:
- Start with MongoDB for document-oriented flexibility.
- SQLite/Postgres remain options for relational needs later.
- Migrations: Alembic for relational DBs; manual scripts for MongoDB.
⚠️ Risks & Mitigations
- Dependency bloat → Prefer SvelteKit, audit packages.
- Performance → Keep bundle small, offload heavy logic to backend.
- Security → Pin versions, use Tauri secure APIs.
- DB choice → MongoDB for flexibility now; Postgres later if relational needs arise.
🎯 Acceptance Criteria
- Tauri app launches and spawns/stops FastAPI backend.
- SvelteKit UI loads and interacts with FastAPI endpoints.
- MongoDB integration works for CRUD operations.
- Clear MVC separation in codebase.
✅ Next Steps
- Confirm frontend: SvelteKit.
- Confirm database: MongoDB now; Postgres optional later.
- Scaffold repo with Tauri + SvelteKit + FastAPI + MongoDB.
- Add CI and performance checks.
Metadata
Metadata
Assignees
Labels
No labels