Supabase Edge Functions
Supabase Edge Functions handle the application's background processing tasks, such as parsing PDF documents and sending automated email notifications. These functions are written in TypeScript and run on Deno, ensuring high performance and security without the need for a dedicated backend server.
Overview
The Japanese ATS utilizes two primary edge functions to automate the recruitment workflow:
parse-cv: Automatically extracts text from resumes and calculates a keyword match score.send-status-notification: Sends branded email updates to applicants when their application status changes.
CV Parsing and Analysis (parse-cv)
This function is triggered immediately after an applicant submits their form. It processes the uploaded PDF in the background to provide administrators with instant insights into the candidate's qualifications.
Trigger Mechanism
The function is invoked from the Apply page after a successful file upload to Supabase Storage and a database record creation.
Usage
const { data, error } = await supabase.functions.invoke("parse-cv", {
body: {
applicantId: "uuid-of-applicant",
cvFilePath: "path/to/resume.pdf",
customKeywords: ["N1", "React", "Management"] // Optional
},
});
Request Payload
| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| applicantId | string | Yes | The unique ID of the applicant in the database. |
| cvFilePath | string | Yes | The path to the file in the cvs storage bucket. |
| customKeywords | string[] | No | Additional keywords to search for in the resume. |
Functionality
- Text Extraction: Uses
pdfjs-distto read text content from PDF files. - Keyword Matching: Scans extracted text against a predefined list of technical skills (languages, frameworks, databases) and Japanese language proficiency levels (JLPT N1–N5).
- Scoring: Calculates a
keyword_match_scorebased on the density of relevant keywords. - Database Update: Automatically populates the
cv_extracted_text,matched_keywords, andkeyword_match_scorecolumns in theapplicantstable.
Email Notifications (send-status-notification)
This function integrates with the Resend API to manage communication between the admissions team and the applicants.
Trigger Mechanism
The function is invoked by the Admin Dashboard whenever an administrator updates an applicant's status (e.g., from "Pending" to "Accepted").
Usage
const { data, error } = await supabase.functions.invoke("send-status-notification", {
body: {
applicantName: "John Doe",
applicantEmail: "john@example.com",
newStatus: "accepted",
preferredCourse: "JLPT N2 Preparation"
},
});
Request Payload
| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| applicantName | string | Yes | The full name of the candidate. |
| applicantEmail | string | Yes | The recipient's email address. |
| newStatus | string | Yes | Must be pending, reviewed, accepted, or rejected. |
| preferredCourse | string | Yes | The course the candidate applied for. |
Email Templates
The function automatically selects a relevant HTML template based on the newStatus:
- Reviewed: Notifies the candidate that their application is under active consideration.
- Accepted: Sends a congratulatory message with green-themed branding.
- Rejected: Sends a professional and encouraging rejection notice.
Configuration & Environment Variables
To run these functions, the following Supabase Secrets must be configured:
| Secret Name | Description |
| :--- | :--- |
| SUPABASE_URL | The project URL for storage and database access. |
| SUPABASE_SERVICE_ROLE_KEY | Needed for the parse-cv function to bypass RLS and update applicant records. |
| RESEND_API_KEY | Your API key from Resend for sending emails. |
Local Development
To test functions locally, use the Supabase CLI:
supabase functions serve --no-verify-jwt
Note: The --no-verify-jwt flag is recommended for local development if you are invoking functions directly from the frontend without Auth headers.