Files
backend/.ai/architecture.md
T
ksv741 9810d47e42
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
docs: refine backend conventions and routing
2026-09-15 05:42:16 +03:00

3.1 KiB
Raw Blame History

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; source code определяет фактическую реализацию.

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.

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. 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.