SAARETOOLS Hybrid Modular Architecture Guide
Bookmark this page for future reference. It documents how tool.php, tools/, includes/tools.php, and assets/js/app.js work together—plus a live status tracker of all 42 tools.
1. How Every Tool Request Works (Step-by-Step)
1. Visitor URLtool.php?slug=emi-calculator
2. tool.php RouterReads $_GET['slug']
3. includes/tools.phpLoads Title, Tier, FAQs
4. Free / Pro Gatecan_access_tool($tool)
5A. tools/{slug}.phpIf file exists (Modular)
OR
5B. assets/js/app.jsFallback if not migrated yet
Why this Hybrid design is ideal: You manage header, footer, SEO meta tags, breadcrumbs, Free/Pro login gating, AdSense slots, and FAQs in one single file (tool.php), while each calculator's UI & JavaScript lives in its own isolated file inside tools/. A bug in one calculator can never break another calculator.
2. Project Folder & File Map
| File / Folder | Purpose & When to Edit |
|---|---|
includes/tools.php |
Master Tool Catalog. Stores every tool's slug, name, category, type, tier ('free' or 'pro'), formula, guide, and FAQs. Powers homepage cards, search, filters, related tools, and sitemap.php. |
tool.php |
Shared Wrapper & Hybrid Router. Checks Free/Pro access, loads tools/{slug}.php if present, otherwise falls back to assets/js/app.js. Edit this only when changing the global layout or AdSense slots. |
tools/{slug}.php |
Individual Modular Tools. Self-contained HTML + CSS + JS for one specific calculator (e.g., tools/emi-calculator.php). Always starts with the SAARETOOLS_TOOL_CONTEXT security check. |
tools/_template.php |
Starter Template. Copy and rename this file whenever you want to create a new modular tool. |
tools/.htaccess |
Security Shield. Blocks direct browser URLs like /tools/gratuity-calculator.php so visitors cannot bypass the Pro login gate in tool.php. |
assets/js/app.js |
Legacy Fallback Engine. Automatically runs any tool that hasn't been moved to tools/{slug}.php yet. |
includes/auth.php |
Visitor Auth & Tier Helpers. Provides is_logged_in(), is_pro_user(), and can_access_tool($tool). |
index.php & stopwatch.php |
Homepage & Stopwatch. Self-contained modern homepage featuring the top Stopwatch banner, Smart Arithmetic/Scientific Calculator, Length Converter, Weight Converter, and AdSense compliance brief. |
3. How to Add a Brand New Calculator (3 Minutes)
- Register in
includes/tools.php: Add an array entry with a unique slug (e.g.,'slug' => 'hra-calculator'),'tier' => 'free'(or'pro'), title, summary, formula, guide, and FAQs. - Create
tools/hra-calculator.php: Copytools/_template.php, rename it tohra-calculator.php, and write your HTML inputs + JS calculation inside an IIFE(function(){ ... })();. - Done! Your new tool automatically appears on the homepage, live search, category chips, Free/Pro comparison page,
sitemap.php, and works at bothtool.php?slug=hra-calculatorand/tool/hra-calculator.
// Security header required at top of every tools/{slug}.php file:
<?php
if (!defined('SAARETOOLS_TOOL_CONTEXT')) {
http_response_code(403);
exit('Direct access not permitted.');
}
?>
4. Live Tool Status Tracker
4 Modular (tools/*.php)
38 Fallback (app.js)
Active Modular Tools (Isolated Files in tools/)
Fallback Tools (Running via fixed assets/js/app.js — Ready to migrate anytime)
Loan Amortization Calculator · Compound Interest Calculator · FD / RD Maturity Calculator · GST Calculator · Income Tax Estimator (New Regime) · Paycheck & In-Hand Salary Calculator · Hourly Wage & Overtime Calculator · DA (Dearness Allowance) Calculator · Catering Estimate & Food Quantity Calculator · Party Organiser & Budget Planner · Office Meeting Organiser & Cost Estimator · BMR Calculator · Daily Calorie & TDEE Calculator · Exact Age Calculator · Date Difference & Working Days Calculator · Percentage Calculator · Discount & Sale Price Calculator · Average, Median & Sum Calculator · Fuel Cost & Trip Mileage Calculator · Profit, Loss & Margin Calculator · Monthly Budget Planner · Savings Goal Planner · Debt Repayment Planner · Weekly Study Timetable Planner · Daily Task & Priority Planner · Weekly Fitness & Workout Planner · Length & Distance Converter · Weight & Mass Converter · Temperature Converter · Word & Reading Time Counter · Character & SMS Limit Counter · Text Case Converter · Secure Password Generator · Hours & Minutes Time Calculator · Online Countdown Timer · Client-Side Image Resizer · Client-Side Image Compressor · QR Code Link & Text Generator
5. Troubleshooting Checklist (XAMPP & Hostinger)
- Old JS still loading? Hard-refresh with
Ctrl + F5or bump?v=4to?v=5inincludes/footer.php. - Assets (CSS/JS) 404 on XAMPP? Open
includes/config.phpand setdefine('BASE_URL', '');for automatic local detection. - Testing Pro Tools locally: Sign up at signup.php, then run this in phpMyAdmin:
UPDATE users SET plan = 'pro', plan_expires_at = DATE_ADD(NOW(), INTERVAL 1 YEAR) WHERE email = 'your@email.com'; - Debugging any tool: Press
F12→ Console tab to inspect errors immediately.