Skip to content

Latest commit

 

History

History
278 lines (204 loc) · 7.34 KB

File metadata and controls

278 lines (204 loc) · 7.34 KB

CourseCompanion

A collaborative platform for students to upload study materials, share resources, and connect with peers for academic support.

License Node React

Table of Contents

Features

  • Upload and organize study materials
  • Real-time collaboration with peers
  • User authentication via Firebase Auth
  • Cloud storage for documents and resources
  • Responsive Material-UI interface
  • Load-balanced backend with Docker Swarm

Architecture

Architecture Diagram

The application uses a microservices architecture with:

  • Frontend: React application served via Nginx (3 replicas)
  • Backend: Node.js/Express API (4 replicas)
  • Load Balancer: Nginx reverse proxy
  • Database: Firebase Realtime Database
  • Storage: Firebase Cloud Storage
  • Authentication: Firebase Authentication

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v14.0.0 or higher)
  • npm (v6.0.0 or higher)
  • Docker (v20.10 or higher) - for Docker deployment
  • Docker Compose (v1.29 or higher) - for Docker deployment
  • Git

Installation

1. Clone the Repository

git clone https://github.com/dheerajram13/CourseCompanion
cd CourseCompanion

2. Firebase Setup

  1. Create a new Firebase project at Firebase Console
  2. Enable the following services:
    • Firebase Authentication (Email/Password and Google providers)
    • Cloud Firestore
    • Realtime Database
    • Cloud Storage
  3. Generate a service account key:
    • Go to Project Settings > Service Accounts
    • Click "Generate New Private Key"
    • Save the JSON file as firebase-config.json in the project root
    • Also save it as firebase-adminsdk.json in the backend/ directory
  4. Get your Realtime Database URL from Firebase Console

Option 1: Run with Docker Swarm (Production)

Install Docker (Ubuntu/Debian)

# Install prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Add Docker repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# Install Docker
sudo apt update
sudo apt install docker-ce -y

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Deploy with Docker Swarm

# Initialize Docker Swarm
sudo docker swarm init

# Build images
sudo docker build -t coursecompanion_frontend:latest ./frontend
sudo docker build -t coursecompanion_backend:latest ./backend

# Deploy the stack
sudo docker stack deploy --compose-file docker-compose.yml coursecompanion

# Check deployment status
sudo docker stack ps coursecompanion

# View service logs
sudo docker service logs coursecompanion_frontend
sudo docker service logs coursecompanion_backend

The application will be accessible at http://localhost

Managing the Docker Stack

# List running services
sudo docker stack services coursecompanion

# Scale a service
sudo docker service scale coursecompanion_backend=6

# Remove the stack
sudo docker stack rm coursecompanion

# Leave swarm mode
sudo docker swarm leave --force

Option 2: Run Locally (Development)

Backend Setup

# Navigate to backend directory
cd backend

# Install dependencies
npm install

# Create .env file
cat > .env << EOF
FIREBASE_DB_URL=your_firebase_database_url_here
PORT=81
EOF

# Start the backend server
npm start

The backend will run on http://localhost:81

Frontend Setup

Open a new terminal:

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Create .env file (optional, for custom API URL)
cat > .env << EOF
REACT_APP_API_BASE_URL=http://localhost:81/api
EOF

# Start the development server
npm start

The frontend will run on http://localhost:3000

Configuration

Environment Variables

Backend (backend/.env)

FIREBASE_DB_URL=https://your-project-id.firebaseio.com/
PORT=81

Frontend (frontend/.env)

REACT_APP_API_BASE_URL=http://localhost:81/api

Firebase Configuration Files

  • firebase-config.json - Root directory (for Docker deployment)
  • firebase-adminsdk.json - Backend directory (for local development)

Important: Never commit these files to version control. They are already in .gitignore.

Usage

  1. Open your browser and navigate to:
    • Local development: http://localhost:3000
    • Docker deployment: http://localhost
  2. Create an account or sign in
  3. Upload study materials
  4. Browse and search for resources
  5. Collaborate with other students

Project Structure

CourseCompanion/
├── backend/                # Node.js/Express backend
│   ├── routes/            # API routes
│   ├── firebaseAdmin.js   # Firebase initialization
│   ├── server.js          # Express server entry point
│   ├── package.json
│   └── dockerfile
├── frontend/              # React frontend
│   ├── public/           # Static files
│   ├── src/              # React components and logic
│   ├── package.json
│   └── dockerfile
├── images/               # Documentation images
├── docker-compose.yml    # Docker Swarm configuration
├── nginx.conf           # Nginx load balancer config
└── Readme.md

Technologies Used

Frontend

  • React 18.3.1 - UI library
  • Material-UI (MUI) 6.1.3 - Component library
  • React Router 6.27.0 - Client-side routing
  • Firebase SDK 10.14.1 - Authentication and storage
  • Emotion - CSS-in-JS styling

Backend

  • Node.js - Runtime environment
  • Express 4.21.0 - Web framework
  • Firebase Admin SDK 12.6.0 - Backend Firebase integration
  • Multer 1.4.5 - File upload handling
  • CORS 2.8.5 - Cross-origin resource sharing

DevOps

  • Docker - Containerization
  • Docker Swarm - Orchestration
  • Nginx - Load balancing and reverse proxy

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the ISC License.


Note: This project is part of an academic initiative to improve student collaboration and resource sharing.