Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion .cursorrules
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# FuzeFront Development Rules

## DNS-Based Architecture & Port Allocation Rules
- **ALWAYS use DNS-based routing through nginx** - Services should be accessed via `fuzefront.dev.local`, not direct ports
- **ALWAYS use port allocator** to prevent conflicts and assign ports systematically
- **NO direct port mappings** in docker-compose.yml - services communicate internally through Docker networks
- **Use FuzeInfra shared nginx** for reverse proxy and load balancing
- Access pattern: `http://fuzefront.dev.local/` (frontend), `http://fuzefront.dev.local/api/` (backend), `http://fuzefront.dev.local/health` (health)

## Port Allocation System
- **Frontend services**: 3000-3999 range (FuzeFront frontend: 3001)
- **Backend APIs**: 5000-5999 range (FuzeFront backend: 3002)
- **Database services**: 6000-6999 range
- **Cache services**: 7000-7999 range
- Use `cd FuzeInfra/tools/port-allocator && python port-allocator.py allocate <project-name> --num-ports <count>` to allocate ports
- Update .env file with allocated ports using `cd envmanager && python env_manager.py add "BACKEND_PORT=<port>"`

## Nginx Configuration
- Main nginx runs on port 80/443 (`fuzeinfra-nginx` container)
- Project configs in `FuzeInfra/infrastructure/shared-nginx/conf.d/`
- Use `docker exec fuzeinfra-nginx nginx -s reload` after config changes
- DNS resolver configured for dynamic upstream resolution
- WebSocket support enabled for development

## Shared Infrastructure Rules
- **NEVER restart, stop, or recreate shared infrastructure containers**
- Shared infra containers include: shared-postgres, shared-mongodb, shared-redis, shared-kafka, shared-rabbitmq, shared-prometheus, shared-grafana, shared-elasticsearch, shared-neo4j
- Shared infra containers include: shared-postgres, shared-mongodb, shared-redis, shared-kafka, shared-rabbitmq, shared-prometheus, shared-grafana, shared-elasticsearch, shared-neo4j, **fuzeinfra-nginx**
- These containers should remain running across all development sessions
- Use existing connections to shared services rather than spinning up new instances
- If shared services are not running, start them with: `cd FuzeInfra && docker-compose -f docker-compose.shared-infra.yml up -d`
Expand All @@ -18,6 +40,14 @@
- Keep shared services running to maintain data persistence
- Use environment manager (envmanager) for configuration management
- Test against shared infrastructure, not isolated containers
- **Access services via DNS**: `http://fuzefront.dev.local` not `http://localhost:3010`

## Docker Compose Rules
- **NO port mappings** for internal services (frontend, backend, task manager)
- Services connect via internal Docker networks (FuzeInfra, fuzefront)
- Only expose ports for services that need external access (authentik, permit-pdp)
- Use environment variables from .env file: `env_file: - .env`
- Override specific variables in environment section: `PORT=${BACKEND_PORT:-3002}`

## Documentation Rules
- **ALWAYS export chat history before every commit**
Expand Down
138 changes: 129 additions & 9 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,129 @@
# Generated by Local Development Orchestrator
BACKEND_PORT=3011
FRONTEND_PORT=3010
DATABASE_PORT=3012
CACHE_PORT=3013
TASKMANAGER_PORT=3014
HOST=0.0.0.0
NODE_ENV=development
API_URL=http://fuzefront.dev.local/api
# FrontFuse Backend Environment Variables
# Copy this file to .env and fill in your actual values

# Server Configuration
NODE_ENV=production
PORT=3002

# JWT Authentication
JWT_SECRET=fuzefront-production-secret-change-this-in-production

# Database Configuration
DB_HOST=postgres
DB_PORT=5432
DB_NAME=fuzefront_platform
DB_USER=postgres
DB_PASSWORD=postgres
USE_POSTGRES=true

# PostgreSQL Configuration (Production)
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

# Frontend Configuration
FRONTEND_URL=http://localhost:5173

