OCUS Job Hunter: Developer Documentation

1. Project Overview

OCUS Job Hunter is a web application with a serverless backend built on Cloudflare. The backend provides APIs for features like feature toggles and Stripe integration.

Current Priority: Resolve a persistent HTTP 500 error in the Admin Dashboard's feature toggles API (/api/admin/dashboard-features).

2. Cloudflare Platform Guide

This project relies heavily on the Cloudflare ecosystem. Here’s a guide to the key services used.

Cloudflare Pages (Hosting & Deployment)

Cloudflare Pages is a platform for deploying and hosting web projects. It integrates directly with GitHub for a seamless CI/CD workflow.

Cloudflare Functions (Serverless Backend)

The backend logic is built using Cloudflare Functions, which are serverless functions that run on Cloudflare's edge network. In this project, they are deployed as part of the Pages application.

Cloudflare D1 (Database)

D1 is Cloudflare's serverless SQL database, built on SQLite. It's used to persist application data.

3. Local Development

The Wrangler CLI allows you to develop and test the entire application locally.

# 1. Clone the repository
git clone https://github.com/Houman6460/OCUS-jub-hunter.git
cd OCUS-jub-hunter

# 2. Install dependencies
npm install

# 3. Run local server with D1 binding
npx wrangler pages dev --d1=DB

This command starts a local server and creates a local SQLite file to simulate the D1 database.

4. Current Debugging Task

5. Useful Links

6. Issue & Resolution: Premium Download Validation

Issue

The premium extension download endpoint (/api/download-premium) did not correctly validate user eligibility due to mismatches with the actual D1 schema and Stripe webhook behavior. Symptoms included rejecting valid premium users and failing to log extension downloads.

Resolution

Verification

Related Files

Appendix: Visual guide with screenshots

These annotated screenshots walk through the Cloudflare UI for deployments and D1. If images do not load, ensure the files exist under public/docs/screenshots/ (served at /docs/screenshots/ in production) with the filenames used below.

A. Cloudflare Pages deployments view

Cloudflare Pages deployments list for ocus-jub-hunter
What to notice:
  • Project: ocus-jub-hunter. Each commit to main triggers a deployment.
  • Commit IDs: Click View details for logs tied to the exact commit.
  • Status icons: Green checks indicate successful build and activation.
  • Visit link: Opens the deployed URL to validate endpoints and UI.
Step-by-step:
  1. Open Cloudflare Dashboard → Workers & Pages.
  2. Select the ocus-jub-hunter project.
  3. On the Deployments tab, find the row for the commit you deployed.
  4. Click View details to inspect build and function logs.
  5. Use the Visit link to open the live site and verify endpoints (e.g., /documentation and /api routes).

B. D1 Database list

D1 Database list showing ocus-tickets and usage
What to notice:
  • Database name: ocus-tickets with UUID cc9216e4-8167-486a-b174-89087493b2ea.
  • Queries & size: Useful to verify activity in production.
  • Open Studio: Click the database to access the Studio for tables and queries.
Step-by-step:
  1. From the Cloudflare Dashboard, go to Workers & Pages → D1.
  2. Locate ocus-tickets and confirm the UUID matches production.
  3. Click the database name to open the detail view and access Studio.

C. D1 Studio: tables and data

D1 Studio with tables list and data grid
What to notice:
  • Tables list: Left sidebar, including dashboard_features.
  • Data grid: Inspect rows, verify columns (e.g., feature_key, is_enabled).
  • Query tab: Run SQL like PRAGMA table_info('dashboard_features'); for schema.
Step-by-step:
  1. Open Studio for ocus-tickets.
  2. Select the dashboard_features table in the sidebar.
  3. Use the Query tab to run schema checks and updates as needed.
  4. Confirm columns include feature_key, is_enabled, and timestamps.