This is a mock FastAPI backend that matches the endpoints your iPhone app expects. Deploy it to the cloud so the mobile app works on any network (cellular included).
- Create a new repo, e.g.,
student-tracking-api
- Add all files and push
- Go to Render → New → Web Service
- Connect your GitHub repo
- Runtime: Docker
- Build Command: (leave empty for Docker)
- Start Command: (not needed; Dockerfile defines CMD)
- Region: pick closest
- Click Create Web Service
Render will build the Docker image using the provided
Dockerfile
and expose a public URL likehttps://student-tracking-api.onrender.com
JWT_SECRET
— set a strong random string (not used in demo logic but good to add)RETENTION_DAYS
— e.g.,3
Use curl or a browser:
# Auth (demo accepts any password)
curl -X POST https://<your-service>.onrender.com/auth/login -H "Content-Type: application/json" -d '{"email":"parent@example.com","password":"parent123"}'
# Copy the "access_token":"demo-token" from response, then:
curl "https://<your-service>.onrender.com/parent/child/current?student_id=S-001" -H "Authorization: Bearer demo-token"
You should see JSON with zone and updated time.
In the Expo app project (src/api.js
), set:
export let BASE_URL = 'https://<your-service>.onrender.com';
Rebuild/restart the app (Expo Go works fine). Now it works on any network.
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000
API root: http://127.0.0.1:8000
POST /auth/login
→{ access_token: "demo-token", user: { role, student_id? } }
GET /parent/child/current?student_id=...
(Bearer)GET /parent/alerts?student_id=...
(Bearer)GET /staff/students
(Bearer)GET /staff/zones
(Bearer)
These match the Expo prototype. Replace the demo data with your DB later.
- Replace demo token with JWT (short-lived access + refresh).
- Add database (Postgres/MySQL) and store students/zones/events.
- Enforce RBAC in every endpoint.
- Add HTTPS domain (CNAME your Render URL to
api.yourschool.org
). - Add rate limiting and audit logs.