How shorrohs/quiloo works
1. Overall shape: Quiloo is a Node.js application with a thin server-backed architecture: a REST API and admin/business logic in src/server.js, PostgreSQL-backed persistence in src/db.js and db/schema.sql, and a browser UI served from src/public/.
2. Primary runtime boundary: The app splits cleanly into three layers:
- Client: static HTML/CSS/JS in src/public/
- Application server: Express-style backend in src/server.js
- Data/services: PostgreSQL for ledger and config data, plus Supabase Storage for documents and SMTP/Nodemailer for credential reset mail
3. Ledger engine: The financial core lives in src/utils/ledger.js. Its job is to compute chronological daily simple interest, shifting principal/balance over time, and to format amounts using Indian numbering conventions and INR rules. This is the main domain-specific computation boundary in the repo.
4. Persistence model: db/schema.sql is the canonical database definition, described in the README as “self-healing.” That suggests schema setup/repair is part of the repository’s intended operational model, not just app code. The database appears to store agreement parameters, ledger records, and related admin-controlled state.
5. Database access layer: src/db.js is the central server-side persistence adapter. It likely owns the PostgreSQL pool and any CRUD helpers used by the API. This is the point where application code crosses into database I/O, and it is the main coupling point for schema, queries, and transaction-oriented logic.
6. Admin/auth flow: The backend includes a secured admin console with default credentials noted in the README and token verification in the server. The architecture implies a privileged path for editing agreement settings, managing transactions, and controlling document operations, separate from standard read-only user views.
7. Document vault path: Business documents are stored outside the database in Supabase Storage. The server handles upload/search-related API calls, and the browser supports previews and filters. So document handling is a separate storage flow: client upload/view request → server auth/processing → Supabase Storage object persistence → client preview/filtering.
8. Email/reset integration: Nodemailer is an external service integration for credential reset or recovery workflows. This sits alongside the admin auth subsystem and is a distinct outbound dependency from the main ledger/database flow.
9. Frontend responsibilities: src/public/index.html, css/style.css, and js/app.js provide a static single-page style experience with responsive glassmorphic UI, client-side session handling, file reading/base64 preview support, and filter interactions. The frontend is presentation + interaction logic, not a separate application tier.
10. Operational and environment boundaries: .env contains database and SMTP secrets, indicating the app depends on runtime configuration for connectivity and mail delivery. test_db.js suggests a lightweight database connectivity/validation path for local or deployment checks.
11. Documentation as architecture source: docs/architecture.md, docs/implementation_plan.md, and docs/walkthrough.md appear to be the canonical narrative for system design, database layout, and feature sequencing. For diagramming, these docs likely reflect the intended flow more directly than the UI assets.
12. Notable external services: The two services that materially affect the architecture are PostgreSQL/Supabase for structured ledger/config data and Supabase Storage for documents. SMTP is the third external integration, but it is narrower in scope and tied to account recovery rather than the core ledger lifecycle.
Main entry points: server.js Server core · db.js DB adapter · index.html UI shell · architecture.md Architecture
Components 18
Client
Static browser interface and client-side interaction logic
Server
Application server, auth, admin flows, and business logic
- Server core · REST API, admin actions, and request routing
src/server.js - DB adapter · PostgreSQL access and query helpers
src/db.js - Ledger engine · Daily simple-interest and INR formatting logic
src/utils/ledger.js - Admin auth · Token verification and protected admin console path
- Ledger API · Agreement and transaction operations built on the ledger engine
- Document API · Upload and search operations for business documents
- Reset mail · Credential reset and recovery messaging
Data & services
Database, storage, and outbound service dependencies
- Schema · Canonical database definition and repair model
db/schema.sql - PostgreSQL · Structured persistence for agreements, ledger data, and admin state
- Storage · Document vault for uploaded files
- SMTP · Outbound credential reset mail delivery
- Runtime config · Database and SMTP connection settings
.env
Docs
Architecture and implementation documentation
- Architecture · System structure and boundaries
docs/architecture.md - Plan · Feature sequencing and implementation roadmap
docs/implementation_plan.md - Walkthrough · End-to-end feature and operational narrative
docs/walkthrough.md
Connections 19
- UI shell → Styles: loads · The UI shell is styled by the main stylesheet
- UI shell → App logic: bootstraps · The page initializes client-side application behavior
- App logic → Server core: calls · Browser actions invoke the backend API
- Server core → Admin auth: guards · Protected admin paths require token verification
- Server core → Ledger API: routes · Core agreement and transaction requests flow here
- Server core → Document API: routes · Document upload and search requests flow here
- Server core → Reset mail: triggers · Recovery requests send credential reset mail
- Ledger API → Ledger engine: computes · Ledger operations rely on the interest engine
- Ledger API → DB adapter: reads/writes · Business operations persist through the database layer
- Document API → Storage: stores · Uploaded documents are persisted in object storage
- Document API → DB adapter: indexes · Document metadata and lookup state are stored in PostgreSQL
- Reset mail → SMTP: sends · Recovery emails are delivered through SMTP
- DB adapter → PostgreSQL: connects · The adapter manages PostgreSQL access
- Schema → PostgreSQL: defines · The canonical schema governs database structure
- Server core → Schema: syncs · Server-side logic depends on the canonical schema model
- Server core → Runtime config: reads · Runtime configuration supplies secrets and connection settings
- SMTP → Runtime config: configures · Mail delivery depends on environment-provided credentials
- Architecture → Plan: informs · Architecture and implementation plan reinforce each other
- Architecture → Walkthrough: describes · The walkthrough reflects the intended system behavior