Admin Dashboard
Relevant source files
The following files were used as context for generating this wiki page:The Admin Dashboard is a protected section of the GUC Resume Enhancer application designed for administrative users. Its primary purpose is to provide a centralized interface for resume management and enhancement, mirroring the functionality available to standard users but within an access-controlled environment. This module is intended to be integrated into a larger, existing dashboard application.
The page is located at the /admin/resumes route and is composed of reusable components for uploading and viewing resumes. Access is strictly limited to users authenticated with an "admin" role.
Sources: admin/resumes/page.tsx, INTEGRATION_GUIDE.md:38-44
Access Control
Access to the Admin Dashboard is restricted based on user authentication and role. The system first checks if a user session exists. If not, the user is redirected to the sign-in page. If a session exists, it then verifies that the user object contains a role property with the value "admin". Users without this specific role are redirected to the standard user dashboard.
Sources: admin/resumes/page.tsx:8-17
Authentication and Authorization Flow
The following diagram illustrates the server-side logic for granting or denying access to the admin page.
Sources: admin/resumes/page.tsx:8-17
Role Check Implementation
The role check is performed by casting the session user to an object that includes an optional role string and comparing it to "admin".
// admin/resumes/page.tsx:13-16
// Check if user has admin role
const userRole = (session.user as { role?: string }).role;
if (userRole !== "admin") {
redirect("/dashboard");
}
Sources: admin/resumes/page.tsx:14-17
Page Structure and Components
The AdminResumesPage is structured as a two-column grid on larger screens. It reuses the same core components found on the standard user dashboard for a consistent user experience.
- Left Column: Contains the
UploadSectioncomponent, which handles file uploads. - Right Column: Contains the
RecentResumescomponent, which displays a list of recently uploaded resumes.
Sources: admin/resumes/page.tsx:21-29
Component Layout
This diagram shows the component hierarchy of the admin resumes page.
Sources: admin/resumes/page.tsx:19-31
Core Components
The admin page leverages components from the main user dashboard.
| Component | File Path | Description |
|---|---|---|
UploadSection | dashboard/_components/upload-section.tsx | Provides a drag-and-drop interface and file browser for uploading PDF and DOCX resumes. It includes validation for file type and size (max 10MB). |
RecentResumes | dashboard/_components/recent-resumes.tsx | Fetches and displays a list of the most recent resumes from the /api/resumes endpoint. Each item links to the enhancement page (/enhance/[id]). |
AdminLayout | admin/resumes/layout.tsx | A layout file that wraps the admin page content. In the provided source, it is a pass-through component, but the integration guide suggests wrapping it in a main admin layout. |
Sources: admin/resumes/page.tsx:5-6, dashboard/_components/upload-section.tsx, dashboard/_components/recent-resumes.tsx, INTEGRATION_GUIDE.md:79-87
Integration
The Admin Dashboard is designed as a module to be integrated into an existing Next.js dashboard application. The INTEGRATION_GUIDE.md provides detailed steps for this process.
Integration Steps
- Install Dependencies: Add required packages like
@supabase/supabase-js,@prisma/client,pdf-parse, andmammothtopackage.json. - Copy Files: Copy the admin pages, related components, and API routes into the target project's file structure.
- Configure Environment: Set up
.envvariables for Supabase, database connection, and encryption keys. - Set Up Database: Run Prisma migrations to update the database schema.
- Add Navigation: Add a link to
/admin/resumesin the existing admin navigation sidebar or header.
Sources: INTEGRATION_GUIDE.md:14-87
Required Files for Admin Integration
The following table lists the core files that must be copied to integrate the admin resume functionality.
| File Path | Purpose |
|---|---|
admin/resumes/page.tsx | The main page component for the route. |
admin/resumes/layout.tsx | The layout for the admin resumes section. |
api/resumes/upload/route.ts | API endpoint for handling resume uploads. |
api/enhance-resume/[id]/route.ts | API endpoint for AI enhancement. |
dashboard/_components/upload-section.tsx | Reusable upload component. |
dashboard/_components/recent-resumes.tsx | Reusable component to list resumes. |
Sources: INTEGRATION_GUIDE.md:38-60
Summary
The Admin Dashboard for the GUC Resume Enhancer is a role-protected module that provides administrative access to the core resume upload and enhancement features. It reuses key components from the main application for consistency and is designed to be easily integrated into a larger admin system. Its functionality is controlled by a server-side check that ensures only users with the "admin" role can access the /admin/resumes route.