How jawadur13/branchsync works
1. Repository shape
- This is a two-tier monorepo: a Spring Boot 3 backend in backend/ and a React 18 + Vite + TypeScript frontend in frontend/.
- The system is centered on an internal bank workflow for inter-branch asset transfers rather than a generic CRUD app.
2. Primary runtime boundary
- The backend exposes all business capabilities through REST controllers under com.jamunabank.branchsync.controller.
- The frontend is a single-page application that consumes those APIs through Axios and routes users through protected pages based on JWT session state.
3. Core business domain
- The main domain object is the TransferRequest, which moves items between branches through a staged approval and fulfillment process.
- The workflow is designed around HQ-controlled routing: requesters initiate a transfer, but the destination branch is assigned later by HQ logistics.
4. Workflow engine
- Transfer lifecycle behavior lives in TransferService and is surfaced via TransferController.
- The flow includes internal approval, HQ verification, destination acceptance, release, pickup, delivery, and closure, with explicit rejection and return-to-HQ paths.
- Status history and printable transfer details are part of the transfer subsystem, not separate services.
5. Specialized inventory engines
- The repository contains two distinct inventory models:
- Cash: BranchCashBalance, CashLedgerEntry, CashManualAdjustment, CashTransferDenomination
- Stock: BranchStockBalance, StockLedgerEntry, StockManualAdjustment, StockItem
- These are behavior-driven by category type, with CASH, STOCK, and DOCUMENT_CASE handled differently in the business layer.
- Cash and stock are not just views; they have ledger-style accounting and manual adjustment approval flows.
6. Service layer boundaries
- The backend is organized into domain services: TransferService, CashService, StockService, ManagementService, and AuditService.
- Implementations live under service/impl, suggesting controllers are thin and business rules are concentrated in service classes.
- ManagementService owns master-data administration such as branches, departments, users, item categories, and stock items.
7. Persistence model
- Data access is via Spring Data JPA repositories in repository/, one repository per aggregate or ledger table.
- The schema is backed by MariaDB/MySQL and bootstrapped from backend/src/main/resources/db/migration/branchsync.sql.
- The model includes support tables for roles, departments, item categories, audit logs, branch balances, ledgers, and transfer state.
8. Security and authentication
- Authentication is JWT-based, with login handled by AuthController and token utilities in security/JwtUtils.
- User lookup integrates with Spring Security through CustomUserDetailsService and JwtAuthenticationFilter.
- The repo also includes a custom SHA-256 password encoder, indicating non-default password handling for the legacy or internal auth model.
9. Operational audit and exception handling
- AuditService and AuditLog provide transactional traceability for transfer actions.
- GlobalExceptionHandler standardizes API error responses using ErrorResponse, with domain-specific exceptions for business rule violations, missing resources, and role authorization failures.
- This makes the API behavior explicit and suitable for regulated operational workflows.
10. Frontend architecture
- The frontend is divided into reusable layout components, route guards, context-based auth state, and feature pages.
- Main user areas include dashboard, transfer creation/history/details, cash and stock ledgers and adjustments, branch directory, profile, and admin screens.
- ProtectedRoute and AuthContext are the main frontend boundaries enforcing authenticated access.
11. Admin and master-data management
- Dedicated controllers and pages manage the bank’s structural data: users, branches, departments, item categories, and stock items.
- The system separates operational users from system administrators, and many workflows depend on branch/department/role scoping.
- Lookup endpoints exist to populate dropdowns and contextual choices, such as available branches, departments per branch, and delivery personnel.
12. Tests, scripts, and delivery
- Backend tests focus on repository and service behavior, especially the transfer workflow.
- docker-compose.yml supports local orchestration, and the repo includes seed/test SQL scripts under backend/src/main/resources/db/test data.
- The architecture is therefore designed for local monorepo development with a database-backed API and a browser-based client, not for distributed microservices.
Main entry points: axiosConfig.ts Axios Client · TransferRequestRepository.java Repositories · main.tsx React SPA · TransferRequest.java Domain Model
Components 24
Backend
Spring Boot API, domain services, persistence, and security
- Spring Boot · Backend application entry point
backend/src/main/java/com/jamunabank/branchsync/BranchSyncApplication.java - Auth API · Login and session token issuance
backend/src/main/java/com/jamunabank/branchsync/controller/AuthController.java - Transfer API · Transfer lifecycle endpoints
backend/src/main/java/com/jamunabank/branchsync/controller/TransferController.java - Cash API · Cash ledger and adjustment endpoints
backend/src/main/java/com/jamunabank/branchsync/controller/CashController.java - Stock API · Stock ledger and adjustment endpoints
backend/src/main/java/com/jamunabank/branchsync/controller/StockController.java - Admin API · Branch, user, department, and item administration
backend/src/main/java/com/jamunabank/branchsync/controller/OrgManagementController.java - Lookup API · Reference-data and selection endpoints
backend/src/main/java/com/jamunabank/branchsync/controller/LookupController.java - Transfer Service · Approval, routing, fulfillment, and closure logic
backend/src/main/java/com/jamunabank/branchsync/service/TransferService.java - Cash Service · Cash balances, ledgers, and manual adjustments
backend/src/main/java/com/jamunabank/branchsync/service/CashService.java - Stock Service · Stock balances, ledgers, and manual adjustments
backend/src/main/java/com/jamunabank/branchsync/service/StockService.java - Management Service · Master data and structural administration
backend/src/main/java/com/jamunabank/branchsync/service/ManagementService.java - Audit Service · Operational audit trail recording
backend/src/main/java/com/jamunabank/branchsync/service/AuditService.java - Security Stack · JWT filter, user details, password encoding, and security config
backend/src/main/java/com/jamunabank/branchsync/security/SecurityConfig.java - Domain Model · Transfer, balances, ledgers, users, branches, roles, and categories
backend/src/main/java/com/jamunabank/branchsync/model/entity/TransferRequest.java - Repositories · Spring Data access for aggregates and ledger tables
backend/src/main/java/com/jamunabank/branchsync/repository/TransferRequestRepository.java - MySQL Schema · Schema and seed data for branches, ledgers, users, and transfer state
backend/src/main/resources/db/migration/branchsync.sql
Frontend
React SPA, route protection, and API consumption
- React SPA · Vite-powered single-page client
frontend/src/main.tsx - Auth State · Client session state and JWT awareness
frontend/src/context/AuthContext.tsx - Protected Route · Authenticated page access control
frontend/src/components/ProtectedRoute.tsx - Layout Shell · Shared navigation chrome and page framing
frontend/src/components/Layout/Layout.tsx - Axios Client · API integration and token-aware requests
frontend/src/api/axiosConfig.ts - User Pages · Dashboard, transfers, ledgers, profile, and branch directory
frontend/src/pages/Dashboard.tsx - Admin Pages · Branch, department, user, and item management screens
frontend/src/pages/admin/UserManagement.tsx
Other components
- BranchSync · Two-tier bank workflow system
Connections 35
- BranchSync → Spring Boot: hosts · Backend runtime for business capabilities
- BranchSync → React SPA: includes · Browser client for operators and admins
- Spring Boot → Security Stack: secured by · JWT authentication and request filtering
- Auth API → Security Stack: issues tokens · Login flow relies on JWT utilities and user lookup
- Auth API → Repositories: auth lookup · Validates credentials against persisted users
- Transfer API → Transfer Service: delegates · Transfer lifecycle orchestration
- Cash API → Cash Service: delegates · Cash accounting operations
- Stock API → Stock Service: delegates · Stock accounting operations
- Admin API → Management Service: delegates · Master-data administration
- Lookup API → Management Service: reads refs · Populates branch, department, and other lookup data
- Transfer Service → Domain Model: mutates · Transfer requests and transfer state history
- Transfer Service → Repositories: persists · Loads and saves transfer and audit-related data
- Transfer Service → Audit Service: records · Writes workflow trace events
- Cash Service → Domain Model: mutates · Branch cash balances, ledger entries, adjustments
- Cash Service → Repositories: persists · Cash aggregate and ledger storage
- Stock Service → Domain Model: mutates · Branch stock balances, ledger entries, adjustments
- Stock Service → Repositories: persists · Stock aggregate and ledger storage
- Management Service → Domain Model: mutates · Branches, departments, users, roles, and item categories
- Management Service → Repositories: persists · Admin master-data persistence
- Audit Service → Domain Model: logs · AuditLog records
- Audit Service → Repositories: persists · Audit trail storage
- Repositories → MySQL Schema: maps to · JPA repositories backed by schema tables
- React SPA → Auth State: uses · Maintains session and login state
- React SPA → Protected Route: protects with · Blocks unauthenticated navigation
- React SPA → Layout Shell: renders through · Shared application shell
- React SPA → Axios Client: calls API via · Axios-based REST integration
- Auth State → Axios Client: configures · Provides JWT-aware request headers
- Axios Client → Auth API: authenticates against · Login and session token exchange
- Axios Client → Transfer API: consumes · Transfer workflow endpoints
- Axios Client → Cash API: consumes · Cash ledger endpoints
- Axios Client → Stock API: consumes · Stock ledger endpoints
- Axios Client → Admin API: consumes · Admin and master-data endpoints
- Axios Client → Lookup API: consumes · Reference-data endpoints
- Protected Route → User Pages: allows · Authenticated business views
- Protected Route → Admin Pages: allows · Admin-only views are still protected by session state