A full-stack task management platform with multi-tenant support, built with React, Node.js, and MongoDB.
- Node.js 20.x or later
- MongoDB 6.0 or later
- Docker and Docker Compose
- Git
- Ubuntu 22.04 LTS or later
- Docker Engine 24.x or later
- Docker Compose 2.x or later
- Nginx (for reverse proxy)
- SSL Certificate (for HTTPS)
-
Install Docker Desktop for Windows from Docker Hub
-
Extract the project archive (projectexport*.zip)
-
Open PowerShell and navigate to the project directory
-
Set up the environment:
# Copy environment example file Copy-Item .env.example .env # Edit the environment file with your values notepad .env
-
Import and use the management module:
# Import management module Import-Module .\docker-utils.psm1 # Start all services Start-Services # Check services status Get-ServicesStatus # View service logs Get-ServiceLogs -Service frontend Get-ServiceLogs -Service backend
-
Install Docker and Docker Compose:
# Install Docker curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # Add your user to docker group sudo usermod -aG docker $USER # Log out and log back in for changes to take effect
-
Extract the project archive and set up:
# Extract archive unzip project_export_*.zip -d task-platform cd task-platform # Set up environment cp .env.example .env nano .env
-
Start the services:
# Start application and monitoring docker compose up -d docker compose -f docker-compose.monitoring.yml up -d
After successful setup, access the following URLs:
- Frontend Application: http://localhost
- Backend API: http://localhost:5000
- Grafana Dashboard: http://localhost:3000 (default login: admin/admin)
- Prometheus Metrics: http://localhost:9090
-
If containers fail to start:
# Check container logs Get-ServiceLogs -Service backend Get-ServiceLogs -Service mongodb # Restart services Stop-Services Start-Services
-
If ports are already in use:
- Edit docker-compose.yml to change the port mappings
- Restart the services
-
Common issues:
- Ensure Docker Desktop is running (Windows)
- Check if required ports (80, 5000, 3000, 9090) are available
- Verify environment variables in .env file
- Ensure sufficient disk space for containers and volumes
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install required packages
sudo apt install -y docker.io docker-compose nginx certbot python3-certbot-nginx
# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker
# Add your user to docker group
sudo usermod -aG docker $USER# Clone the repository
git clone <repository-url>
cd multi-tenant-task-platform
# Copy environment files
cp .env.production .env# Install SSL certificate using Let's Encrypt
sudo certbot --nginx -d yourdomain.comCreate /etc/nginx/sites-available/task-platform:
server {
listen 80;
server_name yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# SSL configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# HSTS
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
proxy_pass http://localhost:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}| Variable | Description | Example |
|---|---|---|
| MONGO_URI | MongoDB connection string | mongodb://mongodb:27017/multi_tenant_db |
| JWT_SECRET | Secret key for JWT tokens | your-secret-key |
| EMAIL_USER | Email for sending notifications | app@yourdomain.com |
| EMAIL_PASSWORD | Email app password | your-app-password |
| NODE_ENV | Node environment | production |
| PORT | Server port | 5000 |
| FRONTEND_URL | Frontend application URL | https://yourdomain.com |
| Variable | Description | Example |
|---|---|---|
| VITE_API_URL | Backend API URL | https://yourdomain.com/api |
- Build and start containers:
docker-compose -f docker-compose.yml up -d --build- Monitor logs:
docker-compose logs -f- Scale services (if needed):
docker-compose up -d --scale backend=3- Backend:
cd backend
npm install
npm run build
npm start- Frontend:
cd frontend
npm install
npm run build# Create migration directory
mkdir -p backend/migrations
# Install migration tool
npm install -g migrate-mongo# Generate new migration
migrate-mongo create add-user-roles
# Apply migrations
migrate-mongo up
# Rollback migrations
migrate-mongo downExample migration script (backend/migrations/YYYYMMDDHHMMSS-add-user-roles.js):
module.exports = {
async up(db) {
await db
.collection("users")
.updateMany({ role: { $exists: false } }, { $set: { role: "member" } });
},
async down(db) {
await db
.collection("users")
.updateMany({ role: "member" }, { $unset: { role: "" } });
},
};Create .github/workflows/main.yml:
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "20"
# Backend tests
- name: Backend Tests
run: |
cd backend
npm ci
npm test
# Frontend tests
- name: Frontend Tests
run: |
cd frontend
npm ci
npm test
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /opt/task-platform
git pull
docker-compose -f docker-compose.yml up -d --build- Set up monitoring:
# Install monitoring stack
docker-compose -f docker-compose.monitoring.yml up -d- Regular maintenance:
# Backup database
docker exec mongodb mongodump --out /backup/$(date +%Y%m%d)
# Update containers
docker-compose pull
docker-compose up -d
# Cleanup
docker system prune -af- Keep all packages updated
- Regularly rotate JWT secrets
- Use strong passwords and secure them properly
- Enable rate limiting
- Implement request validation
- Use HTTPS everywhere
- Regular security audits
- Monitor for suspicious activities
- Database backups:
# Automated daily backups
0 0 * * * docker exec mongodb mongodump --out /backup/$(date +%Y%m%d)
# Restore from backup
docker exec mongodb mongorestore --drop /backup/YYYYMMDD- Container data:
# Backup volumes
docker run --rm -v task-platform_mongodb_data:/data -v /backup:/backup alpine tar czf /backup/mongodb-data.tar.gz /dataCommon issues and solutions:
- Container fails to start:
# Check container logs
docker-compose logs [service_name]
# Verify environment variables
docker-compose config- Database connection issues:
# Check MongoDB status
docker exec mongodb mongosh --eval "db.adminCommand('ping')"- Frontend not loading:
# Verify nginx configuration
docker exec frontend nginx -t
# Check nginx logs
docker exec frontend tail -f /var/log/nginx/error.log