docs: refine backend conventions and routing
Backend security / security (push) Successful in 8s
Backend verify / verify (push) Successful in 2m12s
Conventional commits / commits (pull_request) Successful in 25s
Backend security / security (pull_request) Successful in 7s
Backend verify / verify (pull_request) Successful in 2m3s
Backend security / security (push) Successful in 8s
Backend verify / verify (push) Successful in 2m12s
Conventional commits / commits (pull_request) Successful in 25s
Backend security / security (pull_request) Successful in 7s
Backend verify / verify (pull_request) Successful in 2m3s
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Backend mental model
|
||||
|
||||
NestJS + TypeScript modular monolith. Composition root `AppModule` подключает
|
||||
бизнес-модули, validated configuration, Prisma и Pino. Общая `configureApp`
|
||||
задаёт `/api/v1`, CORS/cookies, validation, request logging и error filter.
|
||||
Точные versions/scripts — в [package.json](../package.json); source code
|
||||
определяет фактическую реализацию.
|
||||
|
||||
```text
|
||||
HTTP controller → application service/use case → pure domain rules
|
||||
↓
|
||||
repository/data access → Prisma → SQLite
|
||||
↓
|
||||
integration client → T-Bank gRPC / MOEX / NCR HTTP
|
||||
```
|
||||
|
||||
`modules/auth`, `modules/banking/bank-cards` и области `modules/investments`
|
||||
владеют пользовательскими возможностями. Сложные модули разделены на
|
||||
presentation/application/domain/infrastructure; компактные остаются плоскими.
|
||||
`*.module.ts` — Nest DI, `*.api.ts` — используемые cross-module exports.
|
||||
Application использует конкретные providers; обязательных ports на каждый
|
||||
класс нет. [Module convention](conventions/backend-architecture.md).
|
||||
|
||||
Stocks/bonds — slices одного instruments module: catalog владеет identity/cache,
|
||||
market — котировками, income — выплатами/личными позициями. Общая orchestration
|
||||
в `instruments/application` использует DTO/provider records и не становится pure
|
||||
domain из-за extraction в функцию. Boundary mappers преобразуют внешние records;
|
||||
чистые расчёты portfolio/banking остаются у domain owner.
|
||||
|
||||
PrismaService владеет DB lifecycle. Самостоятельные use cases получают данные
|
||||
через concrete repositories; существующие связные CRUD/transaction services
|
||||
сохраняют прямые queries по [data convention](conventions/backend-data.md).
|
||||
Money — currency + decimal string; расчёты используют точные общие helpers.
|
||||
|
||||
Auth управляет identity/session; TbankAccessService проверяет доступ к счёту и
|
||||
connection generation. Integration clients владеют protocol/deadline/retry;
|
||||
provider records преобразуются перед чистыми domain calculations.
|
||||
Пользовательский `tbank-connection` не владеет низкоуровневым gRPC client.
|
||||
|
||||
Runtime OpenAPI из Nest → предоставленный frontend snapshot → generated types.
|
||||
Problem Details фильтруются общей HTTP boundary; StructuredLogger добавляет
|
||||
request context и ограничивает поля событий. Jest unit tests, изолированные
|
||||
SQLite/HTTP suites и OpenAPI parity доказывают разные части поведения.
|
||||
Системные потоки и ADR выбираются через [SOURCES](SOURCES.md).
|
||||
Reference in New Issue
Block a user