You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Solid lines = current operating flow. PostgreSQL holds **normalized seed data** (hosts/alerts/vulns/observations) which is loaded into InMemoryRepository at boot for queries. The 6 UI operational stores (triage / incidents / asset owners / vuln actions / asset audit log / user profiles) currently run in-memory; the **dashed line = next milestone (Postgres persistence + activating real-time pollers)**.
120
+
>
121
+
> **API structure (Task J done):**`server.py` is now a **thin orchestrator (888 lines)** that assembles in-memory state and helper closures into a `RouteContext`, then registers 16 domain modules. Each endpoint is owned by `register_<domain>(ctx)` in `routes/<domain>.py`, and the 6 in-memory stores are shared across modules via the `RouteContext`.
118
122
119
123
---
120
124
@@ -272,7 +276,17 @@ Deployment behavior: `docker compose down && docker compose up -d` (GitHub Actio
|**UI operational state — 6 in-memory stores** (reset on restart) |Module-scope dicts in API process. Postgres persistence not yet connected |`api/server.py`|
314
+
|**UI operational state — 6 in-memory stores** (reset on restart) |Created by `server.py`, injected via `RouteContext`, shared/mutated by domain route modules. Postgres persistence not yet connected |`api/server.py` → `api/routes/context.py`|
`server.py` is very large and contains HTML/JS inside Python triple-quoted strings. Always validate after edits:
447
+
Task J split routes into `api/routes/` and HTML/JS renderers into `api/templates.py`. To guarantee a lossless refactor, run the **3-gate check**after changes:
Additionally, a helper script that verifies brace balance in `<script>...</script>` blocks (used during the Audit-Ready work in this README) can catch JS breakage before runtime.
460
+
Each domain's routes are owned by `register_<domain>(ctx)`in `routes/<domain>.py`; shared state/helpers are injected via the `RouteContext`in `routes/context.py`.
440
461
441
462
---
442
463
@@ -581,7 +602,7 @@ MORI SOC combines open-source security tools to provide a single ops screen, wit
581
602
582
603
| ID | Work | Status |
583
604
|---|---|---|
584
-
|**J** (foundation) | Split `server.py`(~9,200 lines) into modules — i18n / templates / auth / routes. A refactor that lowers regression risk for the persistence/poller work that follows |🔲 Next|
605
+
|**J** (foundation) | Split `server.py` into modules — i18n / templates / auth / payloads + a `routes/` package (16 domain modules, `RouteContext`). **2,962→888 lines (-70%)**, lossless-verified (OpenAPI diff · SHA · 115 tests). A refactor that lowers regression risk for the persistence/poller work that follows |✅ Done|
585
606
|**M2-1**| Persist the 6 UI operational state stores (`asset_owners`·`asset_audit_log`·`vuln_actions`·`triage_store`·`incident_store`·`user_profiles`) to PostgreSQL (`repositories/postgres.py` + `schema/002_*.sql`) | 🔲 Top priority |
> 실선은 현재 운영 중인 흐름. PostgreSQL은 **정규화 시드 데이터**(hosts/alerts/vulns/observations)를 보유하며 부팅 시 InMemoryRepository로 로드되어 질의에 사용됩니다. UI 운영 상태(triage / incidents / asset owners / vuln actions / asset audit log / user profiles) 6종은 현재 인메모리에서 동작하며, **점선 = 다음 마일스톤(Postgres 영속화 + 실시간 폴러 활성화)** 입니다.
120
+
>
121
+
> **API 구조(Task J 완료):**`server.py`는 인메모리 상태와 헬퍼 클로저를 `RouteContext`로 조립한 뒤 16개 도메인 모듈을 등록하는 **얇은 오케스트레이터(888줄)** 로 슬림화되었습니다. 각 엔드포인트는 `routes/<domain>.py`의 `register_<domain>(ctx)`가 소유하며, 인메모리 6종 store는 `RouteContext`를 통해 모듈 간 공유됩니다.
118
122
119
123
---
120
124
@@ -270,7 +274,17 @@ flowchart LR
270
274
```text
271
275
src/mori_soc/
272
276
├── api/
273
-
│ ├── server.py ← FastAPI 엔드포인트 + 통합 운영 UI(/ui) HTML/JS
277
+
│ ├── server.py ← 얇은 오케스트레이터(888줄): RouteContext 조립 + 모듈 등록
278
+
│ ├── routes/ ← 16개 도메인 라우트 모듈 (register_<domain>(ctx))
0 commit comments