HouseLearning Docs

API Reference

Current Firebase HTTP and callable function contracts. HouseLearning does not currently expose the fictional REST routes previously listed here.

Download the OpenAPI 3.1 specification

Transport and authentication

The static website is hosted by GitHub Pages. Firebase provides the backend services; there is no HouseLearning `/api/auth/login`, `/api/users/{id}`, `/api/content/docs`, or `/api/analytics/views` route.

Sign users in with Firebase Authentication. Firestore reads and writes use the Firebase SDK and are governed by the deployed Firestore security rules. Do not put service-account credentials, Gemini keys, webhook tokens, or admin claims in browser code.

Firebase HTTPS function URLs are generated for the configured Firebase project and region. Use the URL printed by `firebase deploy --only functions:`; do not infer a production URL from the GitHub Pages hostname.

SafeAI assistant

HTTP POST `assistant`

Accepts a JSON request with `message` (or `prompt`), optional `subject`, `pageTitle`, `grade`, `language`, `sourceUrls`, `sourceEntries`, and `siteKnowledge`. The endpoint validates HouseLearning source URLs and returns a JSON object containing `text` and `suggestions`.

const response = await fetch('https://us-central1-contract-center-llc-10.cloudfunctions.net/assistant', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    message: 'Explain how fractions are equivalent.',
    subject: 'math',
    grade: 'Grade 5',
    language: 'en',
    tutorMode: true
  })
});
const result = await response.json();

The current endpoint does not require Firebase Authentication. `tutorMode` requests guided hints; it is not an authorization boundary or a substitute for server-side safety controls.

Notifications

HTTP GET `getNotificationImage`

Requires `Authorization: Bearer <Firebase ID token>` and query parameters `notificationId` and `imageIndex`. The function verifies the token and confirms that the notification belongs to that user before returning PNG, JPEG, GIF, or WebP bytes. It returns 401 for missing/invalid authentication, 404 for inaccessible media, and 400 for invalid parameters.

HTTP POST `receivePushNotificationEmail`

A SendGrid Inbound Parse webhook that accepts multipart email data. The query token must match the Firebase secret `PUSH_EMAIL_WEBHOOK_SECRET`; the sender and subject must satisfy the allowlist described in the HouseLearning Home README. Keep the secret in Firebase Secret Manager and SendGrid configuration, never in client code.

Moderation

Public Gists and Forum contributions are written with a pending status and remain hidden until a trusted moderator reviews them. This zero-inference workflow uses Firebase Authentication, Firestore reads/writes, and security rules only; it makes no Gemini calls and requires no new Cloud Functions.

Gists and Forum moderator queues

Recognized administrators review pending items in the Gists or Forum UI. Approval/block writes are direct Firebase SDK updates protected by Firestore rules. Rules require an admin identity, a pending/review state, a valid decision/category, the reviewer UID, and a server timestamp. Client users cannot self-approve or modify review metadata.

Legacy content migration

Use the repository's Admin SDK migration commands once with an authorized service account to queue older public content that has no moderation state. They make bounded Firestore writes and do not invoke an AI model.

Moderation is not automated classification. Ambiguous content requires a person to review it. Deploy only the required Firestore rules and indexes; no moderation function deployment is needed.