Skip to content

Realdhiru/gsbooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

66 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GSBooks

FastAPI Python TailwindCSS Alpine.js SQLite Alembic

GSBooks is a billing and accounting single-page application (SPA). It was built to solve the strict data persistence challenges associated with hosting database-driven Python backend systems on ephemeral cloud infrastructure, while maintaining absolute user data ownership.

Live Environment

Production URL: gsbooks.dhirendraautomation.com

(Note: System access is actively restricted via a strict OAuth email whitelist. Public access is disabled.)


Core Architecture & Systems

1. Ephemeral Storage & Data Persistence Layer

Cloud hosts operating on free tiers utilize ephemeral file systems that permanently delete local data when the server spins down. To solve this without migrating to a paid managed database, this application implements a custom cloud-sync bridge.

  • Initialization: Upon successful Google OAuth login, the backend calls the Google Drive API (drive.file scope) to locate and download the user's specific SQLite .db file into the temporary container.
  • Termination: Upon logout, or via the manual UI trigger, the updated .db binary is streamed back to Google Drive, ensuring total data persistence across server restarts.

2. Security & Access Control

Security is handled via centralized dependency injection at the routing middleware level, protecting against unauthorized API access and file system attacks.

  • OAuth 2.0 & Whitelisting: Integrated Google identity services for token-based authentication. The OAuth callback verifies the user's email against a strict .env whitelist. Unauthorized attempts are blocked (403 HTTP) before any session variables or database engines are initialized.
  • Centralized Gatekeeping: All data endpoints require a validated session dependency, eliminating the risk of unauthenticated direct API queries.
  • Path Traversal Protection: File ingestion routes utilize UUID-based deterministic hashing for temporary storage, preventing malicious payload execution during imports.

3. Multi-Tenant Schema Management

The system utilizes a multi-tenant architecture where each user operates on an isolated SQLite database.

  • Alembic Migrations: Schema evolution is managed via Alembic.
  • SQLite Batch Mode: Configured with render_as_batch=True to bypass SQLite's native ALTER TABLE limitations, allowing seamless column additions and removals across all user databases without data loss.

4. Data Processing & Parsing Engine

The application handles bulk financial data through various ingestion methods, relying on the pandas library for normalization.

  • Smart Paste: Parses raw clipboard text (tab-separated values from Excel/Google Sheets) directly into structured JSON payloads for the FastAPI backend.
  • File Uploads: Processes bulk CSV/XLSX imports for both sales and purchases ledgers.
  • Export Generation: Aggregates database records and outputs correctly formatted .xlsx files using openpyxl, categorized specifically for GSTR-1 (Outward Supplies) and ITC (Inward Supplies) filing formats.

5. Frontend Implementation

The user interface avoids heavy JavaScript framework build steps, focusing on lightweight reactivity and modern styling.

  • Styling: Tailwind CSS is used to implement a custom "Liquid Glass" macOS-inspired UI (frosted glassmorphism, deep backgrounds).
  • Reactivity: Alpine.js handles DOM manipulation, modal toggling, tab switching, and sidebar state management directly within the HTML markup.
  • Templating: FastAPI's Jinja2Templates injects backend session data directly into the frontend components before serving.

Technical Stack

  • Backend: Python 3.12+, FastAPI, SQLAlchemy (ORM)
  • Migrations: Alembic
  • Frontend: HTML5, Tailwind CSS, Alpine.js, Jinja2
  • Database: SQLite (Local/Ephemeral), Google Drive API (Persistent Remote)
  • Data Processing: Pandas, OpenPyXL
  • Authentication: Authlib, Starlette Sessions
  • Deployment: Render (with custom domain DNS routing and automatic TLS/SSL)

๐Ÿ”’ Data Privacy & Security By Design

Unlike traditional SaaS applications that hoard financial data on centralized servers, GSBooks is built on a User-Owned Data Architecture inspired by "Local-First" principles.

  • Absolute Data Ownership: Your entire database (.sqlite file) lives exclusively in your own personal or corporate Google Drive. We do not store, hoard, or analyze your financial data on our servers.
  • Zero Vendor Lock-In: Because your data is saved as a standard SQLite database, you are never locked into our ecosystem. You have full agency to download, archive, or query your data using third-party tools.
  • Enterprise-Grade Cloud Security: By leveraging Google Drive for cloud storage, your database inherits Google's security infrastructure (256-bit SSL/TLS encryption in transit and 128-bit AES encryption at rest).
  • Immunity to Centralized Breaches: By decentralizing storage and isolating your data within your own Google account, the centralized "honeypot" is eliminated, drastically reducing vulnerability to massive data breaches.

Application Interface & Screenshots (All data in the screenshots displayed is dummy data generated with the help of AI)

1. Main Dashboard & Analytics

Dashboard Overview The primary control center displaying aggregated Total Sales, Total Purchases, Net Payable GST, and interactive financial charts based on the selected Financial Year.

2. Ledger Views (Purchases & Sales)

Purchases Ledger Structured data tables for tracking inward and outward supplies. Details include invoice numbers, taxable values, and calculated CGST/SGST/IGST, complete with inline edit and delete capabilities.

3. Manual Data Entry

Manual Input Form A clean, intuitive modal form for logging individual sales or purchases. Features dynamic dropdowns and auto-populates party details to ensure data consistency across the database.

4. System Settings & Cloud Sync

Settings & Sync The system control center featuring dynamic user profile rendering via Google OAuth, database reset controls, and the manual trigger for Google Drive cloud synchronization.

About

Built as an open-source alternative to traditional SaaS accounting software. This multi-tenant billing engine is powered by FastAPI and Google Drive to deliver strict privacy and local-first data ownership.

Topics

Resources

Stars

Watchers

Forks

Contributors