How yeyus2025/subscription-management-system works
Project type and purpose
• This is a pure front-end, browser-based subscription management Web application.
• Its goal is to let users add/edit/delete subscriptions, track status (valid, expiring, expired), set intentions (renew/cancel), filter and batch-operate on items, and persist data in localStorage (with a fallback to data.json on first load).
File structure
• index.html: single-page application shell, links Tailwind CSS, script.js, and defines modal and list containers.
• script.js: contains a single SubscriptionManager class that encapsulates all application logic (data loading/saving, event binding, rendering, filtering, validation, UI feedback).
• data.json: default dataset loaded via Fetch API when localStorage is empty.
• No backend or server code—files are served by a static HTTP server (e.g., Python http.server or http-server).
README for additional insights
• Tech stack: HTML5, Tailwind CSS, ES6+ JavaScript, localStorage, Fetch API.
• Application modules and methods are enumerated (init, loadData, saveData, render, form handling, status calculation, batch operations, notifications, etc.).
• Emphasis on responsive UI, modals, dynamic form fields, and keyboard shortcuts.
Main components
a. Browser / User Interface
• index.html (DOM structure)
• Tailwind CSS (UI styling)
• SubscriptionManager (script.js logic)
• UI sub-components:
• Subscription List & Filters
• Modal Form (add/edit)
• Stats Cards & Notifications
• Batch Operation Controls
b. Data Layer
• localStorage (primary persistence)
• data.json (initial fallback data source)
• Fetch API (to load data.json)
c. Server (static file server)
• HTTP server only for delivering index.html, script.js, data.json (no dynamic logic)
d. User (browser events)
• Mouse/keyboard interactions triggering SubscriptionManager methods
Relationships and interactions
• On app startup:
1. SubscriptionManager.init()
2. Attempt loadData() → localStorage read
– If empty/fails, fetch data.json via HTTP server
3. saveData() writes into localStorage
4. render() populates DOM (subscription list, stats)
• User actions (clicks, form submits, keyboard shortcuts):
• bindEvents() routes events to handler methods (add/edit/delete, filter, batch operations)
• Methods update in-memory data model → saveData() → localStorage → render()
• Notifications & loading indicators shown via DOM manipulation
Architectural patterns & design principles
• Single-page application (SPA) without a framework, using a single controller class (SubscriptionManager).
• Separation of concerns:
• Data layer (localStorage, data.json/fetch)
• Application logic (SubscriptionManager methods)
• Presentation layer (DOM updates, Tailwind CSS)
• Declarative UI rendering: renderSubscriptions(), updateStats() re-write DOM based on current model.
• Event-driven design: bindEvents() centralizes event delegation.