An open-source collaborative document platform built with Vue.js and Firebase.
- Node.js (version 18 or higher)
- npm or yarn
- A Firebase account
- Firebase CLI (
npm install -g firebase-tools
)
This project uses several Firebase services that need to be configured before running locally:
- Firestore - Document database
- Authentication - User authentication
- Hosting - Web hosting
- Cloud Functions - Server-side functions
- Analytics - Usage analytics
- App Check - Security with reCAPTCHA
- Go to the Firebase Console
- Click "Create a project"
- Enter a project name (e.g., "canonical-local")
- Enable Google Analytics (recommended)
- Complete the project creation
In your Firebase project console:
-
Authentication:
- Go to Authentication > Sign-in method
- Enable "Email/Password" provider
-
Firestore:
- Go to Firestore Database
- Click "Create database"
- Choose "Start in test mode" (you can tighten security later)
- Select a location close to you
-
App Check:
- Go to App Check
- Register your app
- Configure reCAPTCHA v3 provider
- Get your reCAPTCHA site key
- In your Firebase project, go to Project Settings (gear icon)
- Scroll down to "Your apps" and click "Add app"
- Choose the web app icon (
</>
) - Register your app with a nickname
- Copy the Firebase configuration object
Create a .env
file in the project root with the following variables:
# Firebase Configuration
VITE_FIREBASE_API_KEY=your_api_key_here
VITE_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id
# reCAPTCHA (from App Check setup)
VITE_RECAPTCHA_SITE_KEY=your_recaptcha_site_key
# Optional: Set a default project ID for new users
VITE_DEFAULT_PROJECT_ID=your_project_id
Replace all the placeholder values with your actual Firebase configuration values.
-
Install Firebase CLI globally:
npm install -g firebase-tools
-
Login to Firebase:
firebase login
-
Set your project:
firebase use --add
Select your project and give it an alias (e.g., "default")
# Install main project dependencies
npm install
# Install Cloud Functions dependencies
cd functions
npm install
cd ..
# Deploy Firestore security rules
firebase deploy --only firestore:rules
# Deploy Firestore indexes
firebase deploy --only firestore:indexes
If you want to run Cloud Functions locally:
# Deploy functions to your Firebase project
firebase deploy --only functions
# Or run functions locally with emulators
firebase emulators:start --only functions,firestore
npm run dev
The application will be available at http://localhost:5173
For a complete local development experience, use Firebase emulators. This is especially useful for testing invitation flows and user onboarding without affecting production data.
-
Initialize emulators (if not already done):
firebase init emulators
Select Auth, Firestore, and UI when prompted.
-
Configure emulators - your
firebase.json
should include:{ "emulators": { "auth": { "port": 9099 }, "firestore": { "port": 8080 }, "ui": { "enabled": true, "port": 4000 } } }
# Start all emulators
firebase emulators:start
# Start with data import/export (preserves data between restarts)
firebase emulators:start --import=./emulator-data --export-on-exit
# Start fresh (no saved data)
firebase emulators:start --import=./emulator-data
When using emulators:
- Firestore UI:
http://localhost:4000
- View/edit database - Your app:
http://localhost:5173
- Your application - Functions:
http://localhost:5001
- Cloud Functions
After running npm run seed:invitations
, you'll have access to these test accounts:
-
Auto-Accept Invitations Flow
- Email:
newuser@example.com
- Password: Any password
- Behavior: Will automatically accept 2 pending invitations on signup
- Expected Result: "Welcome! You've been automatically added to 2 projects: Test Project Alpha, Test Project Beta"
- Email:
-
Normal New User Flow (No Invitations)
- Email:
noninvited@example.com
- Password: Any password
- Behavior: Standard new user flow with no pending invitations
- Expected Result: Redirected to
/new-user
setup flow
- Email:
-
Invitation URL Flow
- Email:
urluser@example.com
- Password: Any password
- Test URL:
http://localhost:5173/invite/url-invite-token-abc123
- Behavior: Sign up through invitation link, then accept invitation
- Expected Result: User joins Test Project Alpha after signup
- Email:
-
Email:
admin@example.com
- Role: Project admin for both test projects
- Has existing default project
-
Email:
existing@example.com
- Role: Existing user with 1 pending invitation (manual acceptance)
- Will see invitation modal on login
- Test Project Alpha - Admin: existing-user-1
- Test Project Beta - Admin: existing-user-1
{
"scripts": {
"dev": "vite",
"dev:test": "VITE_USE_EMULATOR=true vite",
"emulators": "firebase emulators:start --import=./emulator-data --export-on-exit",
"emulators:fresh": "firebase emulators:start",
"seed:invitations": "node scripts/seed-emulator-data.js",
"seed:clear": "node scripts/seed-emulator-data.js clear"
}
}
This project supports two development modes:
Use this for normal development work with your real Firebase project:
npm run dev
# → Uses production Firebase services
# → App runs at http://localhost:5173
Use this for testing invitation flows and other features without affecting production:
# Terminal 1: Start emulators
npm run emulators:fresh
# Terminal 2: Seed test data (wait ~10 seconds for emulators to start)
npm run seed:invitations
# Terminal 3: Start app in emulator mode
npm run dev:test
# → Uses local emulators
# → App runs at http://localhost:5173
name: admin@example.com password: testPassword123!
-
Start emulator testing environment:
# Terminal 1 npm run emulators:fresh # Terminal 2 (wait for "All emulators ready" message) npm run seed:invitations # Terminal 3 npm run dev:test
-
Test different new user flows:
Auto-Accept Invitations:
- Go to
http://localhost:5173
- Sign up with:
newuser@example.com
- Should see: "Welcome! You've been automatically added to 2 projects" message
Normal New User (No Invitations):
- Sign up with:
noninvited@example.com
- Should be redirected to
/new-user
setup flow
Invitation URL Flow:
- Go to:
http://localhost:5173/invite/url-invite-token-abc123
- Sign up with:
urluser@example.com
- Should auto-accept invitation and join project
- Go to
-
Test existing user flow:
- Sign in with:
admin@example.com
(admin with projects) - Sign in with:
existing@example.com
(pending invitation modal)
- Sign in with:
-
Reset and test again:
# Kill emulators (Ctrl+C in Terminal 1) # Restart with fresh data npm run emulators:fresh npm run seed:invitations
-
Debug with Firestore UI:
- Visit
http://localhost:4000
- View users, invitations, projects collections
- Modify test data in real-time
- Visit
- Single invitation: Remove one invitation from seed script
- No invitations: Comment out invitation creation in seed script
- Expired invitations: Set
expiresAt
to past date - Existing user invitations: Create invitations for
admin@example.com
This setup gives you complete control over testing the invitation flow without affecting production data or requiring new user accounts each time.
npm run build
firebase deploy
firebase deploy --only functions
src/
- Vue.js application source codefunctions/
- Firebase Cloud Functionsfirestore.rules
- Firestore security rulesfirestore.indexes.json
- Firestore database indexesfirebase.json
- Firebase project configuration
-
App Check errors: Make sure you've configured reCAPTCHA v3 and added the site key to your
.env
file -
Permission denied errors: Check that your Firestore rules allow the operations you're trying to perform
-
Functions not working: Ensure you've deployed functions and they're properly configured in your Firebase project
-
Environment variables not loading: Make sure your
.env
file is in the project root and variables start withVITE_
If you encounter issues:
- Check the browser console for detailed error messages
- Review the Firebase console for your project status
- Ensure all required environment variables are set
- Verify that all Firebase services are enabled in your project
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with Firebase emulators
- Submit a pull request
[Add your license information here]