# Authentik Configuration - Uses shared FuzeInfra PostgreSQL and Redis
AUTHENTIK_DB_NAME=authentik
AUTHENTIK_SECRET_KEY=generate-random-secret-in-production-please-change-this-to-a-secure-value
AUTHENTIK_COOKIE_DOMAIN=fuzefront.dev.local
AUTHENTIK_PORT=9000
AUTHENTIK_SSL_PORT=9443
AUTHENTIK_CLIENT_ID=
AUTHENTIK_CLIENT_SECRET=
AUTHENTIK_ISSUER_URL=http://fuzefront.dev.local:9000/application/o/fuzefront/
AUTHENTIK_REDIRECT_URI=http://fuzefront.local:8080/auth/callback

# Permit.io Configuration
PERMIT_API_KEY=permit_key_IbtK6N3JdqcJUTj3kS9rDo2uBdQGG9Q6Urk2qdry8uocAEymmGbJ17P6Cq541uqijVQhyU5idlPHQMVzV59qQ1
PERMIT_DEBUG=true
PERMIT_PDP_URL=http://permit-pdp:7000
PERMIT_OFFLINE_MODE=false
PERMIT_SYNC_INTERVAL=10000

# Permit.io PDP Configuration (Container)
PERMIT_PDP_PORT=7766
PERMIT_OPA_PORT=8181

# NOTE: Permit.io PDP bundles OPA+OPAL internally
# No separate OPAL containers needed

# External Services (Optional)
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK

# Container Registry (for production deployment)
DOCKER_REGISTRY=ghcr.io
DOCKER_USERNAME=your-username
DOCKER_PASSWORD=your-personal-access-token

# NPM Publishing
NPM_TOKEN=npm_your-npm-access-token

# Security Tool API Keys
SNYK_TOKEN=your-snyk-api-token
TRIVY_TOKEN=your-trivy-api-token
TRUFFLEHOG_TOKEN=your-trufflehog-api-token

# Monitoring & Alerting
SECURITY_WEBHOOK_URL=https://your-security-monitoring-webhook
SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id

# Production Database (when moving away from SQLite)
PROD_DATABASE_URL=postgresql://user:password@host:port/database
REDIS_URL=redis://user:password@host:port

# Stytch Configuration (when ready)
STYTCH_PROJECT_ID=your-stytch-project-id
STYTCH_SECRET=your-stytch-secret

# Legacy Permit.io Configuration
PERMIT_IO_PDP_URL_LEGACY=https://cloudpdp.api.permit.io

# Session Configuration
SESSION_SECRET=your-secure-session-secret-here
SESSION_MAX_AGE=86400

# WebSocket Configuration
WEBSOCKET_CORS_ORIGIN=http://localhost:5173

# Port Configuration
BACKEND_PORT=3002
FRONTEND_PORT=8080

# PostgreSQL (from FuzeInfra)
POSTGRES_DB=fuzefront_platform

# Redis (from FuzeInfra)
# Used by: Authentik, general caching, sessions
# No additional Redis configuration needed

# Frontend Configuration
VITE_API_URL=http://fuzefront.dev.local
VITE_AUTHENTIK_URL=http://fuzefront.dev.local:9000
VITE_APP_TITLE=FuzeFront Platform

# ================================
# SECURITY NOTES
# ================================

# PRODUCTION REQUIREMENTS:
# 1. Generate strong random secrets for all *_SECRET_KEY variables
# 2. Use proper database credentials with limited privileges
# 3. Configure proper CORS origins
# 4. Set NODE_ENV=production
# 5. Use HTTPS in production (set AUTHENTIK_SSL_PORT)
# 6. Obtain real Permit.io API key from https://app.permit.io
# 7. Set PERMIT_DEBUG=False in production for performance

# AUTHENTIK SECURITY:
# - AUTHENTIK_SECRET_KEY should be at least 32 characters
# - Change default database credentials in production
# - Configure proper cookie domain for your domain
# - Review Authentik security settings in admin interface

