Skip to content

Admin Panel

Top G & AI Velocity Feature

Admin panel is available in Top G and AI Velocity tiers only.
See tier comparison

SQLAdmin-powered admin interface for managing users, payments, and viewing analytics.

Quick Access

Bash
1
2
3
4
5
6
7
8
# 1. Create superuser account
task db:user-create -- --email [email protected] --password admin123 --full_name "Admin User"

# 2. Start backend
task run-backend

# 3. Access admin panel
# http://localhost:8020/admin/

Login with your superuser credentials.

Features

User Management

  • View all users
  • Search by email, name, customer ID
  • Filter by account type, verified status
  • View user details (no password visible)
  • Sort by creation date, last login

Purchase Management

  • View all one-time purchases
  • Search by transaction ID, product type
  • Filter by success status, currency
  • Sort by purchase date, amount

Subscription Management

  • View all active subscriptions
  • Search by Stripe subscription ID, plan
  • Filter by plan type, status
  • Sort by start/end dates

Payment Analytics Dashboard

Custom dashboard showing:

  • Total revenue
  • Total transactions
  • Active subscriptions
  • Recent transactions (last 10)

User Insights Dashboard

Custom dashboard showing:

  • Total users
  • Account type distribution
  • Top spending customers
  • Conversion metrics

Creating Superuser

Bash
1
2
3
4
5
6
7
8
# Method 1: Task command
task db:user-create -- \
  --email [email protected] \
  --password securepass123 \
  --full_name "Admin User"

# Method 2: Python script
poetry run python app/commands/create_superuser.py

Security

Authentication

  • Separate from main app authentication
  • Bcrypt password hashing
  • Session-based login
  • Only superusers can access

Permissions

  • Only users with is_superuser=True can login
  • Regular users cannot access admin panel
  • Password hash never displayed in UI

Customization

Adding Model Views

Edit app/admin.py:

Python
from sqladmin import ModelView
from app.models import YourModel

class YourModelAdmin(ModelView, model=YourModel):
    name = "Your Model"
    icon = "fa-solid fa-icon"
    column_list = [YourModel.id, YourModel.name]
    column_searchable_list = ["name"]

# Register in create_admin()
admin.add_view(YourModelAdmin)

Adding Custom Dashboards

Create template in app/templates/:

Python
# app/admin.py
from sqladmin import BaseView, expose

class CustomDashboard(BaseView):
    name = "Dashboard Name"
    icon = "fa-solid fa-chart-line"

    @expose("/custom-dashboard")
    async def dashboard_page(self, request: Request):
        # Query data
        data = await get_dashboard_data()

        return await self.templates.TemplateResponse(
            request,
            "custom_dashboard.html",
            context={"data": data}
        )

admin.add_view(CustomDashboard)

Common Issues

Problem: Can't login to admin panel
Solution: Ensure user has is_superuser=True

Problem: Custom dashboard not showing
Solution: Verify template exists in app/templates/

Problem: Model changes not reflected
Solution: Restart backend server

Files Reference

  • app/admin.py - Admin configuration
  • app/templates/payment_analytics.html - Payment dashboard
  • app/templates/user_insights.html - User insights dashboard
  • app/commands/create_superuser.py - Superuser creation script