Table of Contents
- DiabetesAlertSystem
- Project Overview
- Key Features
- Screenshots
- Technology Stack
- Repository structure (high-level)
- Quick Start — Local Development
- Configuration & Environment
- Database
- API Reference (summary)
- Testing
- Building & Release
- Contributing
- Security & Privacy Notes
- License
- Contact / Maintainers
- Appendix — Useful commands & tips
A smart diabetes management application — cross-platform mobile frontend built with Flutter (Dart) and a lightweight PHP + MySQL backend. Features real-time blood sugar tracking, configurable alerts, medication reminders, activity logs, and simple REST-style endpoints to enable integration with other systems.
This document provides a clear project overview, technical architecture, deployment and development instructions, API references, and contribution guidelines suitable for professional audiences (maintainers, reviewers, and developers).
DiabetesAlertSystem is a cross-platform mobile application for tracking and managing diabetes-related health metrics. The app lets patients record metrics (blood sugar, blood pressure, heart rate), receive alerts, store medication schedules, and view historical metrics. The backend is a lightweight PHP-based API that stores users, metrics, alarms and medication records in a MySQL database.
This repository contains:
- Flutter app source (src/diabetes_alert_system/)
- PHP backend API (src/backend/)
- SQL schema and seed data (src/backend/database/)
- Supporting scripts and utilities
Before making the repository public, ensure all secrets are removed from source control (see Security & Privacy Notes).
- User authentication endpoints (login/signup flows).
- Persistent user metrics (blood sugar, blood pressure, heart rate).
- Alarm management (create/view/remove alarms).
- Medication records and simple CRUD.
- A Flutter frontend with organized screens and controllers.
- Lightweight PHP backend using PDO with JSON responses.
- Exportable SQL schema to easily initialize a database.
| Splash Animation 1 | Splash Animation 2 | Registration Screen | Email Verification Screen | Success Registration Screen |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Login Screen | Forget Password Screen | Verification Code Screen | Reset Password Screen | Password Reset Success Screen |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Bottom Navigation | Custom Drawer Open | Medication List Screen 1 | Medication List Screen 2 | Add Medication Bottom Dialog |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Delete Confirmation Dialog | Health Metrics List — Screen 1 | Health Metrics List — Screen 2 | Add Medication Dialog (add metric) | Result of Adding Metric |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Delete Confirmation (metric) | Result of Deleting Metric | Health Metric Guidance — Pop-up 1 | Health Metric Guidance — Pop-up 2 | Alarm List 1 |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Alarm List 2 | Add Alarm Screen | Add Alarm Screen (Time Picker) | Ringing Alarm | Notification |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Challenge Screen | After Finish Challenge | Delete Confirmation (alarm) | Result of Deleting Alarm | Activity List — Screen 1 |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Activity List — Screen 2 | Add Activity (before selecting a type) | Add Activity | Add Activity (Stopwatch) | Activity added successfully |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
| Dashboard — Overview | Home — Quick Actions opens | Home — Scrolling 1 | Home — Scrolling 2 | Loading |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
- Frontend: Flutter (Dart) — located at
src/diabetes_alert_system/(containslib/,pubspec.yaml,assets/). - Backend: Plain PHP (PDO) — located at
src/backend/(PHP controllers / endpoints). - Database: MySQL (schema SQL files in
src/backend/database/). - Email: PHPMailer (bundled in backend includes).
- Optional: any third-party API keys are read from environment variables.
The repository is organized to separate the mobile app from the server API:
DiabetesAlertSystem/
├─ LICENSE
├─ README.md
├─ .gitignore
└─ src/
├─ diabetes_alert_system/ # Flutter app
│ ├─ lib/ # Flutter source code (UI, controllers, services)
│ ├─ pubspec.yaml
│ └─ assets/
└─ backend/ # PHP backend (small REST-style endpoints)
├─ auth/ # authentication endpoints (e.g., login.php)
├─ alarms/ # alarm endpoints (view.php, remove.php)
├─ metrics/ # metrics endpoints (add.php)
├─ database/ # SQL schema and seed files (e.g., medications.sql)
├─ includes/ # PHPMailer and helpers
├─ connect.php # DB connection and environment loader
├─ env.php # .env file loader
└─ .env # (DO NOT commit to public repo) environment values
Note: The exact file listing may be larger — inspect the repository UI for a complete file tree.
These instructions help contributors run the system locally. They are intentionally explicit to onboard new developers quickly.
- Flutter SDK (stable; recommended matching the project channel in
.metadata). - Android Studio / Xcode or another device/emulator to run the Flutter app.
- PHP 7.4+ with PDO MySQL extension enabled.
- MySQL / MariaDB server.
- A local web server environment (XAMPP, MAMP, LAMP) or Docker for the PHP backend.
- curl or Postman for testing API endpoints.
-
Place the backend into a web-accessible directory. Example:
- Linux:
/var/www/html/diabetes-backend - Windows (XAMPP):
C:\xampp\htdocs\diabetes-backend
- Linux:
-
Import the database schema:
-
Using MySQL CLI:
mysql -u root -p < src/backend/database/medications.sql(This imports the medications table and seed data — import any additional
.sqlfiles found insrc/backend/database/.) -
Using phpMyAdmin:
- Create a database (e.g.,
diabetes_alert_system), set collation toutf8mb4_unicode_ci. - Import the
.sqlfiles via phpMyAdmin -> Import.
- Create a database (e.g.,
-
-
Configure environment variables:
- Create a
.envfile insrc/backend/(do NOT commit this to public repo) with the following variables:DB_HOST=127.0.0.1 DB_NAME=diabetes_alert_system DB_USER=root DB_PASSWORD=your_db_password SMTP_USER=your_smtp_user@example.com SMTP_PASSWORD=your_smtp_password - The backend includes
env.phpto load this file at runtime.
- Create a
-
File permissions:
- Ensure the webserver user can read
connect.php,env.phpand write to any upload directories if used.
- Ensure the webserver user can read
-
Test an endpoint (adjust URL based on your server):
curl -X POST "http://localhost/diabetes-backend/auth/login.php" \ -F "email=alice@example.com" -F "password=secret" -
Quick PHP built-in server (for small-scale testing):
cd src/backend php -S 0.0.0.0:8000 # then point your Flutter app API_BASE_URL to http://<host>:8000/
-
Open
src/diabetes_alert_system/in your IDE. -
Update backend base URL:
- Locate the code that stores the API base URL (commonly in a
lib/linkapi.dartor similar file). Update it to the backend address you configured (local or remote). - Example:
static const String server = "http://YOUR_SERVER_ADDRESS/diabetes-backend/";
- Locate the code that stores the API base URL (commonly in a
-
(Optional) Add environment variables if used (create
.envinsrc/diabetes_alert_system/next topubspec.yamlif the project reads from it):API_BASE_URL=http://YOUR_SERVER_ADDRESS/diabetes-backend/ OTHER_API_KEYS=... -
Install packages and run:
cd src/diabetes_alert_system flutter pub get flutter run -
For emulator network mapping:
- Android emulator: host machine is reachable at
10.0.2.2(if you run PHP server on the same machine). - Physical device: use machine LAN IP (e.g.,
http://192.168.1.10/diabetes-backend/).
- Android emulator: host machine is reachable at
-
Backend
.env(create locally; DO NOT commit):DB_HOST=127.0.0.1 DB_NAME=diabetes_alert_system DB_USER=root DB_PASSWORD=your_db_password SMTP_USER=youremail@example.com SMTP_PASSWORD=your_smtp_password -
Frontend optional
.env(next topubspec.yaml):API_BASE_URL=http://YOUR_SERVER_ADDRESS/diabetes-backend/ OTHER_KEYS=... -
Update any server constants in frontend source (e.g.,
lib/linkapi.dart) if the project does not read from environment.
- SQL files are stored under
src/backend/database/. Example:medications.sql. - Typical tables to expect:
users,metrics,alarms(oralarmsrelated views),medications. - After import, verify tables and seed data via your database client.
Base URL (example):
http://<your-host>/diabetes-backend/
Note: The backend exposes small PHP endpoint scripts. All POST endpoints accept form-encoded data; file uploads use multipart/form-data. Responses are JSON objects with status and optional data.
Authentication:
auth/login.php(POST) — params:email,password(note: password may be hashed with sha1 in current implementation). Returns user record on success.
Alarms / Notifications:
alarms/view.php(POST) — params:id(user id) — returns alarms/metrics view for user.alarms/remove.php(POST) — params:id(alarm id) — deletes a single alarm.alarms/removeall.php(POST) — params:id(user id) — remove all alarms for a user.
Metrics:
metrics/add.php(POST) — params includeid(user id),metric_type(e.g., "Blood Sugar", "Blood Pressure", "Heart Rate"),value1,value2(optional for BP). Stores a metric and returns status.
Medications:
- SQL and seed available at
src/backend/database/medications.sql. Backend endpoints for CRUD on medications may exist — inspectsrc/backend/for specific files.
Utility:
connect.php— sets up PDO connection, CORS headers and includesfunctions.php.functions.php— contains helpers (filterRequest, getData, insertData, getAllData, etc.) and PHPMailer integration.
Important: The above is a summary from repository inspection; for an exhaustive list, browse src/backend/ and grep for <?php endpoints.
- Manual testing: Use Postman or curl to call endpoints.
- E2E: Run Flutter in debug and exercise UI flows (login, add metrics, create alarms).
- Unit tests: The Flutter project currently does not include unit/widget tests by default. Add tests under
src/diabetes_alert_system/test/for critical logic. - Backend tests: None included — consider adding PHPUnit or integration tests that run against a test database.
- Android:
flutter build apk --releaseorflutter build appbundle - iOS:
flutter build ios(macOS + Xcode required) - Make sure to update frontend API base URL to production endpoint before building release artifacts.
Thank you for contributing. Suggested workflow:
- Fork the repository and create a feature branch (e.g.,
feature/metrics-export). - Commit changes in small, testable increments and include descriptive commit messages.
- Open a pull request and describe the change, include screenshots for UI updates.
- Add or update API contract docs if endpoint behavior changes.
Coding standards:
- Dart: follow official Dart/Flutter style guidelines.
- PHP: prefer prepared statements (PDO) and sanitize inputs (already using helpers like
filterRequest()in code).
- DO NOT publish
.envfiles or credentials. I foundsrc/backend/.envcommitted in the repo during inspection. That file includes SMTP credentials — remove it and rotate the exposed credentials immediately before making the repo public. - Remove any commits that contain secrets from repository history (use
git filter-repoor BFG Repo-Cleaner). Rotate credentials after removal. - Add
.envto.gitignore. - Sanitize and validate all user inputs server-side. The backend uses helper functions but review them for edge cases and injection risks.
- Use HTTPS for production API endpoints and secure SMTP configuration for email sending.
- Consider hashing passwords with a stronger algorithm (bcrypt/argon2) instead of sha1.
Suggested commands to scrub secrets:
- BFG:
bfg --delete-files .env git reflog expire --expire=now --all git gc --prune=now --aggressive - Or use
git filter-repoto remove sensitive files/strings.
This project is distributed under the MIT License. See LICENSE for full text.
- Owner / primary maintainer: GitHub: tawafmesar
- For issues, feature requests, or security disclosures: open an issue in this repository or contact the maintainer directly (email in AUTHORS/metadata if provided). If you exposed credentials and rotated them, list rotated secrets in a secure channel.
-
Import DB:
mysql -u <user> -p diabetes_alert_system < src/backend/database/medications.sql -
Run PHP built-in server:
cd src/backend php -S 0.0.0.0:8000 -
Flutter run:
cd src/diabetes_alert_system flutter pub get flutter run -
Remove
.envfrom history (example with BFG):bfg --delete-files .env git reflog expire --expire=now --all git gc --prune=now --aggressive -
Critical: remove and rotate credentials (SMTP, DB passwords) found in
src/backend/.envbefore making the repository public. If you want, I can produce a .gitignore and a short migration plan to remove secrets from history.












































