This repository contains a collection of Firebase functions for the Levante platform. The functions are organized into separate directories: |
| levante-admin | Contains Firebase functions for the hs-levante-admin and hs-levante-admin-dev projects |
| levante-assessment | Contains Firebase functions for hs-levante-assessment and hs-levante-assessment-dev projects. (To be sunset.) |
| local | Contains "local" functions for one off use cases (ex. transfering user data to another account).
To get started with the Levante Firebase Functions, follow these steps:
- Install the necessary dependencies:
npm install- Build the functions (From the root folder):
npm run buildThe project includes comprehensive Firebase emulator support for local development with seed data.
Before running the Firebase emulators, ensure you have the following installed:
- Node.js (version 20 or higher)
- Java (version 21 or higher) - Required for Firebase emulators
- On macOS: Install using Homebrew:
brew install openjdk@21 - On Windows: Download from Oracle JDK or use OpenJDK
- On Linux: Use your package manager (e.g.,
sudo apt install openjdk-21-jdkon Ubuntu)
- On macOS: Install using Homebrew:
Above is the easiest way to install Java. You can also download the binaries directly from the Oracle website .
NOTE: Current version numbers above are LTS versions at the time of writing.
# Start emulators with data persistence
npm run dev
# Fill the emulator environment with seed data
npm run emulator:seedThe emulator includes a comprehensive seeding system that creates test users, groups, and data relationships:
| User Type | Password | Description | |
|---|---|---|---|
| Super Admin | superadmin@levante.test | super123 | Super Admin user |
| Admin | admin@levante.test | admin123 | Admin user |
| Teacher | teacher@levante.test | teach123 | Participant user (teacher) |
| Student | student@levante.test | student123 | Participant user (student) |
| Parent | parent@levante.test | parent123 | Participant user (parent) |
- District: "Test District" (ID: test-district-1)
- School: "Test Elementary School" (ID: test-school-1)
- Class: "3rd Grade - Room 101" (ID: test-class-1)
- Group: "Reading Intervention Cohort" (ID: test-group-1)
# Database Management
npm run emulator:clear # Clear all data from emulator
npm run emulator:seed # Seed database with test data
npm run emulator:reset # Clear + seed (fresh start)
# Utility Commands
npm run emulator:export # Export current emulator data for backup
# Kill emulators (if needed)
pkill -f firebase
# Reset without scripts
rm -rf emulator_data && npm run dev:clean-
Start emulators:
npm run dev
-
Set up test data:
npm run emulator:setup
-
Develop and test your application with the created users
-
Reset data when needed:
npm run emulator:setup # Fresh start
- Super Admin: Has
super_admin: trueand access to all groups - Admin: Has limited group access with admin privileges
- Participants (Teacher/Student/Parent): No admin claims, associated with groups via user document associations
All participant users are automatically linked to the test group (cohort) and groups according to their user type.
Levante functions are deployed automatically when merged to the main branch. If you would like to deploy functions locally, follow these steps:
-
Build the functions as above
-
Navigate to the project that you would like to deploy.
For example, to deploy functions in
levante-admin,cd functions/levante-admin -
Deploy the functions
~To deploy only certain functions, first select either the dev or prod environment. For example, to select the dev environment, use
npx firebase use dev
Then deploy a function by name. For example, to deploy only the
exampleFunctionfunction, usenpx firebase deploy --only functions:dashboard-functions:exampleFunction
Note that you must use the
npx firebasecommand, rather than the defaultfirebasecommand. The latter will fail. Also note that if changes were made to functions located in a separate directory (e.g. functions/common), make sure to runnpm run build:allprior to deployment. This will build and update the changed directory.- Deploy all the functions
To deploy all of the functions, you can use the supplied
npm runscripts:npm run deploy:dev # For deployment to the dev environmentor
npm run deploy:prod # For deployment to the prod environment
This project is a derivative of ROAR's original version, which is licensed under the Stanford Academic Software License for ROAR.