Skip to content

DosiBridge/dosimeet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Google Meet Clone

A fully functional Google Meet clone with real-time video/audio calling, WebRTC peer-to-peer connections, chat messaging, and screen sharing capabilities.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 β”‚         β”‚                  β”‚         β”‚                 β”‚
β”‚  Next.js        │◄───────►│  Go Backend      │◄───────►│  PostgreSQL     β”‚
β”‚  Frontend       β”‚  HTTP   β”‚  (Fiber + WS)    β”‚  GORM   β”‚  Database       β”‚
β”‚  (TypeScript)   β”‚  WebSocket                 β”‚         β”‚                 β”‚
β”‚                 β”‚         β”‚                  β”‚         β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                            β”‚
        β”‚                            β”‚
        └────────WebRTC P2Pβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             (STUN/TURN)

✨ Features

  • βœ… User Authentication: JWT-based auth with bcrypt password hashing
  • βœ… Meeting Rooms: Create and join persistent meeting rooms with UUID identifiers
  • βœ… Real-time Video/Audio: WebRTC peer-to-peer connections (mesh topology for ≀6 participants)
  • βœ… WebSocket Signaling: Reliable signaling server with rate limiting
  • βœ… Text Chat: Real-time chat with message persistence
  • βœ… Screen Sharing: Browser-native screen sharing via getDisplayMedia
  • βœ… Participant Management: Real-time participant list with join/leave events
  • βœ… Media Controls: Mute/unmute audio, enable/disable video
  • βœ… Health & Metrics: Prometheus-compatible metrics endpoint
  • βœ… Docker Deployment: Full docker-compose setup for local development

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose
  • (Optional) Node.js 20+ and Go 1.21+ for local development

Run with Docker Compose

  1. Clone the repository

    git clone <repository-url>
    cd test-project
  2. Set up environment variables

    cp .env.example .env
    # Edit .env and set JWT_SECRET to a secure random string (min 32 characters)
  3. Start all services

    docker-compose up --build
  4. Access the application

  5. Create demo users (optional)

    cd backend
    make seed
    # Creates user1@example.com and user2@example.com (password: password123)

πŸ“ Project Structure

/
β”œβ”€β”€ backend/                 # Go backend
β”‚   β”œβ”€β”€ cmd/server/         # Main entry point
β”‚   β”œβ”€β”€ internal/
β”‚   β”‚   β”œβ”€β”€ api/            # REST API handlers
β”‚   β”‚   β”œβ”€β”€ auth/           # JWT & password hashing
β”‚   β”‚   β”œβ”€β”€ config/         # Configuration management
β”‚   β”‚   β”œβ”€β”€ db/             # GORM models & database
β”‚   β”‚   β”œβ”€β”€ signal/         # WebSocket signaling
β”‚   β”‚   └── metrics/        # Prometheus metrics
β”‚   β”œβ”€β”€ migrations/         # SQL migrations
β”‚   β”œβ”€β”€ docs/               # OpenAPI specification
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ Makefile
β”‚   └── go.mod
β”œβ”€β”€ frontend/               # Next.js frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/            # Next.js app router pages
β”‚   β”‚   β”œβ”€β”€ components/     # React components
β”‚   β”‚   β”œβ”€β”€ contexts/       # React contexts (Auth)
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom hooks (WebRTC)
β”‚   β”‚   └── lib/            # API client
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml      # Docker Compose configuration
β”œβ”€β”€ .gitlab-ci.yml          # GitLab CI/CD pipeline
└── README.md

πŸ› οΈ Local Development (without Docker)

Backend

cd backend

# Install dependencies
go mod download

# Set environment variables
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/meet?sslmode=disable"
export JWT_SECRET="your-secret-key-min-32-characters"
export PORT=8080

# Run migrations (requires PostgreSQL running)
make migrate

# Start development server
make dev

# Run tests
make test

# Run linter
make lint

Frontend

cd frontend

# Install dependencies
npm install

# Create .env.local file
cat > .env.local << EOF
NEXT_PUBLIC_API_URL=http://localhost:8080
NEXT_PUBLIC_WS_URL=ws://localhost:8080/ws
NEXT_PUBLIC_STUN=stun:stun.l.google.com:19302
EOF

# Start development server
npm run dev

# Run linter
npm run lint

πŸ§ͺ Testing

Backend Tests

