DSA Platform Self-Hosting Manual

Table of Contents

  1. Prerequisites
  2. Installation
  3. Firebase Setup
  4. Admin Configuration
  5. Security Rules
  6. Deployment
  7. Maintenance

1. Prerequisites

Before you begin the self-hosting process, ensure you have the following installed:

2. Installation

Follow these steps to set up the development environment:

  1. Clone the repository:
    git clone [your-repository-url]
    cd [repository-name]
  2. Install dependencies:
    npm install
  3. Create a `.env.local` file in the root directory with the following variables:
    NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key
    NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
    NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
    NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
    NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
    NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id

3. Firebase Setup

To set up Firebase for your self-hosted instance:

  1. Go to the Firebase Console (https://console.firebase.google.com)
  2. Create a new project
  3. Enable Authentication:
  4. Set up Firestore Database:
  5. Configure Firebase Security Rules (see Security Rules section)

4. Admin Configuration

The platform uses a role-based access control system. To set up an admin user:

  1. First, create a regular user account through the platform's registration process
  2. Access the Firebase Console
  3. Navigate to Firestore Database
  4. Find the user document in the `users` collection
  5. Update the user's role field to "admin":
    {
      "role": "admin",
      "email": "admin@example.com",
      "displayName": "Admin User",
      "createdAt": "timestamp",
      "joinedAt": "timestamp",
      "settings": {
        "theme": "light",
        "notifications": true
      }
    }
Note: The admin user has full access to:

5. Security Rules

The platform uses Firebase Security Rules to control access to data. The rules are already configured in the `firestore.rules` file, but you should review and customize them based on your needs:

Important: Always test your security rules thoroughly before deploying to production. Use the Firebase Emulator Suite for testing.

6. Deployment

To deploy the platform:

  1. Build the application:
    npm run build
  2. Deploy to your preferred hosting platform (e.g., Vercel, Firebase Hosting):

7. Maintenance

Regular maintenance tasks include:

Best Practices:

Additional Resources