The refactor of CMS Nova should support the research goals directly. The repository must evolve from an organically grown product codebase into a research-grade artifact where security boundaries, module ownership, and policy enforcement are explicit.
- organize by domain instead of by technical artifact alone,
- separate server-only policy and secret-handling code from shared code,
- make public versus privileged behavior obvious from folder boundaries,
- reduce ad hoc route logic by moving critical checks into reusable policy modules,
- ensure documentation can point to stable architectural locations.
src/
app/
(public)/
admin/
api/
modules/
auth/
client/
server/
components/
schemas/
types/
users/
client/
server/
components/
schemas/
types/
content-types/
client/
server/
components/
schemas/
types/
content-entries/
client/
server/
components/
schemas/
types/
media/
plugins/
templates/
server/
auth/
db/
security/
policies/
services/
repositories/
logging/
shared/
components/
ui/
config/
hooks/
lib/
types/
Move the following concerns into src/server:
- secret resolution and decryption,
- authorization policy,
- public content visibility policy,
- repository access wrappers,
- structured logging,
- plugin persistence and secure config serialization.
The goal is to make it hard for client code or generic shared utilities to accidentally import privileged logic.
Group features by domain so that route handlers, components, actions, types, and schemas that belong to the same capability live together. This improves traceability and makes it easier to state security rules such as:
- every
content-entries/servermutation must pass through publication policy, - every
plugins/serveroperation must sanitize secrets, - every
users/serverwrite path must enforce role checks.
Keep src/app thin. Routes should compose domain modules and policy wrappers, not implement core business rules directly.
That reduces the chance that future AI-generated route files bypass security assumptions.
This refactor should be mirrored by documentation:
docs/architectureexplains boundaries,docs/securityexplains policy,docs/researchexplains why the change matters,docs/vibe-guardexplains how real-time auditing applies to the new structure.
- freeze the current repository as the baseline artifact,
- document known weaknesses,
- tag structural hotspots and risky routes.
- create server-only policy modules,
- centralize logging,
- centralize secret handling,
- define public content retrieval policy.
- move auth, users, content, media, plugins, and templates into domain modules,
- update imports gradually,
- keep route files as composition layers only.
- map old structure to new structure,
- compare baseline and refactored security posture,
- record which classes of issues Vibe-Guard would have blocked.
The refactor is not just a cleanup effort. It is part of the experiment. It demonstrates how a system built with fast AI assistance can be transformed into one governed by explicit architecture and enforceable policy.