Skip to content

feat: Replace CLI admin panel with web-based one - #594

Merged
Blaumaus merged 2 commits into
mainfrom
feature/web-based-admin-panel
Jul 23, 2026
Merged

feat: Replace CLI admin panel with web-based one#594
Blaumaus merged 2 commits into
mainfrom
feature/web-based-admin-panel

Conversation

@Blaumaus

@Blaumaus Blaumaus commented Jul 23, 2026

Copy link
Copy Markdown
Member

Changes

If applicable, please describe what changes were made in this pull request.

Community Edition support

  • Your feature is implemented for the Swetrix Community Edition
  • This PR only updates the Cloud (Enterprise) Edition code (e.g. Paddle webhooks, blog, payouts, etc.)

Database migrations

  • Clickhouse / MySQL migrations added for this PR
  • No table schemas changed in this PR

Documentation

  • You have updated the documentation according to your PR
  • This PR did not change any publicly documented endpoints

Summary by CodeRabbit

  • New Features
    • Added a secure web-based admin panel for Cloud environments with access controlled via an email allowlist.
    • Introduced an admin dashboard with overview stats, growth/event charts, plan distribution, and attention indicators.
    • Added interactive tabs for users, projects (including top-by-activity), organisations, and database diagnostics (ClickHouse + MySQL).
    • Enabled user plan and add-on/entitlement override editing.
  • Refactor
    • Removed the previous command-line admin application UI and its supporting data/CLI logic.

@Blaumaus Blaumaus self-assigned this Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fba89e82-5887-4bbd-ba59-5a77dcbf24da

📥 Commits

Reviewing files that changed from the base of the PR and between 4ceb270 and e7ee7d8.

📒 Files selected for processing (1)
  • web/app/pages/Admin/UsersTab.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/app/pages/Admin/UsersTab.tsx

📝 Walkthrough

Walkthrough

The PR removes the Ink-based admin CLI and introduces an authenticated Cloud admin panel with NestJS APIs, reporting services, Remix routing, and web tabs for overview, users, projects, organisations, and database diagnostics.

Changes

Admin panel

