Skip to content

Instantly share code, notes, and snippets.

@ViniciusGibran
Last active March 12, 2026 13:48
Show Gist options
  • Select an option

  • Save ViniciusGibran/c603b556b26a81c3236ade5e063f8b4b to your computer and use it in GitHub Desktop.

Select an option

Save ViniciusGibran/c603b556b26a81c3236ade5e063f8b4b to your computer and use it in GitHub Desktop.
Amora Book Keeping - Doc 2

Amora Book Keeping - Script Structure and Conventions

Objective

To organize and maintain a clean, scalable codebase for the Amora Book Keeping MVP app, following well-defined script organization and code conventions.


File Structure Overview

Each sheet, class, and business logic will have its own script file for better organization. Here’s the current structure:

  • GLOBAL.gs – Centralized global constants and references.
  • UTILITIES.gs – Helper methods, reusable utilities.
  • TRIGGERS.gs – Management of time-based triggers and other triggers across sheets.
  • MENU_CLASS.gs – Handles main menu navigation and logic.
  • WIDGETS_CLASS.gs – Miscellaneous functions (weather, exchange rates, time, etc.).
  • DATABASE_SHEET.gs – Acts like a 'MongoDB' for storing JSON-like data for various tables/sheets.
  • EXPENSES_CLASS.gs – Business logic specific to the "Despesas" (Expenses) sheet.
  • EXPENSES_THEME.gs – Manages the layout and theme of the "Despesas" (Expenses) sheet.
  • EXPENSES_LAYOUT.gs – Handles the layout (content position mapping) for the "Despesas" sheet.

Conventions

Code Organization

  • Each sheet will have its own class, containing the business logic and layout.
  • JSON-like storage will be centralized in the DATA_BASE_SHEET, where keys will map data for specific months.
  • Reusable functions will reside in UTILITIES.gs.
  • WIDGETS_CLASS.gs will handle shared "widget-like" functions that can be applied across sheets (e.g., weather, time, currency exchange rates).

DATA_BASE_SHEET.gs Structure

  • First column: Holds the key (e.g., fixed_bills, sales_log).
  • Subsequent columns: Hold the JSON data for each respective month (e.g., Oct-2024, Nov-2024).

Example Layout:

Key Oct-2024 Nov-2024
fixed_bills {"data": "..."} {"data": "..."}
sales_log {"data": "..."} {"data": "..."}

Code Conventions

1. Classes and Methods

  • Each sheet will have its own class.
  • Global Methods: Defined at the sheet level within the file.
  • Private Methods: Methods that should only be called internally will use camelCase (e.g., calculateExpenses()).
  • Global Properties and Methods: Use SNAKE_CASE for constants and methods that need to be accessible globally (e.g., UPDATE_EXPENSES).

2. Naming Convention

  • Classes: Use capitalized SNAKE_CASE for class names (e.g., EXPENSES_CLASS).
  • Global Methods and Constants: Also use capitalized SNAKE_CASE (e.g., LOAD_SHEET_REFERENCES).
  • Private Methods: Use camelCase (e.g., updateExpensesData).

3. File Structure

  • GLOBAL.gs: For storing references to sheets and any constants that need to be used across multiple sheets.
  • UTILITIES.gs: Contains utility functions that can be reused in different classes.
  • WIDGETS_CLASS.gs: Handles miscellaneous (widget-style) features like weather, exchange rates, and time.
  • DATA_BASE_SHEET.gs: Acts like a database layer, storing and retrieving JSON-like data in specific rows and columns.
  • TRIGGERS.gs: Handles the creation and deletion of time-based triggers.

Future Considerations

  • Scalability: The MVP may expand into a full-fledged web app, but the focus for now is on maintaining simplicity within Google Sheets.
  • Versioning: As the project grows, we will adopt semantic versioning for features and updates (e.g., v1.0.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment