No description
- CSS 41.5%
- Python 37.6%
- JavaScript 20.6%
- Dockerfile 0.2%
- Just 0.1%
| .forgejo/workflows | ||
| .opencode | ||
| commands | ||
| domain | ||
| infrastructure | ||
| presentation | ||
| queries | ||
| static | ||
| .dockerignore | ||
| .env | ||
| .gitignore | ||
| .python-version | ||
| config.py | ||
| Dockerfile | ||
| justfile | ||
| main.py | ||
| package-lock.json | ||
| package.json | ||
| pyproject.toml | ||
| QUICKSTART.md | ||
| README.md | ||
| uv.lock | ||
Real-Time Todo App with Stario
A feature-rich todo application built with Stario, Datastar, and SQLite, featuring real-time collaboration, presence tracking, and JWT authentication.
Features
- Multiple Todo Apps: Create and manage multiple todo lists
- Real-Time Collaboration: See changes instantly with SSE streaming
- Presence Tracking: See who's viewing each todo app
- JWT Authentication: Simple token-based auth (user-managed tokens)
- Visibility Settings:
- 🔒 Private - Only you can see and edit
- 🌍 Public - Anyone can view
- 👥 Shared - Anyone can view (read-only)
- CQRS Architecture: Clean separation of commands and queries
- Turso SQLite: Fast, embedded database with SQLAlchemy
Tech Stack
- Stario: Python async web framework for real-time hypermedia
- Datastar: Reactive UI with SSE streaming and signals
- SQLAlchemy: Database ORM
- JWT: Token-based authentication
- Relay: In-memory pub/sub for real-time updates
Getting Started
Installation
# Install dependencies
uv sync
# The database will be created automatically on first run
Configuration
Edit .env to configure:
TURSO_DATABASE_URL=file:local.db
JWT_SECRET=your-secret-key-here
Running
# Start the development server
uv run stario watch main:bootstrap
# Or run once
uv run stario serve main:bootstrap
Visit http://localhost:8000
Usage
Creating an Account
- Click "Create Account"
- Enter a username
- Important: Save your JWT token securely! You'll need it to log in.
Logging In
- Paste your JWT token
- Click "Login"
Creating Todo Apps
- Click "+ Create New Todo App"
- Enter name and description
- Choose visibility (private/public/shared)
Managing Todos
- Add items with the input field
- Click checkboxes to complete/uncomplete
- Click 🗑️ to delete items
- Use Settings to edit app details or visibility
Real-Time Features
- Open the same todo app in multiple browser windows
- See presence indicators showing who's viewing
- Changes appear instantly for all viewers
Project Structure
├── domain/ # Entities and business logic
│ ├── entities.py # User, TodoApp, TodoItem
│ └── presence.py # Presence tracking
├── infrastructure/ # External concerns
│ ├── database.py # SQLAlchemy setup
│ ├── jwt.py # JWT utilities
│ ├── presence.py # Presence tracker
│ └── repositories.py # Data access layer
├── commands/ # CQRS: Write operations
│ ├── schema.py # Command DTOs
│ ├── create_user.py
│ ├── todo_app_handlers.py
│ └── todo_item_handlers.py
├── queries/ # CQRS: Read operations
│ ├── schema.py # Query DTOs
│ └── handlers.py # Query handlers
├── presentation/ # Views and HTTP handlers
│ ├── views.py # HTML components
│ ├── handlers.py # HTTP handlers
│ └── signals.py # Signal schemas
├── static/ # Static assets
│ ├── css/style.css
│ └── js/datastar.js
├── config.py # Configuration
└── main.py # Bootstrap
API Endpoints
Authentication
POST /api/register- Create account and get JWTPOST /api/login- Login with JWT
Todo Apps
GET /- List my todo appsGET /public- Browse public appsGET /apps/:id- View todo appPOST /api/apps- Create new appPOST /api/apps/:id/update- Update appPOST /api/apps/:id/delete- Delete appGET /api/apps/:id/subscribe- SSE for real-time updates
Todo Items
POST /api/apps/:id/items- Add itemPOST /api/todos/:id/toggle- Toggle completionPOST /api/todos/:id/delete- Delete item
Architecture
CQRS Pattern
Separates read and write operations:
- Commands: Create, update, delete (write to DB)
- Queries: Read-optimized, return DTOs
Real-Time Updates
- Client connects via SSE to
/api/apps/:id/subscribe - Server sends initial state as HTML patch
- On any change, command publishes to Relay
- All subscribers receive updated state
Presence Tracking
- On SSE connect, user joins presence tracker
- Tracker shows who's viewing each app
- Auto-removes stale connections after 30s
Development
Adding New Features
- Domain: Add entities to
domain/ - Commands: Create command in
commands/, add handler - Queries: Create query in
queries/, add handler - Views: Add UI in
presentation/views.py - Routes: Wire up in
main.py
Database Migrations
Currently using auto-migration. For production, use Alembic.
License
MIT
Notes
- JWT tokens are self-managed by users (like API keys)
- Uses SQLite by default, configurable for Turso
- All data persists in
local.db - Real-time via SSE (no WebSockets needed)
- No frontend framework - pure HTML/Datastar