# PERMIT.IO SECURITY:
# - Keep PERMIT_API_KEY secure and rotate regularly
# - Use environment-specific API keys
# - Enable offline mode in production for resilience
# - Monitor PDP performance and scaling needs
50 changes: 50 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"branches": [
"main",
"master",
{
"name": "develop",
"prerelease": "beta"
},
{
"name": "feature/*",
"prerelease": "alpha"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md",
"frontend/package.json",
"backend/package.json",
"shared/package.json",
"sdk/package.json",
"api-client/package.json",
"task-manager-app/package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"successComment": "🎉 This ${issue.pull_request ? 'pull request is included' : 'issue has been resolved'} in version [${nextRelease.version}](${releases.filter(release => !!release.url).pop().url}) 🎉",
"labels": false,
"releasedLabels": false
}
]
]
}
80 changes: 80 additions & 0 deletions DATABASE_CONNECTION_FIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ✅ Database Connection Fix: RESOLVED

## 🚨 Problem
Authentik and Permit-PDP containers were failing with PostgreSQL connection errors:
- **Error**: `PostgreSQL connection failed, retrying... ([Errno -2] Name or service not known)`
- **Root Cause**: FuzeFront containers were trying to connect to `shared-postgres` and `shared-redis` but the actual FuzeInfra container names are `fuzeinfra-postgres` and `fuzeinfra-redis`

## ✅ Solution Applied

### 1. **Fixed Container Names in docker-compose.yml**
```yaml
# BEFORE (incorrect)
AUTHENTIK_REDIS__HOST: shared-redis
AUTHENTIK_POSTGRESQL__HOST: shared-postgres

# AFTER (correct)
AUTHENTIK_REDIS__HOST: fuzeinfra-redis
AUTHENTIK_POSTGRESQL__HOST: fuzeinfra-postgres
```

### 2. **Removed Deprecated external_links**
- Removed `external_links` sections which are deprecated
- Relied on Docker network connectivity through `FuzeInfra` network
- Both containers are on the same network so they can reach each other

### 3. **Created Missing Database**
```bash
docker exec fuzeinfra-postgres psql -U postgres -c "CREATE DATABASE authentik;"
```

## 🎯 Result: SUCCESS

### ✅ **Authentik Container**
- **PostgreSQL connection successful** ✅
- **Redis Connection successful** ✅
- **Django migrations applying** ✅
- **Status**: Healthy and operational

### ✅ **Backend Container**
- **Status**: Healthy and running
- **Database**: Connected to shared PostgreSQL

### ✅ **Frontend & Task Manager**
- **Status**: Healthy and running
- **Serving**: Applications properly

### ⚠️ **Permit-PDP Container**
- **Status**: Unhealthy (expected)
- **Issue**: Trying to connect to external Permit.io cloud service
- **Solution**: Configure `PERMIT_API_KEY` environment variable for full functionality

## 🛡️ Critical Rule Established

**NEVER restart, stop, or recreate FuzeInfra shared containers**
- These are shared across multiple projects
- Stopping them is like shutting down AWS datacenter
- Always fix application configuration, not infrastructure

## 📋 Container Status Summary

| Container | Status | Database Connection |
|-----------|--------|-------------------|
| **fuzefront-backend** | ✅ Healthy | ✅ Connected |
| **fuzefront-frontend** | ✅ Healthy | N/A |
| **fuzefront-taskmanager** | ✅ Healthy | N/A |
| **authentik-server** | ✅ Healthy | ✅ Connected |
| **authentik-worker** | ✅ Healthy | ✅ Connected |
| **permit-pdp** | ⚠️ Unhealthy* | N/A |

*Permit-PDP requires external API key configuration

## 🚀 Development Ready

The FuzeFront platform is now fully operational with:
- ✅ Working database connections
- ✅ Healthy container status
- ✅ Network connectivity resolved
- ✅ Authentication system operational

**Ready for feature development!** 🎉
Loading
Loading