cd backend
go test -v -cover ./...

Tests include:

  • JWT token generation and validation
  • Password hashing with bcrypt
  • Rate limiter functionality
  • (More integration tests can be added)

Frontend Tests

cd frontend
# Unit tests (to be implemented)
npm test

# E2E tests with Playwright (to be implemented)
npm run test:e2e

πŸ“– API Documentation

OpenAPI specification is available at /backend/docs/openapi.yaml.

Key Endpoints

Authentication

  • POST /api/v1/auth/register - Register new user
  • POST /api/v1/auth/login - Login and get JWT token
  • GET /api/v1/user/me - Get current user profile (protected)

Rooms

  • POST /api/v1/rooms - Create a new room (protected)
  • GET /api/v1/rooms/:id - Get room metadata
  • GET /api/v1/rooms/:id/participants - List room participants

WebSocket

  • GET /ws?room={roomId}&token={jwt} - WebSocket endpoint for signaling

System

  • GET /healthz - Health check
  • GET /metrics - Prometheus metrics

πŸ”’ Security

Current Implementation

  • βœ… JWT tokens with 15-minute expiration
  • βœ… bcrypt password hashing (cost 12)
  • βœ… CORS configured for frontend origin
  • βœ… Rate limiting on WebSocket messages (50 burst, 10/sec sustained)
  • βœ… HTML sanitization for chat messages (XSS prevention)
  • βœ… SQL injection protection via GORM parameterized queries

Production Recommendations

Warning

Do NOT use in production without these changes:

  1. HTTPS/TLS: Deploy behind a reverse proxy (nginx/Caddy) with TLS certificates
  2. JWT Secret: Use a cryptographically secure random string (min 64 characters)
  3. Secret Management: Store secrets in a secret manager (AWS Secrets Manager, HashiCorp Vault)
  4. TURN Server: Deploy coturn for reliable NAT traversal
  5. Database: Use managed PostgreSQL with backups and replication
  6. Rate Limiting: Add API rate limiting per IP address
  7. HSTS: Enable HTTP Strict Transport Security headers
  8. CSP: Configure Content Security Policy headers
  9. Monitoring: Set up logging aggregation and alerting

🌐 WebRTC & NAT Traversal

STUN Server

By default, uses Google's public STUN server: stun:stun.l.google.com:19302

TURN Server (Optional)

For production deployments behind restrictive NATs/firewalls, deploy a TURN server:

# Using coturn with docker-compose (uncomment in docker-compose.yml)
docker-compose up coturn

# Configure environment variables
TURN_URL=turn:your-turn-server.com:3478
TURN_USER=username
TURN_PASS=password

Scalability Note

Important

Current mesh topology supports ≀6 participants

For larger meetings (>6 participants), use an SFU (Selective Forwarding Unit):

πŸ› Troubleshooting

WebRTC Connection Issues

Problem: Video/audio not connecting between participants

Solutions:

  1. Check browser console for ICE connection errors
  2. Verify STUN server is reachable: stun:stun.l.google.com:19302
  3. If behind corporate firewall, configure TURN server
  4. Ensure WebSocket connection is established (check Network tab)
  5. Grant browser permissions for camera/microphone

Database Connection Errors

Problem: Backend fails to connect to PostgreSQL

Solutions:

  1. Verify PostgreSQL is running: docker-compose ps
  2. Check DATABASE_URL environment variable
  3. Ensure database migrations ran successfully
  4. Check logs: docker-compose logs backend

Port Conflicts

Problem: Port 3000 or 8080 already in use

Solutions:

  1. Stop conflicting services
  2. Modify ports in docker-compose.yml
  3. Update frontend environment variables accordingly

πŸ“Š Monitoring

Prometheus Metrics

Available at http://localhost:8080/metrics:

  • meet_active_rooms - Number of active meeting rooms
  • meet_total_connections - Total WebSocket connections
  • meet_messages_sent_total - Total messages sent

Health Check

curl http://localhost:8080/healthz
# Response: {"status":"ok"}

🀝 Contributing

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

πŸ“ License

This project is for educational purposes.

πŸ™ Acknowledgments

  • Inspired by Google Meet
  • Built with Go Fiber, Next.js, and WebRTC
  • Uses GORM for database operations
  • Gorilla WebSocket for signaling

Made with ❀️ for learning WebRTC and real-time communications

About

using Golang + NextJs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors