How kinzee97/centsible_backend works
Centsible is a REST backend for personal finance: a client registers or logs in, then uses a JWT to manage user-scoped categories and transactions and request monthly summaries. Requests enter the Express router, pass authentication where required, reach controllers for boundary validation, and are handled by services that query PostgreSQL through Prisma. The README documents category breakdowns and cascade deletion; source excerpts show summary calculations and database access, but do not expose every runtime detail. The graph uses documented capabilities where implementation excerpts are unavailable.
Main entry points: router.ts Route dispatch · prisma.ts Prisma client · userService.ts Account service · userController.ts Account endpoints
Components 20
API and middleware
- Route dispatch
src/routes/router.ts - Error responses
src/middleware/errorHandler.ts - Login limiter
src/middleware/limiter.ts
Identity and access
- JWT middleware
src/middleware/authMiddleware.ts - Account endpoints
src/controllers/userController.ts - Account service
src/service/userService.ts - Account validation
src/controllers/schema/user.schema.ts - Password hashing
src/utils/hash.ts - Token signing
src/utils/jsonwebtoken.ts
Finance domain
- Category endpoints
src/controllers/categoryController.ts - Category operations
src/service/categoryService.ts - Category validation
src/controllers/schema/category.schema.ts - Transaction endpoints
src/controllers/transactionController.ts - Transaction and summaries
src/service/transactionService.ts - Transaction validation
src/controllers/schema/transaction.schema.ts - Month range
src/utils/dateRange.ts
Persistence and models
- Prisma client
src/lib/prisma.ts - Data model
prisma/schema.prisma - PostgreSQL
Other components
- API client
Connections 22
- API client → Route dispatch: sends requests
README.md - Route dispatch → Account endpoints: routes account
src/routes/router.ts - Route dispatch → Category endpoints: routes categories
src/routes/router.ts - Route dispatch → Transaction endpoints: routes transactions
src/routes/router.ts - Route dispatch → JWT middleware: guards routes
src/routes/router.ts - Route dispatch → Login limiter: limits login
src/routes/router.ts - Account endpoints → Account validation: validates input
src/controllers/userController.ts - Account endpoints → Account service: calls service
src/controllers/userController.ts - Account service → Password hashing: hashes passwords
src/service/userService.ts - Account service → Token signing: signs tokens
src/service/userService.ts - Account service → Prisma client: queries users
src/service/userService.ts - JWT middleware → Prisma client: checks user
src/middleware/authMiddleware.ts - Category endpoints → Category validation: validates input
src/controllers/categoryController.ts - Category endpoints → Category operations: calls service
src/controllers/categoryController.ts - Category operations → Prisma client: reads and writes
src/service/categoryService.ts - Transaction endpoints → Transaction validation: validates input
src/controllers/transactionController.ts - Transaction endpoints → Transaction and summaries: calls service
src/controllers/transactionController.ts - Transaction and summaries → Month range: gets month range
src/service/transactionService.ts - Transaction and summaries → Prisma client: queries and writes
src/service/transactionService.ts - Prisma client → PostgreSQL: uses adapter
src/lib/prisma.ts - Data model → PostgreSQL: defines persisted data
README.md - Route dispatch → Error responses: forwards failures
src/server.ts