How lkduy2602/svibox works
Project Type & Purpose
• This is a backend-only microservice built on Google Apps Script.
• It exposes POST endpoints (via doPost) to handle authentication, user management, and media metadata operations.
• Data persistence lives in Google Sheets. Error notifications are sent via Gmail.
File Structure (Layered MVC-Style)
• appsscript.json / .clasp.json – project config for Google Apps Script & clasp.
• src/main.js – entrypoint, routes incoming POST requests to controllers.
• src/controller – HTTP handler layer (auth.controller, user.controller, media.controller).
• src/service – business logic (auth.service, user.service, media.service).
• src/repository – data access (factory.repository routes calls to sheet-based repositories).
• src/entity – data models (auth.entity, user.entity, media.entity).
• src/validator – input validation before business logic.
• src/_utils – helpers (auth tokens, email, environment config, response wrappers, validation).
Readme Insights
• Google Sheets as primary datastore.
• Uses clasp for deployment & development.
• Requires POST calls against a deployed Apps Script URL.
• Initial setup: run setUp() in main.gs to provision sheets.
Main Components & Interactions
A. External Clients (e.g. Frontend, Postman, Other Services)
→ send HTTP POST with JSON payload.
B. Google Apps Script Execution Environment
• doPost() in main.js
• Dispatch layer: maps path to appropriate controller.
C. Controller Layer
• Validate input → call service → return response wrapper.
D. Service Layer
• Core business rules (auth, user, media management).
• On errors, call utils/email to send error notifications.
E. Repository Layer
• Uses SpreadsheetApp API to read/write Sheets.
• factory.repository selects the correct sheet (Auth, User, Media).
F. Data Storage
• Google Sheets (three tabs: auth, user, media).
G. External Google Services
• GmailApp (error emails)
• (Optional) DriveApp if storing actual file content—currently metadata only.
Architectural Patterns & Principles
• Layered architecture: Controllers → Services → Repositories → Sheets.
• Single Responsibility per module (validation, helpers, entities).
• Factory pattern for repository instantiation.
• Centralized error handling with email notifications.
• Environment-driven configuration (api keys, sheet IDs in src/_utils/environment.js).
Technologies & Frameworks
• Google Apps Script runtime & built-in services (SpreadsheetApp, GmailApp).
• clasp (local development & deployment tool).
• Vanilla JavaScript modules.