đźš§ Service Unavailable
gosave is currently down due to issues with the VPS hosting provider.
I'm working to resolve this and will restore service as soon as possible.
Thank you for your patience!
GoSave is a PWA built using a React and Vite Frontend and a Flask Backend & API which helps users take their pill regularly by introducing regular reminders, flexible Notifications, Logs and Features like reminding based on location. You can try GoSave at gosave.pro. (Note: New Features/Bug Fixes will be available on the website first and will be pushed to the public repo after)
This section explains the frontend code for the Progressive Web App (PWA) designed to help users manage their pill intake schedule efficiently. The Frontend is built using React and Vite, and it leverages Firebase for notifications and backend communication.
- Progressive Web App (PWA): GoSave is a PWA, which means it can be installed on your device and used offline.
- Location-Based Reminders: The app can remind users to take their pills when they arrive home using location-based triggers.
- Timezone Awareness: The app is fully timezone-aware, ensuring notifications are sent at the correct local time.
- Firebase Cloud Messaging: Utilizes Firebase for push notifications, ensuring users receive timely reminders.
- Responsive Design: Built with Tailwind CSS and DaisyUI, the app is fully responsive and works on all device sizes.
- User-Friendly Interface: The app features a clean and intuitive interface, making it easy for users to manage their pill intake schedule.
To get started with the GoSave frontend, follow these steps:
To get started with the GoSave frontend, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/gosave.git cd gosave/Frontend
-
Add Configuration
- go into
firebase-messaging-sw.js
andfirebase.js
and paste in your Firebase Config. - go into the Notification.jsx Component and paste in your VapidKey
- go into
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Build for production:
npm run build
-
Preview the production build:
npm run preview
Once the app is running, you can access it in your browser. The app will guide you through setting up your pill intake schedule, including setting reminders for when you arrive home.
The app is composed of several key components:
- Home: The main dashboard where users can see their pill schedule and manage settings.
- RemindHome: Handles the logic for reminding users when they arrive home.
- InfoRemindHome: Provides a guide for setting up location-based reminders using iPhone Shortcuts.
- ChangeIntakeTime: Allows users to temporarily change their pill intake time.
- NextNotification: Displays the next scheduled notification time.
- SettingsPanel: Provides access to user settings, including theme changes and cycle settings.
The app includes a service worker for handling background tasks and notifications. The service worker is registered in main.jsx
and is responsible for managing Firebase Cloud Messaging.
GoSave uses Firebase for push notifications. The Firebase configuration is set up in firebase.js
, and the service worker script is located in firebase-messaging-sw.js
.
import { initializeApp } from "firebase/app";
import { getMessaging } from "firebase/messaging";
const firebaseConfig = {
"YOUR FIREBASE CONFIG"
}
const app = initializeApp(firebaseConfig)
const messaging = getMessaging(app)
export { messaging }
This API is designed to manage users' pill reminders by handling notifications, tracking pill intake, and managing user data. The system is based on Flask and SQLAlchemy for the backend, Firebase for notifications, and APScheduler for managing scheduled tasks.
- Python 3.8+
- Firebase Admin SDK (for notification purposes)
- SQLite (as the database)
- Flask framework and related dependencies
- APScheduler (for managing scheduled tasks)
- Backend Installation
- API Endpoints
- Database Structure
- Scheduler
- Error Handling
- Firebase Notifications
- Time Zones
-
Clone the repository:
git clone <repository_url> cd <repository_name>
-
Create and activate a virtual environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up Firebase Admin SDK:
- Place your Firebase Admin SDK JSON file in the
config/
folder with the nameaccount_key.json
.
- Place your Firebase Admin SDK JSON file in the
-
Run the application:
python app.py
-
Verify installation:
- Open a browser or tool like Postman and navigate to
http://127.0.0.1:5000/
. You should see a message confirming that the server is up and running.
- Open a browser or tool like Postman and navigate to
Checks if the server is running.
{
"message": "The server is up and running!"
}
Creates or updates a user in the database. If the user already exists, it updates their data (FCM token, intake time, pill cycle, etc.).
{
"fcmToken": "string", // Firebase Cloud Messaging Token
"timezone": "string", // User's timezone, e.g., "Europe/Berlin"
"intakeTime": "HH:MM", // Optional: intake time in 24-hour format
"cycleData": { // Optional: pill cycle data
"pillDays": int,
"breakDays": int,
"startDate": "YYYY-MM-DD"
}
}
- 201 Created: User added successfully
- 200 OK: User data updated successfully
- 400 Bad Request: Missing required fields or invalid format
Fetches the data of a specific user by their FCM token.
fcmToken
(required): Firebase Cloud Messaging token to identify the user.
{
"user": {
"fcmToken": "string",
"intakeTime": "HH:MM",
"timezone": "string",
"cycleData": {
"pillDays": int,
"breakDays": int,
"startDate": "YYYY-MM-DD"
}
}
}
- 200 OK: User data returned successfully
- 404 Not Found: User with the specified token not found
- 400 Bad Request: Missing
fcmToken
query parameter
Saves a user's FCM token to the database if it doesn't already exist.
{
"fcmToken": "string"
}
- 201 Created: Token saved successfully
- 200 OK: Token already exists
- 400 Bad Request: Missing or invalid
fcmToken
Determines whether today is a pill day for the user based on their pill cycle.
{
"fcmToken": "string"
}
{
"isPillDay": true/false
}
- 200 OK: Result returned successfully
- 404 Not Found: User with the specified token not found
- 400 Bad Request: Missing
fcmToken
Updates whether the user has taken their pill for the day.
{
"fcmToken": "string",
"isPillTaken": true/false
}
- 200 OK: Status updated successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing required fields or invalid data
Fetches whether the user has taken their pill for the day.
fcmToken
(required): Firebase Cloud Messaging token.
{
"pillTaken": true/false
}
- 200 OK: Status returned successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing
fcmToken
Schedules notifications for a user's pill intake time.
{
"fcmToken": "string",
"intakeTime": "HH:MM",
"interval": true/false // Whether to notify at intervals before intake time
}
- 200 OK: Notifications scheduled successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing or invalid data
Sets the user to be reminded to take their pill when they arrive home.
{
"fcmToken": "string",
"waitingForHome": true/false,
"isHome": true/false // Whether the user has arrived home
}
- 200 OK: Reminder set or reset successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing or invalid data
Checks whether the user is waiting for a reminder when they get home.
fcmToken
(required): Firebase Cloud Messaging token.
{
"waitingForHome": true/false
}
- 200 OK: Status returned successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing
fcmToken
Returns the next scheduled notification time for the user.
fcmToken
(required): Firebase Cloud Messaging token.
{
"next_notification": "HH:MM" // Time of the next notification
}
- 200 OK: Time returned successfully
- 404 Not Found: User or notifications not found
- 400 Bad Request: Missing
fcmToken
Fetches the user's pill logs for the last two cycles.
fcmToken
(required): Firebase Cloud Messaging token.
{
"pillLogs": [
{
"day_of_week": "Monday",
"calendar_date": "YYYY-MM-DD",
"is_pill_day": true/false,
"pill_taken_time": "HH:MM:SS",
"pillTaken": true/false
},
...
]
}
- 200 OK: Logs returned successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing
fcmToken
For testing purposes, allows creation or updating of pill logs.
{
"fcmToken": "string",
"pillTaken": true/false,
"date": "YYYY-MM-DD" // Optional: Log for a specific date
}
- 200 OK: Log created or updated successfully
- 404 Not Found: User not found
- 400 Bad Request: Missing or invalid data
Column | Type | Description |
---|---|---|
id | Integer | Primary key |
fcm_token | String | Unique Firebase Cloud Messaging token |
intake_time | String | Time of pill intake in HH:MM format |
pill_days | Integer | Number of pill days in a cycle |
break_days | Integer | Number of break days in a cycle |
start_date | String | Start date of the user's pill cycle (YYYY-MM-DD) |
is_pill_taken | Boolean | Whether the user has taken their pill today |
timezone | String | User's timezone |
waiting_for_home | Boolean | Whether the user is waiting for a home reminder |
Column | Type | Description |
---|---|---|
id | Integer | Primary key |
user_id | Integer | Foreign key to the User table |
day_of_week | Enum | Day of the week (Monday-Sunday) |
calendar_date | Date | The actual date of the log (YYYY-MM-DD) |
is_pill_day | Boolean | Whether it was a pill day |
pill_taken_time | Time | Time when the pill was taken |
pill_taken | Boolean | Whether the pill was taken |
- Runs at midnight every day.
- Resets users'
is_pill_taken
toFalse
. - Schedules the next day's notifications for pill users.
- Pre-intake Notifications: Scheduled 2 hours before pill intake, with reminders every 30 minutes.
- Post-intake Notifications: Continue for 2 hours after the intake time, with reminders every 15 minutes.
- 400 Bad Request: Returned when required fields are missing or data is invalid (e.g., invalid time or date format).
- 404 Not Found: Returned when a user or resource is not found in the database.
The API sends notifications via Firebase Cloud Messaging (FCM) to remind users about their pill intake. Notifications are scheduled dynamically based on the user's intake time and pill cycle.
All time-related operations are handled based on the user's specified time zone. The API supports time zone localization using pytz
.
This API is fully equipped to handle pill reminder logic, notification scheduling, and user data management. The flexible architecture supports expansion for additional features such as multiple reminder types and advanced analytics.
Contributions are welcome! If you'd like to contribute to GoSave, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you for using GoSave! I hope this app helps you manage your pill intake schedule effectively. If you have any questions or feedback, please feel free to reach out.