museum-database-bangladesh

Unified Museum Database for Bangladesh

Project Overview

This project is a web-based application designed to manage a unified database for museums in Bangladesh. It serves two main types of users:

  1. General Users: Can browse museums, events, art pieces, and purchase tickets.
  2. Administrators: Have full control over the database, including managing museums, events, artifacts, and ticket pricing.

Features

User Features

Admin Features

Technology Stack

Database Schema

The system uses a relational database with the following key tables:

Installation & Setup

GitHub Deployment Path

This project is PHP + MySQL, so it cannot be hosted on GitHub Pages.

The repository now includes GitHub-native deployment automation:

  1. CI workflow: .github/workflows/ci.yml
    • Runs PHP lint checks on push and pull request.
  2. Deployment workflow: .github/workflows/deploy-ghcr.yml
    • Builds the app container from Dockerfile.
    • Publishes image tags to GitHub Container Registry (ghcr.io).
  3. Server deployment workflow: .github/workflows/deploy-server.yml
    • Manual deploy to your server over SSH.
    • Runs Docker Compose and applies DB migrations.

How to use it:

  1. Push to main and verify CI plus GHCR image publish workflows are green.
  2. Set repository secrets for server deployment:
    • DEPLOY_HOST
    • DEPLOY_USER
    • DEPLOY_SSH_KEY
    • DEPLOY_PATH
  3. Run Deploy To Server manually from the Actions tab.

Notes:

Prerequisites

1. Database Setup

  1. Create a database named MUSEUM_DATABASE.
  2. Import the schema and data:
    sudo mysql -e "CREATE DATABASE IF NOT EXISTS MUSEUM_DATABASE;"
    sudo mysql MUSEUM_DATABASE < museum_database.sql
    sudo mysql MUSEUM_DATABASE < update_tickets_event.sql
    sudo mysql MUSEUM_DATABASE < update_users_role.sql
    sudo mysql MUSEUM_DATABASE < create_bookings_table.sql
    

2. Configuration

The database connection is defined in config.php.

3. Running the Application

On Linux / Codespaces: Due to environment specifics, use the custom INI file to ensure MySQL extensions are loaded:

php -c php-custom.ini -S 0.0.0.0:8000

On XAMPP (Windows): Place the project folder in htdocs and start Apache and MySQL via the XAMPP Control Panel. Access via http://localhost/your-folder-name.

4. Hosting in GitHub Codespaces

GitHub Codespaces provides a complete development environment with PHP and MySQL pre-configured:

Automatic Setup (Recommended):

  1. Open in Codespaces: Click “Code” → “Create codespace on main” (or “Rebuild container” if you already have one)
  2. The .devcontainer configuration will automatically:
    • Build custom Docker image with PHP 8.3 and mysqli extension pre-installed
    • Set up MySQL database
    • Import all database schemas
    • Configure port forwarding
  3. Wait for setup to complete - You’ll see “✅ Database setup complete!” message
  4. Start the Application:
    php -S 0.0.0.0:8000
    
  5. Access Your Application: Codespaces will forward port 8000 and provide a public URL (e.g., https://username-repo-xxxxx.github.dev)
  6. Make Port Public (Optional): In the Ports panel, right-click port 8000 and select “Port Visibility” → “Public” to share with others

Important: If you’re getting “mysqli not found” error:

Manual Setup (if automatic setup fails):

  1. Install PHP mysqli extension:
    sudo apt-get update
    sudo apt-get install -y php8.3-mysqli php8.3-mysql
    sudo phpenmod mysqli
    
  2. Restart PHP-FPM or your terminal to load the extension
  3. Start MySQL Service:
    sudo systemctl start mysql
    sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';"
    sudo mysql -e "FLUSH PRIVILEGES;"
    
  4. Create and Import Database:
    mysql -u root -e "CREATE DATABASE IF NOT EXISTS MUSEUM_DATABASE;"
    mysql -u root MUSEUM_DATABASE < museum_database.sql
    mysql -u root MUSEUM_DATABASE < update_tickets_event.sql
    mysql -u root MUSEUM_DATABASE < update_users_role.sql
    mysql -u root MUSEUM_DATABASE < create_bookings_table.sql
    
  5. Start the Application:
    php -S 0.0.0.0:8000
    

Note: GitHub Codespaces is a development environment, not permanent hosting. For production use, deploy to a VPS, shared hosting, or PaaS platform.

Deployment for Online Hosting

For security and flexibility, config.php supports environment variables for database configuration:

Production Considerations

  1. Security:
    • Set display_errors = Off in production PHP configuration
    • Use strong database passwords
    • Set environment variables instead of using defaults
    • Enable HTTPS for secure connections
    • Review and harden file permissions
  2. Database:
    • Use lowercase table names (already implemented)
    • Ensure MySQL/MariaDB is configured for case-insensitive table names on Linux if needed
    • Regular backups of the database
    • Apply all schema updates: museum_database.sql, update_tickets_event.sql, update_users_role.sql, create_bookings_table.sql
  3. Web Server:
    • Configure appropriate PHP-FPM/Apache settings
    • Set up virtual hosts correctly
    • Enable necessary PHP extensions: mysqli, pdo_mysql

Hosting Platforms

This application can be deployed on:

File Structure

Usage Guide