Thank you. I have enough context to begin a first-pass analysis, but before giving implementation instructions I want to clarify a few things so I don't make assumptions. I will ask rather than infer. Questions I need answered before designing the saved-search/email-alert system 1. Email system Do you already have email sending configured? If yes, please send: The file that sends emails (for example mail.php, email.php, PHPMailer setup, etc.) Any configuration in includes/config.php related to email If no, tell me: Do you want to use PHP mail()? Or a service like SMTP / Gmail / SendGrid / Mailgun / Amazon SES? I don't want to choose an email method without knowing your preference. 2. Who receives saved searches? Should saved searches belong to: Option A — Individual users users.user_id | | saved_searches.user_id Meaning: Vergil creates a search Only Vergil sees it Only Vergil gets emails Option B — Organizations organizations.organization_id | | saved_searches.organization_id Meaning: One company account can have multiple users Searches belong to the company Multiple users could receive alerts Your database already has organizations, but I do not want to assume your intended account model. Which one? 3. Email frequency You currently have: */5 * * * * update_database.php Do you want saved searches checked: A. Every 5 minutes after permits update? Example: Every 5 minutes: update_database.php check_saved_searches.php B. Once per day? Example: 2:00 AM: check_saved_searches.php C. Something else? 4. What counts as a "new permit"? I need your rule. Example: User saves: Trade: Electrical Cost: $50,000+ ZIP: 60618 Permit appears Monday. Cron runs. Email sends. Tuesday: Same permit still matches. Should Tuesday send another email? I assume no, but I need confirmation. Possible tracking methods: A. Track by: permit_number B. Track by: building_permits.id C. Something else? 5. Saved search page Where do you want users to manage searches? Currently you have: index.php permit_notes.php Do you want: saved_searches.php with: View saved searches Edit Delete Run now Enable/disable emails Or do you want it integrated into index.php? 6. Saving current filters Your current filters are: cost sort include ZIPs exclude ZIPs trade Do you want saved searches to include: Sort order? Example: "Newest first" or should saved searches only save the filtering criteria? I would normally not save sorting because alerts don't need sorting, but I won't assume. 7. Email content You mentioned earlier: Don't email permit details. Make them log in. Please confirm the email should be something like: Subject: New permit opportunities found Body: Your saved search "Electrical Over $50k" found 12 new permits. Login to view them: [button/link] No contractor/address/cost details? 8. Existing notes relationship Your notes system uses: permit_number in JavaScript: createNotesPanel(row.permit_number) Should saved searches also use permit_number as the identifier? Or should I switch the new feature to use: building_permits.id because it is the database primary key? I need your preference because this affects the tables. 9. Subscription rules You have: organizations.subscription_status trial Should saved-search emails: A. Work during trial only? B. Require active subscription? C. No subscription restrictions yet? 10. Security preference Your API pattern currently uses: require_api_login(); Should the new endpoints follow the same pattern? For example: api/searches/save_saved_search.php api/searches/get_saved_searches.php api/searches/delete_saved_search.php Once you answer these, I can give you a detailed implementation plan with exact file paths and exact insertion points, for example: CREATE: /api/searches/save_saved_search.php MODIFY: /assets/js/app.js Find: function loadPermits(){ Add code immediately after: ... } DATABASE: Run this SQL: ... I will avoid filling in missing decisions myself. 1. I do not have email sending configured. I will use the Postmark email service. 2. Individual users receive saved searches. 3. For now we can leave the cron set to run every 5 minutes while in development. Later when I am in production I will change it to run at a specified time overnight. 4. My code checks either the permit_number or building_permits.id I think, against the my building_permits table to ensure permits are not duplicated in the download. I think that check is in update_database.php. But I am not sending permit info in the email. I am only sending a link in the email for the user to log into the app and click on their saved search button which will apply the filter criteria that was saved and produce the permits that match the filter criteria. So the saved search will have to run in the cron job and only if there is at least one match will it send an email for the user to log in to see their permit data. If there is no match an email will be sent saying something like 'Sorry no permits match your search criteria today'. Probaly tracking by building_permits.id. 5. For saved searches lets have a button on the dashboard that says saved searches that, when clicked will display a list of the search criterial that was save and a button next to it that says apply filter. when that button is clicked it will apply the filter criteria to the search fields on the index.php and fire the apply filters button on the dashboard/index.php. yes lets have View saved searches on the dashboard and when the modal opens it will have buttons to edit, delete, run now and enable/disable emails. 6. sort order should be newest first, and they are only saving the filtering criteria. If a user want to save a particular permit, they need to make a note on it. Thats what the notes are for, they also act as a way to save permits. I am saving sorting so that the user doesn't have to keep entering zip codes and trades etc every time the do a search and It gives me the criteria I need to run a cron job on that particular sort criteria. 7. That is correct, no contractor details, just alerting the user there are permits that match their sort criteria. Subject: New permit opportunities found Body: Your saved search "Electrical Over $50k" found 12 new permits. Login to view them: [button/link]. 8. Saved searches are only saving sort criteria not permit data, so the saved searches can have their on identifier. 9. No subsrcription restrictions yet. 10. Yes follow same pattern.