How shewaks/glucosafe works
GlucoSafe is a diabetes-management platform for patients and guardians: users sign in, then record and review glucose-related data, assess hypoglycemia risk, use food and meal tools, or monitor linked patients. The React client calls a FastAPI backend that exposes authentication, telemetry, prediction, food, guardian, and chat capabilities backed by MongoDB and ML services. The tree also contains a separate backend/app implementation; its sampled database uses SQLite, unlike the README-documented MongoDB backend. Some feature-to-service wiring is therefore left unspecified.
Main entry points: main.py FastAPI entry · api.js API client · connection.py Database access · auth.py Authentication routes
Components 27
Web application
- React application
frontend/src/App.jsx - Session state
frontend/src/context/AuthContext.jsx - API client
frontend/src/services/api.js - Patient views
frontend/src/pages/Dashboard.jsx - Food recognition
frontend/src/pages/FoodRecognition.jsx - History and support
frontend/src/pages/History.jsx - Guardian portal
frontend/src/pages/GuardianPortal.jsx
Unified API
- FastAPI entry
backend/main.py - Authentication routes
backend/routes/auth.py - Patient telemetry
backend/routes/patient.py - Guardian monitoring
backend/routes/guardian.py - Risk assessment
backend/routes/predict.py - Food endpoints
backend/routes/food.py - Real-time hypo risk
backend/routes/hypo_risk.py - Chat endpoint
backend/routes/chat.py - Chat assistant
backend/services/chat_service.py
Patient health features
- Hypoglycemia model
backend/services/hypoglycemia_service.py - Food ML and bolus
backend/services/food_ml_service.py
Identity and persistence
- Auth guards
backend/auth/dependencies.py - Token security
backend/auth/security.py - MongoDB
- Database access
backend/database/connection.py
Alternate app implementation
- Alternate FastAPI app
backend/app/main.py - SQLite database
backend/app/database.py - Alternate app config
backend/app/config.py
Other components
- Patient
- Guardian
Connections 38
- Patient → React application: uses
frontend/src/App.jsx - Guardian → React application: uses
frontend/src/App.jsx - React application → Session state: provides session
frontend/src/App.jsx - Session state → API client: authenticates through
frontend/src/context/AuthContext.jsx - Patient views → API client: requests data
frontend/src/pages/Dashboard.jsx - Food recognition → API client: requests food analysis
frontend/src/pages/FoodRecognition.jsx - History and support → API client: requests history
frontend/src/pages/History.jsx - Guardian portal → API client: requests monitoring
- API client → Authentication routes: calls auth endpoints
frontend/src/services/api.js - API client → Patient telemetry: calls patient endpoints
frontend/src/services/api.js - API client → Guardian monitoring: calls guardian endpoints
frontend/src/services/api.js - API client → Food endpoints: calls food endpoints
frontend/src/services/api.js - FastAPI entry → Authentication routes: registers router
backend/main.py - FastAPI entry → Patient telemetry: registers router
backend/main.py - FastAPI entry → Guardian monitoring: registers router
backend/main.py - FastAPI entry → Risk assessment: registers router
backend/main.py - FastAPI entry → Food endpoints: registers router
backend/main.py - FastAPI entry → Real-time hypo risk: registers router
backend/main.py - FastAPI entry → Chat endpoint: registers router
backend/main.py - Chat endpoint → Chat assistant: delegates to
backend/routes/chat.py - Authentication routes → Auth guards: authenticates with
backend/routes/auth.py - Auth guards → Token security: verifies tokens
backend/auth/dependencies.py - Auth guards → Database access: loads users
backend/auth/dependencies.py - Authentication routes → Database access: reads and writes users
backend/routes/auth.py - Patient telemetry → Database access: reads and writes telemetry
backend/routes/patient.py - Guardian monitoring → Database access: reads patient data
backend/routes/guardian.py - Food endpoints → Database access: searches foods
backend/routes/food.py - FastAPI entry → Database access: initializes database
backend/main.py - Database access → MongoDB: persists data
backend/database/connection.py - FastAPI entry → Hypoglycemia model: loads model service
backend/main.py - FastAPI entry → Food ML and bolus: loads model service
backend/main.py - Risk assessment → Hypoglycemia model: uses for prediction
- Food endpoints → Food ML and bolus: uses for food analysis
- Real-time hypo risk → Food ML and bolus: uses for risk forecast
- FastAPI entry → Alternate FastAPI app: separate implementation
- Alternate FastAPI app → SQLite database: uses database
backend/app/main.py - Alternate FastAPI app → Alternate app config: loads configuration
backend/app/main.py - SQLite database → Alternate app config: uses project path
backend/app/database.py