2.3 KiB
2.3 KiB
Frontend Architecture
OpsxSQL frontend uses a light domain-first structure:
pages: route-level composition onlyfeatures: business domains such as datasource, Redis, Mongo, query, ticket, RBAC, governance, systemapi: transport clients grouped by backend domaincomponents: existing shared app componentsshared: new cross-domain primitives
Production guideline:
- Keep page files below about 700 lines.
- Move reusable business UI into
features/<domain>/components. - Move domain state/data orchestration into
features/<domain>/hooks. - Move cross-domain helpers into
shared/lib. - Avoid putting transport logic inside components.
- New API imports should prefer domain paths such as
api/datasource/redisandapi/system/user; top-level API files are compatibility shims. - Database-engine-specific behavior belongs under
features/datasource/engines/<engine>or the engine domain (features/redis,features/mongo) when the surface is large enough.
Domain map:
features/datasource: instance inventory, connection forms, import flows, MySQL/PostgreSQL engine panelsfeatures/redis: Redis key/value browsing, Redis result formatting, Redis command helpersfeatures/mongo: MongoDB collection/document browsing and Mongo shell result renderingfeatures/query: self-service query workspace, templates, query history, result renderingfeatures/ticket: change ticket lifecycle, execution, rollback, approval actionsfeatures/governance: workflows, audit rules, risk policy, execution windows, SLA policyfeatures/rbac: users, roles, permission groups, LDAP syncfeatures/system: settings, notifications, announcements, audit logs, appearance
First migration sample:
- Redis value formatting and command helpers now live in
features/redis. - Redis Hash result display is shared by Redis detail and query workflows.
- Query template/history UI now lives in
features/query.
Current page-size hotspots:
InstancePage.tsx: datasource domainUsersPage.tsx: RBAC domainTicketsPage.tsxandTicketDetailPage.tsx: ticket domainWorkflowPage.tsx: governance domainLdapConfigPage.tsx: RBAC/system boundary; should be folded into RBAC LDAP panels or system integration settings
Use npm run audit:pages in frontend/ to find pages over the 700-line budget.