docs: update spec status, tasks, and frontend overview for FSD app+auth migration
Some checks failed
CI / ci (push) Failing after 6m18s

This commit is contained in:
Sergey Krylov 2026-06-20 14:47:54 +03:00
parent 8e9fdbe70a
commit 20f0efa083
3 changed files with 91 additions and 62 deletions

View File

@ -17,19 +17,31 @@ React SPA, собранная с Vite.
```
apps/frontend/src/
├── main.tsx # Точка входа
├── App.tsx # BrowserRouter
├── routes.tsx # Маршруты
├── app/ # FSD app layer
│ ├── App.tsx # BrowserRouter → AppRoutes
│ ├── index.ts # barrel
│ ├── providers/
│ │ ├── AppProviders.tsx # QueryClientProvider + SessionProvider
│ │ ├── SessionProvider.tsx
│ │ └── index.ts
│ ├── routing/
│ │ ├── AppRoutes.tsx # Все маршруты
│ │ ├── ProtectedRoute.tsx
│ │ └── index.ts
│ └── layouts/
│ ├── AppLayout.tsx # Шапка + <Outlet/>
│ └── index.ts
├── api/
│ ├── auth.ts # Auth API helpers
│ ├── auth.ts # re-export shim → entities/session/api
│ ├── client.ts # HTTP-клиент (fetch)
│ ├── portfolio.ts # Portfolio API helpers
│ ├── responses.ts # Типы ответов (ручные)
│ ├── screener.ts # Screener API helpers
│ └── types.ts # Типы из openapi-typescript
├── context/
│ └── AuthContext.tsx
│ └── AuthContext.tsx # re-export shim → app/providers/SessionProvider
├── hooks/
│ ├── useAuth.ts
│ ├── useAuth.ts # re-export shim → entities/session/model
│ ├── usePortfolio.ts
│ ├── usePortfolioAnalytics.ts
│ ├── usePortfolioMutations.ts
@ -43,22 +55,23 @@ apps/frontend/src/
│ ├── useBond.ts
│ └── useBondCandles.ts
├── components/
│ ├── Layout.tsx
│ ├── ProtectedRoute.tsx
│ ├── Layout.tsx # re-export shim → app/layouts
│ ├── ProtectedRoute.tsx # re-export shim → app/routing
│ ├── SearchBar.tsx
│ ├── PriceChart.tsx
│ ├── StockDetails.tsx
│ ├── BondDetails.tsx
│ └── portfolios/
├── entities/
│ ├── broker-account/ # FSD pilot: account slice (api, model, ui)
│ ├── broker-position/ # FSD pilot: position slice (api, model)
│ └── broker-operation/ # FSD pilot: operation slice (api, model)
│ ├── session/ # FSD: auth/session (api, model/context + hook)
│ ├── broker-account/ # FSD: account slice (api, model, ui)
│ ├── broker-position/ # FSD: position slice (api, model)
│ └── broker-operation/ # FSD: operation slice (api, model)
├── widgets/
│ ├── broker-account-card/ # FSD pilot: account card widget
│ ├── broker-accounts-summary/ # FSD pilot: accounts summary widget
│ ├── broker-allocation-chart/ # FSD pilot: allocation chart widget
│ └── broker-operations-table/ # FSD pilot: operations table widget
│ ├── broker-account-card/ # FSD: account card widget
│ ├── broker-accounts-summary/ # FSD: accounts summary widget
│ ├── broker-allocation-chart/ # FSD: allocation chart widget
│ └── broker-operations-table/ # FSD: operations table widget
├── pages/
│ ├── HomePage.tsx
│ ├── StockPage.tsx
@ -68,26 +81,42 @@ apps/frontend/src/
│ ├── ProfilePage.tsx
│ ├── portfolios/
│ ├── screener/
│ ├── broker-accounts/ # FSD pilot: page entrypoint
│ ├── broker-account/ # FSD pilot: page entrypoint
│ ├── broker-positions/ # FSD pilot: page entrypoint
│ └── broker-operations/ # FSD pilot: page entrypoint
│ ├── broker-accounts/ # FSD: page entrypoint
│ ├── broker-account/ # FSD: page entrypoint
│ ├── broker-positions/ # FSD: page entrypoint
│ └── broker-operations/ # FSD: page entrypoint
├── test/
│ ├── handlers.ts # MSW handlers
│ └── test-utils.tsx
└── styles.css
```
## FSD-пилот: broker-домен
## FSD-миграция
Broker-домен переведён в пилотный [Feature-Sliced Design](https://feature-sliced.design/) срез:
### app-слой и session-сущность
- `pages/broker-*` — тонкие route entrypoints без экранной логики
- `widgets/broker-*` — screen-level композиция (карточки, таблицы, графики)
- `entities/broker-*` — доменные срезы: account, position, operation (api, model/hooks, ui)
Создан `app/` слой FSD, в который перенесены инфраструктурные модули:
Остальные домены (`portfolio`, `screener`, `auth`) пока остаются в исторической технической структуре.
- `app/providers/` — композиция провайдеров (SessionProvider, QueryClientProvider)
- `app/routing/` — маршруты и ProtectedRoute
- `app/layouts/` — AppLayout (шапка + Outlet)
- `app/App.tsx` — BrowserRouter → AppRoutes
## Точка входа
Домен auth переведён в `entities/session/`:
`main.tsx` рендерит `App.tsx`, который содержит `BrowserRouter``AppRoutes`.
- `entities/session/api/` — login, register, logout, refresh, getMe, updateProfile
- `entities/session/model/` — SessionContext, useSession
Старые файлы (`api/auth.ts`, `hooks/useAuth.ts`, `context/AuthContext.tsx`, `routes.tsx`, `components/Layout.tsx`, `components/ProtectedRoute.tsx`, `App.tsx`) сохранены как ре-экспорт шмы для обратной совместимости.
### broker-домен (пилот)
Broker-домен переведён в пилотный FSD срез:
- `pages/broker-*` — тонкие route entrypoints
- `widgets/broker-*` — screen-level композиция
- `entities/broker-*` — доменные срезы (api, model, ui)
### Остальные домены
`portfolio`, `screener` пока остаются в исторической технической структуре.

View File

@ -1,7 +1,7 @@
# Frontend FSD App + Auth
Дата: 2026-06-20
Статус: спецификация
Статус: реализовано
## Концепт

View File

@ -2,56 +2,56 @@
## Phase 1: entities/session/
- [ ] 1.1 Создать `entities/session/api/sessionApi.ts` (6 функций из `api/auth.ts`, импорты через `@/shared/`)
- [ ] 1.2 Создать `entities/session/api/sessionApi.test.ts` (из `api/auth.test.ts`, обновить импорты)
- [ ] 1.3 Создать `entities/session/model/sessionContext.ts` (SessionContext + SessionContextValue)
- [ ] 1.4 Создать `entities/session/model/useSession.ts` (useContext с guard)
- [ ] 1.5 Создать `entities/session/model/useSession.test.tsx` (из `hooks/useAuth.test.tsx`, обновить импорты)
- [ ] 1.6 Создать `entities/session/index.ts` (barrel)
- [ ] 1.7 Превратить `api/auth.ts` в shim
- [ ] 1.8 Превратить `hooks/useAuth.ts` в shim
- [ ] 1.9 Проверить: `npm test -w apps/frontend`
- [x] 1.1 Создать `entities/session/api/sessionApi.ts` (6 функций из `api/auth.ts`, импорты через `@/shared/`)
- [x] 1.2 Создать `entities/session/api/sessionApi.test.ts` (из `api/auth.test.ts`, обновить импорты)
- [x] 1.3 Создать `entities/session/model/sessionContext.ts` (SessionContext + SessionContextValue)
- [x] 1.4 Создать `entities/session/model/useSession.ts` (useContext с guard)
- [x] 1.5 Создать `entities/session/model/useSession.test.tsx` (из `hooks/useAuth.test.tsx`, обновить импорты)
- [x] 1.6 Создать `entities/session/index.ts` (barrel)
- [x] 1.7 Превратить `api/auth.ts` в shim
- [x] 1.8 Превратить `hooks/useAuth.ts` в shim
- [x] 1.9 Проверить: `npm test -w apps/frontend`
## Phase 2: app/providers/
- [ ] 2.1 Создать `app/providers/SessionProvider.tsx` (lifecycle из `context/AuthContext.tsx`)
- [ ] 2.2 Создать `app/providers/AppProviders.tsx` (QueryClientProvider + SessionProvider)
- [ ] 2.3 Создать `app/providers/SessionProvider.test.tsx` (из `context/AuthContext.test.tsx`)
- [ ] 2.4 Создать `app/providers/index.ts` (barrel)
- [ ] 2.5 Превратить `context/AuthContext.tsx` в shim
- [ ] 2.6 Проверить: `npm test -w apps/frontend`
- [x] 2.1 Создать `app/providers/SessionProvider.tsx` (lifecycle из `context/AuthContext.tsx`)
- [x] 2.2 Создать `app/providers/AppProviders.tsx` (QueryClientProvider + SessionProvider)
- [x] 2.3 Создать `app/providers/SessionProvider.test.tsx` (из `context/AuthContext.test.tsx`)
- [x] 2.4 Создать `app/providers/index.ts` (barrel)
- [x] 2.5 Превратить `context/AuthContext.tsx` в shim
- [x] 2.6 Проверить: `npm test -w apps/frontend`
## Phase 3: app/routing/
- [ ] 3.1 Создать `app/routing/ProtectedRoute.tsx` (из `components/ProtectedRoute.tsx`, useSession)
- [ ] 3.2 Создать `app/routing/AppRoutes.tsx` (из `routes.tsx`, импорты из app/layouts, app/routing)
- [ ] 3.3 Создать `app/routing/index.ts` (barrel)
- [ ] 3.4 Превратить `routes.tsx` в shim
- [ ] 3.5 Превратить `components/ProtectedRoute.tsx` в shim
- [ ] 3.6 Проверить: `npm test -w apps/frontend`
- [x] 3.1 Создать `app/routing/ProtectedRoute.tsx` (из `components/ProtectedRoute.tsx`, useSession)
- [x] 3.2 Создать `app/routing/AppRoutes.tsx` (из `routes.tsx`, импорты из app/layouts, app/routing)
- [x] 3.3 Создать `app/routing/index.ts` (barrel)
- [x] 3.4 Превратить `routes.tsx` в shim
- [x] 3.5 Превратить `components/ProtectedRoute.tsx` в shim
- [x] 3.6 Проверить: `npm test -w apps/frontend`
## Phase 4: app/layouts/
- [ ] 4.1 Создать `app/layouts/AppLayout.tsx` (из `components/Layout.tsx`, useSession)
- [ ] 4.2 Создать `app/layouts/index.ts` (barrel)
- [ ] 4.3 Превратить `components/Layout.tsx` в shim
- [ ] 4.4 Проверить: `npm test -w apps/frontend`
- [x] 4.1 Создать `app/layouts/AppLayout.tsx` (из `components/Layout.tsx`, useSession)
- [x] 4.2 Создать `app/layouts/index.ts` (barrel)
- [x] 4.3 Превратить `components/Layout.tsx` в shim
- [x] 4.4 Проверить: `npm test -w apps/frontend`
## Phase 5: app/App.tsx
- [ ] 5.1 Создать `app/App.tsx` (BrowserRouter + AppRoutes)
- [ ] 5.2 Создать `app/index.ts` (barrel)
- [ ] 5.3 Превратить `App.tsx` в shim
- [ ] 5.4 Проверить: `npm test -w apps/frontend`
- [x] 5.1 Создать `app/App.tsx` (BrowserRouter + AppRoutes)
- [x] 5.2 Создать `app/index.ts` (barrel)
- [x] 5.3 Превратить `App.tsx` в shim
- [x] 5.4 Проверить: `npm test -w apps/frontend`
## Phase 6: main.tsx
- [ ] 6.1 Обновить `main.tsx` (AppProviders вместо ручной композиции)
- [ ] 6.2 Проверить: `npm test -w apps/frontend`
- [x] 6.1 Обновить `main.tsx` (AppProviders вместо ручной композиции)
- [x] 6.2 Проверить: `npm test -w apps/frontend`
## Phase 7: update pages
- [ ] 7.1 `pages/LoginPage.tsx` — импорт `@/entities/session`
- [ ] 7.2 `pages/RegisterPage.tsx` — импорт `@/entities/session`
- [ ] 7.3 `pages/ProfilePage.tsx` — импорт `@/entities/session`
- [ ] 7.4 Финальная проверка: `npm test -w apps/frontend && npm run lint -w apps/frontend && npm run build -w apps/frontend`
- [x] 7.1 `pages/LoginPage.tsx` — импорт `@/entities/session`
- [x] 7.2 `pages/RegisterPage.tsx` — импорт `@/entities/session`
- [x] 7.3 `pages/ProfilePage.tsx` — импорт `@/entities/session`
- [x] 7.4 Финальная проверка: `npm test -w apps/frontend && npm run lint -w apps/frontend && npm run build -w apps/frontend`