This project uses Appwrite as its backend for authentication, database, functions, and file storage. To run this project locally or deploy it, you'll need to set up your own Appwrite instance.
-
Appwrite Instance: You need a running Appwrite instance. This can be:
- Appwrite Cloud (Easiest)
- Self-Hosted Appwrite (Docker)
-
Appwrite CLI: Install and configure the Appwrite CLI.
npm install -g appwrite-cli appwrite login
We have provided npm scripts to streamline the setup process.
Run the initialization script. This creates a appwrite.json file from our configuration template and links it to your Appwrite project.
npm run appwrite:init- Follow the prompts to either create a new project on your Appwrite instance or link to an existing one.
- This will update the
appwrite.jsonfile with your specificprojectId.
Once initialized, deploy the entire backend structure (databases, collections, functions, buckets, etc.) to your instance.
npm run appwrite:pushThis command will:
- Create the
Sonar DBdatabase. - Create all required collections (
Sessions,Activity Logs, etc.) with the correct schema. - Deploy Cloud Functions (
sonar-auth,sonar-session-sync, etc.).
Your Appwrite configuration is defined in appwrite.config.json. This acts as the source of truth for the backend schema.
appwrite.config.json: The template configuration file committed to the repository.appwrite.json: The active configuration file used by the CLI (generated bynpm run appwrite:init). Do not commit this file if it contains secrets.
- Authentication: Users, Teams/Roles.
- Database:
Sonar DB: Main database.Sessions: Tracks active coding sessions.Activity Logs: Audits user actions.
- Functions:
sonar-auth: Custom authentication logic.sonar-session-sync: Real-time session management.sonar-activity-sync: Syncs activity logs.sonar-settings: Manages global and user settings.sonar-teams: Handles team management and roles.
These environment variables must be added to your Appwrite Project's Global Variables (in the Settings tab of the Appwrite Console) so they are accessible to all functions.
| Variable | Description |
|---|---|
APPWRITE_ENDPOINT |
The API endpoint of your Appwrite instance (e.g., https://cloud.appwrite.io/v1). |
APPWRITE_PROJECT_ID |
Your Appwrite Project ID. |
APPWRITE_API_KEY |
An API Key with users.read, users.write, documents.read, documents.write scopes. |
BUILD_SIGNING_KEY |
A shared secret key used to verify the integrity of requests. It also serves as the Developer Key. Important: Do not include the BUILD_SIGNING_KEY variable in your local development environment. It should only be present in the Appwrite Console and the secure production builder tool (e.g., CI/CD) used to generate official builds. To bypass attestation locally, set VITE_DEV_KEY to this value instead. |
DB_ID |
The ID of the database (e.g., sonar_db). |
COL_HACKATHONS |
The ID of the Hackathons collection/table. |
COL_HACKATHON_PARTICIPANTS |
The ID of the Hackathon Participants collection/table used for fast studentId -> team lookups. |
COL_SESSIONS |
The ID of the Sessions collection. |
COL_ACTIVITY_LOGS |
The ID of the Activity Logs collection. |
COL_SETTINGS |
The ID of the Settings collection. |
LATEST_APP_VERSION |
The version string of the latest release (e.g., 1.0.0). Used for update checks. |