Layer / File(s) Summary
Backend authentication and module wiring
backend/.env.example, backend/apps/cloud/src/admin/..., backend/apps/cloud/src/app.module.ts
Adds ADMIN_EMAILS allowlisting, admin authentication guards, NestJS module registration, and concealed unauthorized responses.
Admin reporting and data services
backend/apps/cloud/src/admin/admin.service.ts
Adds overview metrics, charts, MRR estimation, user updates, project and organisation reporting, event aggregation, and database diagnostics.
Admin API and route access flow
backend/apps/cloud/src/admin/admin.controller.ts, web/app/routes/admin.tsx
Adds validated admin endpoints and Remix loader/action handlers for tab data and user billing updates.
Frontend contracts and navigation shell
web/app/pages/Admin/types.ts, web/app/pages/Admin/components.tsx, web/app/pages/Admin/index.tsx, web/app/lib/constants/index.ts
Adds admin data contracts, shared UI helpers, URL-driven tab navigation, and unlocalised admin routes.
Admin reporting and management tabs
web/app/pages/Admin/*Tab.tsx
Adds overview charts, user management, project and organisation tables, and database statistics views.
Legacy CLI removal
admin/*
Removes the previous admin CLI package, entrypoint, entities, database helpers, billing logic, commands, and shared Ink components.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin as Admin browser
  participant Route as Remix admin route
  participant API as NestJS AdminController
  participant Service as AdminService
  participant DB as MySQL and ClickHouse
  Admin->>Route: Request selected admin tab
  Route->>API: Fetch authenticated admin data
  API->>Service: Validate and delegate request
  Service->>DB: Query reporting and entity data
  DB-->>Service: Return aggregated results
  Service-->>API: Return admin payload
  API-->>Route: Return response and cookies
  Route-->>Admin: Render admin tab
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template is mostly followed, but the required Changes section is still just placeholder text and lacks an actual summary. Add a brief Changes section describing the web admin panel rewrite, key routes/components, and any notable behavior changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing the CLI admin panel with a web-based one.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/web-based-admin-panel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
backend/apps/cloud/src/admin/admin.service.ts (1)

753-764: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

inactive-* filter may build an unbounded NOT IN list. getProjectsWithRecentEvents(days) returns every project id with recent events across the whole instance, which is then spread into project.id NOT IN (:...activePids). On large deployments this can be tens of thousands of parameters, risking MySQL max_allowed_packet/placeholder limits and slow query planning. Consider inverting the logic (compute the archived-eligible set from the smaller inactive side, or join against a temp table / use a subquery) rather than a large NOT IN.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/apps/cloud/src/admin/admin.service.ts` around lines 753 - 764, Update
the inactive-* branch in the admin service to avoid spreading all IDs returned
by getProjectsWithRecentEvents into a project.id NOT IN parameter list. Express
the exclusion using a database-side subquery or join that identifies projects
with recent events, while preserving the archived=false and inactive semantics
without an unbounded parameter count.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/app/pages/Admin/UsersTab.tsx`:
- Around line 408-413: The user rows rendered in the users map are mouse-only
because the clickable <tr> elements cannot receive focus or keyboard activation.
Update the row around onUserSelect to add an appropriate interactive role,
tabIndex, and onKeyDown handler that triggers onUserSelect for Enter and Space
while preserving the existing click behavior.

---

Nitpick comments:
In `@backend/apps/cloud/src/admin/admin.service.ts`:
- Around line 753-764: Update the inactive-* branch in the admin service to
avoid spreading all IDs returned by getProjectsWithRecentEvents into a
project.id NOT IN parameter list. Express the exclusion using a database-side
subquery or join that identifies projects with recent events, while preserving
the archived=false and inactive semantics without an unbounded parameter count.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4454d42d-27f8-4902-afbf-79f82f778ef5

📥 Commits

Reviewing files that changed from the base of the PR and between 766fb08 and 4ceb270.

⛔ Files ignored due to path filters (1)
  • admin/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (40)
  • admin/README.md
  • admin/package.json
  • admin/src/billing/pricing.ts
  • admin/src/commands/InactiveProjectsCommand.tsx
  • admin/src/commands/LimitsCommand.tsx
  • admin/src/commands/OrgsCommand.tsx
  • admin/src/commands/ProjectsCommand.tsx
  • admin/src/commands/RecentActivityCommand.tsx
  • admin/src/commands/SearchCommand.tsx
  • admin/src/commands/StatsCommand.tsx
  • admin/src/commands/TopProjectsCommand.tsx
  • admin/src/commands/UsersCommand.tsx
  • admin/src/components/App.tsx
  • admin/src/components/Spinner.tsx
  • admin/src/components/Table.tsx
  • admin/src/db/clickhouse.ts
  • admin/src/db/mysql.ts
  • admin/src/entities/organisation-member.entity.ts
  • admin/src/entities/organisation.entity.ts
  • admin/src/entities/project.entity.ts
  • admin/src/entities/user.entity.ts
  • admin/src/index.tsx
  • admin/tsconfig.json
  • backend/.env.example
  • backend/apps/cloud/src/admin/admin.controller.ts
  • backend/apps/cloud/src/admin/admin.module.ts
  • backend/apps/cloud/src/admin/admin.service.ts
  • backend/apps/cloud/src/admin/decorators/admin-auth.decorator.ts
  • backend/apps/cloud/src/admin/guards/admin-access.guard.ts
  • backend/apps/cloud/src/app.module.ts
  • web/app/lib/constants/index.ts
  • web/app/pages/Admin/DatabaseTab.tsx
  • web/app/pages/Admin/OrganisationsTab.tsx
  • web/app/pages/Admin/OverviewTab.tsx
  • web/app/pages/Admin/ProjectsTab.tsx
  • web/app/pages/Admin/UsersTab.tsx
  • web/app/pages/Admin/components.tsx
  • web/app/pages/Admin/index.tsx
  • web/app/pages/Admin/types.ts
  • web/app/routes/admin.tsx
💤 Files with no reviewable changes (23)
  • admin/README.md
  • admin/src/entities/organisation-member.entity.ts
  • admin/src/components/Spinner.tsx
  • admin/tsconfig.json
  • admin/src/commands/InactiveProjectsCommand.tsx
  • admin/src/entities/project.entity.ts
  • admin/package.json
  • admin/src/entities/user.entity.ts
  • admin/src/entities/organisation.entity.ts
  • admin/src/index.tsx
  • admin/src/components/App.tsx
  • admin/src/commands/RecentActivityCommand.tsx
  • admin/src/commands/StatsCommand.tsx
  • admin/src/billing/pricing.ts
  • admin/src/commands/SearchCommand.tsx
  • admin/src/components/Table.tsx
  • admin/src/db/mysql.ts
  • admin/src/commands/LimitsCommand.tsx
  • admin/src/commands/UsersCommand.tsx
  • admin/src/commands/ProjectsCommand.tsx
  • admin/src/commands/OrgsCommand.tsx
  • admin/src/db/clickhouse.ts
  • admin/src/commands/TopProjectsCommand.tsx

Comment thread web/app/pages/Admin/UsersTab.tsx
@Blaumaus
Blaumaus merged commit 53e6e9d into main Jul 23, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant