Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 1, 2025

  • Refactor admin dashboard to dynamically fetch recent activities via API
  • Create new API route /api/admin/recent-activities to retrieve system events
  • Add state management for recent activities and system health data
  • Implement authorization checks in recent activities API route
  • Fetch activities from multiple sources: user signups, blog posts, events, and hackathons
  • Sort and limit activities to display most recent system events
  • Remove hardcoded activities and replace with dynamic data fetching
  • Improve type safety with explicit type definitions for activities and system health

Summary by CodeRabbit

  • New Features
    • Admin dashboard now displays real-time activity feeds aggregated from across the platform
    • Added system health monitoring with status checks for critical infrastructure services

- Refactor admin dashboard to dynamically fetch recent activities via API
- Create new API route `/api/admin/recent-activities` to retrieve system events
- Add state management for recent activities and system health data
- Implement authorization checks in recent activities API route
- Fetch activities from multiple sources: user signups, blog posts, events, and hackathons
- Sort and limit activities to display most recent system events
- Remove hardcoded activities and replace with dynamic data fetching
- Improve type safety with explicit type definitions for activities and system health
@vercel
Copy link

vercel bot commented Nov 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
codeunia Building Building Preview Comment Nov 1, 2025 10:42am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change introduces a new data layer for the admin dashboard. Two new API endpoints expose admin-authenticated access to recent activities and system health information. The admin page now uses typed state to store this data instead of hardcoded values.

Changes

Cohort / File(s) Change Summary
Admin Dashboard State
app/admin/page.tsx
Added Activity and SystemHealthItem TypeScript types. Introduced recentActivities and systemHealth state variables to store API-fetched data, replacing hardcoded constants.
Recent Activities API
app/api/admin/recent-activities/route.ts
New GET endpoint that aggregates recent activities from multiple sources (user signups, blogs, events, hackathons). Includes admin authentication verification and a helper function to convert timestamps to human-friendly relative strings. Returns top 5 activities sorted by recency.
System Health API
app/api/admin/system-health/route.ts
New GET endpoint that performs health checks on database, API server, storage/CDN, and email service. Each service returns status (healthy/warning/error) and uptime information. Includes admin authentication and defensive error handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AdminPage as Admin Page
    participant RecentAPI as Recent Activities API
    participant SystemAPI as System Health API
    participant Supabase
    participant Services as External Services

    User->>AdminPage: Load dashboard
    
    rect rgb(200, 220, 255)
    Note over AdminPage,RecentAPI: Fetch Recent Activities
    AdminPage->>RecentAPI: GET /api/admin/recent-activities
    RecentAPI->>Supabase: Verify user & admin status
    alt Admin verified
        RecentAPI->>Supabase: Query activities (profiles, blogs, events, hackathons)
        Supabase-->>RecentAPI: Activity data
        RecentAPI-->>AdminPage: { activities: [...] }
        AdminPage->>AdminPage: Update recentActivities state
    else Not authorized
        RecentAPI-->>AdminPage: 401/403 error
    end
    end

    rect rgb(220, 255, 200)
    Note over AdminPage,SystemAPI: Fetch System Health
    AdminPage->>SystemAPI: GET /api/admin/system-health
    SystemAPI->>Supabase: Verify user & admin status
    alt Admin verified
        par Database Check
            SystemAPI->>Supabase: Measure query time
            Supabase-->>SystemAPI: Response time
        and API Check
            SystemAPI->>SystemAPI: Self-time check
        and Storage Check
            SystemAPI->>Services: List objects (blog-images)
            Services-->>SystemAPI: Response time
        and Email Check
            SystemAPI->>SystemAPI: Verify RESEND_API_KEY
        end
        SystemAPI-->>AdminPage: { health: [{service, status, uptime, responseTime}, ...] }
        AdminPage->>AdminPage: Update systemHealth state
    else Not authorized
        SystemAPI-->>AdminPage: 401/403 error
    end
    end
    
    AdminPage->>User: Render dashboard with data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

Areas requiring attention:

  • Admin authentication logic in both API endpoints—verify proper access control and potential security edge cases
  • Data aggregation logic in the recent-activities endpoint—ensure all sources are correctly queried and formatted consistently
  • Health check implementations in the system-health endpoint—validate timing measurements and status determination logic
  • Error handling and null-checking across all new code paths

Poem

Hop, hop! The dashboard now fetches with pride,
Activities and health checks side by side,
API routes guard the admin's view,
With Supabase and checks that ring true! 🐰✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/adminstats

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca107e and 2ccafa0.

📒 Files selected for processing (3)
  • app/admin/page.tsx (3 hunks)
  • app/api/admin/recent-activities/route.ts (1 hunks)
  • app/api/admin/system-health/route.ts (1 hunks)

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 and usage tips.

@codeunia-dev codeunia-dev merged commit 17ddafb into main Nov 1, 2025
2 of 4 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.

3 participants