How chintan616/ledgerone works
1. Overall shape
LedgerOne is a three-part system: a React single-page app, a Spring Boot backend monolith, and a separate Python AI service. The backend is the system of record; the frontend is a thin client; the AI service is called only for chat/AI features.
2. Frontend boundary
The frontend/ app uses React 18 + Vite + Tailwind. Its structure is route/page driven: landing, auth, dashboard, invoices, clients, expenses, reports, and profile. API calls are split by domain in src/api/*, and AuthContext handles token storage plus refresh behavior. ProtectedRoute and shared layout components enforce the authenticated app shell.
3. Authentication and identity flow
Auth lives in backend/auth/. It supports email/password registration and login, Google sign-in with server-side token verification, short-lived JWT access tokens, and database-backed refresh tokens. Requests pass through JwtAuthFilter and Spring Security, so every non-auth endpoint is gated by bearer token validation. User-scoped data is keyed by authenticated user email.
4. Invoice and client subsystem
The invoice domain is the largest backend slice: invoices, invoice items, clients, business profiles, PDF generation, and overdue scheduling. Controllers in invoice/controller call services that persist to PostgreSQL through repositories. Invoice lifecycle includes draft/sent/paid/overdue states, PDF export, and client lookup. Business profile data is embedded into generated invoice PDFs.
5. Accounting and reporting subsystem
accounting/ manages expenses and derived financial views. The backend stores expense records and computes financial summary, GST report, and monthly breakdown responses from invoices plus expenses. This is the reporting layer that feeds dashboard charts and reports pages, rather than a separate analytics service.
6. Caching and read optimization
Redis is used as a cache-aside layer for read-heavy endpoints, especially dashboard summary, invoice lists, GST reports, and monthly aggregates. The README indicates short TTLs and explicit eviction on writes, so the architecture intentionally favors fast reads over always recomputing totals from PostgreSQL.
7. Notification and email delivery
notification/ provides email delivery via Spring Mail and Gmail SMTP. In practice, this supports invoice sending and other user-facing notifications. Email is an integration boundary rather than a separate queueing system; there is no evidence of async messaging infrastructure in the repo.
8. Overdue invoice automation
invoice/scheduler/OverdueScheduler is a nightly background job. It scans sent invoices that are past due and marks them overdue automatically. This is a backend-only batch workflow, independent of frontend interaction.
9. AI/chat subsystem
chat/ is a backend entry point for conversational features, but the actual AI logic is isolated in the separate ai-service/ Python project. The backend exposes a chat controller and config that likely proxy requests to that service. The Python service includes main.py, agent.py, and embed.py, suggesting it handles response generation and embeddings outside the main Java application.
10. Persistence model
PostgreSQL is the primary database, and Hibernate manages schema creation/update (ddl-auto: update). The core entities are users, refresh tokens, clients, invoices, invoice items, business profiles, and expenses. Repositories are organized per domain package, which makes the backend a modular monolith rather than microservices.
11. Security and configuration
config/ centralizes application security, JWT filtering, and cache configuration. CORS is environment-driven, which matters because the frontend is deployed separately from the backend. Google OAuth client ID, JWT secret, DB credentials, Redis URL, and mail credentials are all externalized as runtime configuration.
12. Deployment boundary
The repo is container-ready: backend and AI service each have Dockerfiles, the frontend is built for Vercel, and render.yaml targets backend deployment on Render. Operationally, the architecture is split across three runtime environments: browser-hosted SPA, Java backend API, and Python AI service, with PostgreSQL and Redis as shared infrastructure.
Main entry points: invoices.js API Layer · InvoiceService.java Invoice Service · AuthService.java Auth Service · Dashboard.jsx Pages
Components 26
Frontend
React SPA client
- SPA · Browser client shell and routes
frontend/src/App.jsx - Auth State · Stores tokens and refresh state
frontend/src/context/AuthContext.jsx - API Layer · Domain-split HTTP calls
frontend/src/api/invoices.js - App Shell · Protected layout and navigation
frontend/src/components/Layout.jsx - Pages · Landing, auth, dashboard, invoices, clients, expenses, reports, profile
frontend/src/pages/Dashboard.jsx
Auth
Identity and token handling
- Auth API · Register, login, Google sign-in, refresh
backend/src/main/java/com/ledgerone/auth/controller/AuthController.java - Auth Service · Issues JWTs and manages refresh tokens
backend/src/main/java/com/ledgerone/auth/service/AuthService.java - JWT Logic · Signs and validates access tokens
backend/src/main/java/com/ledgerone/auth/service/JwtService.java - User Store · Users and refresh token persistence
backend/src/main/java/com/ledgerone/auth/repository/UserRepository.java
Invoicing
Invoices, clients, profiles, PDFs, overdue jobs
- Invoice API · Invoices, status updates, PDF flows
backend/src/main/java/com/ledgerone/invoice/controller/InvoiceController.java - Clients API · Client CRUD and lookup
backend/src/main/java/com/ledgerone/invoice/controller/ClientController.java - Profile API · Business profile management
backend/src/main/java/com/ledgerone/invoice/controller/BusinessProfileController.java - Invoice Service · Invoice lifecycle and user-scoped persistence
backend/src/main/java/com/ledgerone/invoice/service/InvoiceService.java - PDF Service · Generates invoice PDFs with business profile data
backend/src/main/java/com/ledgerone/invoice/service/PdfService.java - Overdue Job · Marks past-due sent invoices overdue
backend/src/main/java/com/ledgerone/invoice/scheduler/OverdueScheduler.java
Accounting
Expenses and financial reports
- Accounting API · Expenses and derived financial reports
backend/src/main/java/com/ledgerone/accounting/controller/AccountingController.java - Accounting Service · Computes summaries, GST, and monthly breakdowns
backend/src/main/java/com/ledgerone/accounting/service/AccountingService.java
Chat
Backend chat gateway to AI service
Platform
Security, caching, exceptions, app bootstrap
- Email Delivery · Sends invoice and user-facing emails
backend/src/main/java/com/ledgerone/notification/service/NotificationService.java - Security · Spring Security, JWT filter, CORS, cache config
backend/src/main/java/com/ledgerone/config/SecurityConfig.java - JWT Filter · Validates bearer tokens on protected requests
backend/src/main/java/com/ledgerone/config/JwtAuthFilter.java - Backend App · Monolithic API entry point
backend/src/main/java/com/ledgerone/LedgerOneApplication.java
AI Service
Separate Python AI runtime
- AI App · Separate AI runtime for chat features
ai-service/main.py - Agent · Response generation logic
ai-service/agent.py - Embeddings · Embedding pipeline support
ai-service/embed.py
Connections 25
- SPA → Pages: renders · Route-driven screen composition
- SPA → App Shell: uses · Authenticated app shell
- App Shell → Auth State: reads · Session and token state
- Pages → API Layer: calls · Domain API requests
- Pages → Auth State: uses · Login and refresh flow
- API Layer → Auth API: auth calls · Register, login, refresh, Google sign-in
- API Layer → Invoice API: invoice calls · Invoice and client operations
- API Layer → Accounting API: report calls · Dashboard and reporting reads
- API Layer → Chat API: chat calls · Chat widget requests
- Security → JWT Filter: installs · Protects non-auth endpoints
- JWT Filter → Auth Service: validates · Bearer token checks
- Auth API → Auth Service: delegates · Login, registration, refresh, Google auth
- Auth Service → JWT Logic: issues · Creates and verifies JWTs
- Auth Service → User Store: persists · Users and refresh tokens
- Invoice API → Invoice Service: delegates · Invoice lifecycle operations
- Invoice API → Clients API: shares domain · Client lookup and CRUD
- Invoice Service → PDF Service: generates · Invoice PDF export
- Invoice Service → Email Delivery: notifies · Invoice email delivery
- Invoice Service → Overdue Job: updates · Status transitions to overdue
- Accounting API → Accounting Service: delegates · Expense and summary endpoints
- Chat API → AI Bridge: proxies · Connects backend chat to AI service
- AI Bridge → AI App: calls · Remote AI runtime boundary
- AI App → Agent: uses · Conversation logic
- AI App → Embeddings: uses · Embedding support
- Backend App → Security: boots · Loads application security and cache setup