Skip to content

PostmanLone/Backend-Prototype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Student Tracking API (FastAPI) — Cloud Deployment (Public Internet)

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).


Step-by-step (Render.com example)

1) Push this folder to a GitHub repo

  • Create a new repo, e.g., student-tracking-api
  • Add all files and push

2) Create a web service on Render

  • 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 like https://student-tracking-api.onrender.com

3) Add environment variables (optional now; required later for JWT/DB)

  • JWT_SECRET — set a strong random string (not used in demo logic but good to add)
  • RETENTION_DAYS — e.g., 3

4) Wait for deploy to finish, then test

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.

5) Point your iPhone app to the public URL

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.


Local run (optional)

pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

API root: http://127.0.0.1:8000


Endpoints implemented

  • 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.


Next steps (production hardening)

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published