This repository contains a minimal Piccolo ORM + FastAPI project with:
- Category and Todo entities.
- Auto-generated JSON API endpoints using piccolo_api.
- Built-in Piccolo admin mounted with
piccolo_admin(no custom admin templates needed).
It includes two Expo frontends:
frontend/(main Expo frontend)my-new-expo-app/(OpenAPI scaffolded Expo frontend)
The project uses these entities:
- Category
- Todo
Todo fields:
- task
- user (foreign key to BaseUser)
- category (foreign key to Category)
- done
- FastAPI
- Piccolo ORM
- SQLite (default local database)
- piccolo_admin
- piccolo_api
- Expo (frontend)
- Python 3.10+
- Node.js 18+ and npm
From the project root:
-
Backend dependencies:
python -m pip install -r requirements.txt
-
Frontend dependencies:
cd frontend npm install cd ../my-new-expo-app npm install cd ..
-
Start the API server from the project root:
python -m uvicorn app:app --reload
-
Open in browser:
- Admin UI: http://127.0.0.1:8000/admin
- API docs: http://127.0.0.1:8000/docs
-
Start Expo on port 8081:
cd frontend npx expo start --web --port 8081 --host localhost -
Press
wto open in the browser, or scan the QR code with Expo Go.
-
Start Expo on port 8181:
cd my-new-expo-app npx expo start --web --port 8181 --host localhost -
Press
wto open in the browser, or scan the QR code with Expo Go.
Use three terminals from the project root:
-
Terminal 1 (backend):
python -m uvicorn app:app --reload
-
Terminal 2 (frontend):
cd frontend npx expo start --web --port 8081 --host localhost -
Terminal 3 (my-new-expo-app):
cd my-new-expo-app npx expo start --web --port 8181 --host localhost
If running in Codespaces, ensure ports 8000 (backend), 5300 (my-new-app), 8081 (frontend Expo), and 8181 (my-new-expo-app Expo) are forwarded.
The repository also includes a Refine + Ant Design frontend in refine/.
-
Start backend API from the project root:
/home/codespace/.python/current/bin/python -m uvicorn app:app --reload
-
In a second terminal, start Refine frontend:
cd refine npm install npm run dev -
Open the local URL shown by Vite (typically
http://localhost:5170).
Notes:
- In development,
refine/vite.config.tsproxies/apitohttp://localhost:8000. - If backend runs on a different host, set
VITE_API_URLfor production builds. - Category management is intentionally kept in
/admin; user-facing frontends only consume category data.
The repository includes an OpenAPI-to-React scaffold tool in scripts/scaffold-openapi/.
It generates a standalone React app from your live API schema, including:
- Login and register UI
- Per-entity pages under
src/entities/ - List and edit routes for editable resources
- Foreign key dropdowns (for example category selectors)
-
Start backend API from the project root:
python -m uvicorn app:app --reload
-
Build the scaffold tool:
cd scripts/scaffold-openapi npm install npm run build cd ../..
-
Generate an app from the OpenAPI schema:
node ./scripts/scaffold-openapi/dist/index.js create http://localhost:8000/openapi.json ./my-new-app --app-name "Piccolo Todo" -
Install and run the generated app:
cd my-new-app npm install npm run dev -
Open the Vite URL shown in the terminal (typically
http://localhost:5300).
This app is listed on the home page as OpenAPI Frontend (my-new-app).
If you see an error like ENOENT: process.cwd failed, run commands from the repository root before deleting / regenerating my-new-app.
Safe pattern:
cd /workspaces/python-piccolo-todo
rm -rf ./my-new-app
node ./scripts/scaffold-openapi/dist/index.js create http://localhost:8000/openapi.json ./my-new-app --app-name "Piccolo Todo"The repository also includes an OpenAPI-to-Expo scaffold tool in scripts/scaffold-openapi-expo/.
It generates an Expo Router app from your API schema, including:
- Login and register screens
- Per-resource list screens
- Per-resource edit screens (for resources with update endpoints)
- Field-aware controls (
TextInput,Switch, and simple FK selectors)
-
Start backend API from the project root:
python -m uvicorn app:app --reload
-
Build the Expo scaffold tool:
cd scripts/scaffold-openapi-expo npm install npm run build cd ../..
-
Generate an Expo app from OpenAPI schema:
node ./scripts/scaffold-openapi-expo/dist/index.js create http://localhost:8000/openapi.json ./my-new-expo-app --app-name "Piccolo Todo Expo" -
Install and run the generated Expo app:
cd my-new-expo-app npm install npm run web -- --port 8181 --host localhostIn Codespaces, you can use:
npm run web:codespaces
This auto-sets
EXPO_PUBLIC_API_URLto your forwarded backend URL when not already set. The Codespaces helper also runs Expo Web on port8181to avoid conflict withfrontend/.
Notes:
- For native devices, set
EXPO_PUBLIC_API_URLin the generated.envfile so the app can reach your backend. - Session auth is cookie-based in this project; web works best out of the box.
The following endpoint groups are mounted and documented in Swagger:
- /api/categories/
- /api/todos/
Each group includes standard CRUD operations from PiccoloCRUD, such as list, create, detail, update, and delete.
- app.py: FastAPI app, auto API wrappers, admin mount.
- tables.py: Piccolo table definitions.
- piccolo_conf.py: Piccolo engine configuration.