Skip to main content

Prerequisites

Before setting up Dashboard Dilemmas, ensure you have the following installed:
  • Node.js v18 or higher
  • MySQL database server
  • Apache web server (for production deployment)
  • Git for version control

Installation

1

Clone the Repository

Clone the Dashboard Dilemmas repository to your local machine:
git clone <repository-url>
cd dashboard-dilemas
2

Install Dependencies

Install the required Node.js packages:
npm install mysql2 dotenv
3

Configure Database

Create a .env file in the root directory. You can copy from .env.example:
cp .env.example .env
Add your WordPress database credentials:
.env
DB_HOST=localhost
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=your_wordpress_db
4

Set Up Database Schema

Run the setup script to create the necessary database tables:
node scripts/setup-db.js
This script creates the following tables:
  • de_app_users - Application users
  • de_app_games - Game sessions
  • de_app_clients - Client organizations
  • de_app_answers - User responses
  • de_app_areas - Business areas
  • de_app_comparison - Comparison analytics
The setup script creates tables only. You may need to manually insert initial data using the SQL files in the sql/ directory or reference data from lib/data.ts.bak.
5

Configure Application Settings

Edit includes/config.php to configure your environment:
includes/config.php
// Site Configuration
define('SITE_URL', 'http://localhost:8888/dashboard-dilemas');
define('WP_SITE_URL', 'http://localhost:8888/dilemas');
define('WP_PATH', '/path/to/wordpress');

// SMTP Settings (Brevo, SendGrid, or Gmail)
define('SMTP_HOST', 'smtp-relay.brevo.com');
define('SMTP_USER', 'your-smtp-user');
define('SMTP_PASS', 'your-smtp-password');
define('SMTP_PORT', 587);
define('SMTP_SECURE', 'tls');
define('SMTP_FROM_EMAIL', '[email protected]');
define('SMTP_FROM_NAME', 'Dilemas Eticos');

// Gemini AI API Key
define('GEMINI_API_KEY', 'your-api-key');
Get your Gemini API key from Google AI Studio
6

Start Development Server

Start the development server:
npm run dev
The application will be available at http://localhost:3000

Database Schema Files

The sql/ directory contains various schema and migration files:
  • database.sql - Main database schema
  • users.sql - User table schema
  • areas_schema.sql - Business areas schema
  • compare_schema.sql - Comparison feature schema
  • update_analytics_schema.sql - Analytics tables
  • add_performance_indexes.sql - Performance optimization indexes
  • optimizations.sql - Additional database optimizations
  • mock_comparison_data.sql - Sample data for testing

Development Tools

The dev/ directory contains helpful utilities:

Checks

  • check-user.php - Verify user authentication
  • check_columns.php - Validate database columns
  • check_games.php - Test game data integrity

Debug Scripts

  • debug_areas.php - Debug area functionality
  • debug_db.php - Database connection testing
  • debug_pagination.php - Pagination testing
  • debug_relation.php - Relationship validation
  • debug_schema.php - Schema inspection
  • debug_winners.php - Winners calculation testing

Tests

  • test-hash.php - Password hashing tests
  • test-session.php - Session management tests
  • test-smtp.php - Email sending tests
  • test-wp-auth.php - WordPress authentication tests
  • test-wp-mail.php - WordPress mail integration tests

Troubleshooting

Database Connection Issues

If you encounter database connection errors:
  1. Verify MySQL is running
  2. Check credentials in .env file
  3. Run dev/debug/debug_db.php to test connection

SMTP Configuration

Test email functionality:
php dev/tests/test-smtp.php

WordPress Integration

The application integrates with WordPress for authentication. Ensure:
  • WordPress is installed and accessible
  • WP_PATH and WP_SITE_URL are correctly configured in includes/config.php
  • WordPress database tables are accessible

Next Steps

File Structure

Understand the project organization

Deployment

Deploy to production

Build docs developers (and LLMs) love