This backend consists of two microservices:
- Node.js Steganography Service (Port 3001) - Handles image steganography encoding/decoding
- Python Flask API Service (Port 5001) - Handles device registration and verification logic
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ GeoCam App │ │ Python Flask │ │ Node.js Steg │
│ (React Native) │◄──►│ API Service │◄──►│ Service │
└─────────────────┘ │ (Port 5001) │ │ (Port 3001) │
└─────────────────┘ └─────────────────┘
│
┌─────────────────┐
│ PostgreSQL │
│ Database │
└─────────────────┘
- Docker 20.10+
- Docker Compose 2.0+
- Node.js 18+
- Python 3.11+
- PostgreSQL 15+
-
Clone and navigate to backend directory:
cd Web_Backend -
Configure environment (optional):
# Copy example environment file cp .env.example .env # Edit .env file with your preferred settings # For production, change SECRET_KEY and database passwords
-
Start all services:
# Build and start all services in detached mode docker-compose up --build -d # Or start with logs visible docker-compose up --build
-
Check service health:
# Check API service curl http://localhost:5001/api/health # Check steganography service curl http://localhost:3001/health # Check all services status docker-compose ps
-
Stop services:
# Stop all services docker-compose down # Stop and remove volumes (WARNING: This will delete database data) docker-compose down -v
# Install PostgreSQL and create database
createdb geocam_db
createuser geocam --password # Set password as 'geocam'# Install dependencies
npm install
# Start service
npm start
# Or for development:
npm run dev# Install dependencies
pip install -r requirements.txt
# Set environment variables
export DATABASE_URL="postgresql://geocam:geocam@localhost:5432/geocam_db"
export STEGANOGRAPHY_SERVICE_URL="http://localhost:3001"
# Start service
python app.pyid(Primary Key)installation_id(Unique)device_modelos_nameos_versionpublic_key_hashpublic_key_data(JSONB)registration_dategeocam_sequence(GeoCam1, GeoCam2, etc.)last_activityis_active
id(Primary Key)device_id(Foreign Key)verification_timestampimage_hashverification_resultverification_messagesignature_data(JSONB)
The following environment variables can be configured:
DATABASE_URL- PostgreSQL connection string- Docker default:
postgresql://geocam:geocam@postgres:5432/geocam_db - Local default:
postgresql://geocam:geocam@localhost:5432/geocam_db
- Docker default:
STEGANOGRAPHY_SERVICE_URL- Node.js steganography service URL- Docker default:
http://steganography-service:3001 - Local default:
http://localhost:3001
- Docker default:
SECRET_KEY- Flask secret key (⚠️ Change in production!)DEBUG- Enable debug mode (true/false)PORT- API service port (default:5001)
NODE_ENV- Node environment (development/production)
When using Docker Compose, environment variables are automatically configured in docker-compose.yml. You can override them by:
-
Using .env file (recommended):
cp .env.example .env # Edit .env with your values -
Direct environment variables:
export SECRET_KEY="your-secure-key" docker-compose up
This guide explains how to run steganography service locally while keeping the remote database connection.
-
Get Your Local IP Address:
# On Windows ipconfig # On macOS/Linux ifconfig # or ip addr
Note down your local IP address (usually starts with 192.168.x.x or 10.0.x.x)
-
Update Mobile App Configuration:
- Open
geoCamApp/utils/backendConfig.ts - Set the following variables:
// Keep main API service in production const USE_LOCAL_FOR_TESTING = false; // But use local steganography service const USE_LOCAL_STEGANOGRAPHY_ONLY = true; // Update IP address to your local IP (only for steganography service) const DEV_STEG_URL = Platform.OS === 'web' ? 'http://localhost:3001' : 'http://YOUR_IP_ADDRESS:3001';
- Open
-
Update Backend Configuration:
- Open
Web_Backend/config.py - Set the steganography service URL to local:
STEGANOGRAPHY_SERVICE_URL = os.getenv('STEGANOGRAPHY_SERVICE_URL', 'http://localhost:3001')
- Open
-
Start Node.js Steganography Service:
# Navigate to Web_Backend cd Web_Backend # Install dependencies if not done npm install # Start steganography service node steganography-service.js
-
Start Mobile App (in a new terminal):
# Navigate to geoCamApp cd geoCamApp # Install dependencies if not done npm install # Start Expo development server npx expo start
-
Check Local Steganography Service:
curl http://localhost:3001/health
-
Check Remote API Service:
curl https://geocam-api.onrender.com/health
-
Connection Issues:
- Ensure steganography service is running on port 3001
- Check if your phone and computer are on the same network
- Verify the IP address in
backendConfig.tsis correct - Try disabling firewall temporarily
-
Port Conflicts:
- Check if port 3001 is available:
# On Windows netstat -ano | findstr "3001" # On macOS/Linux lsof -i :3001
- Check if port 3001 is available:
To switch back to full production environment:
-
Update Mobile App Configuration:
- In
geoCamApp/utils/backendConfig.ts:const USE_LOCAL_FOR_TESTING = false; const USE_LOCAL_STEGANOGRAPHY_ONLY = false;
- In
-
Update Backend Configuration:
- In
Web_Backend/config.py:STEGANOGRAPHY_SERVICE_URL = os.getenv('STEGANOGRAPHY_SERVICE_URL', 'https://geocam-steganography.onrender.com')
- In