A web-based system University WEB project for tracking functional and non-functional project requirements. Built with PHP backend and vanilla JavaScript frontend, containerized with Docker and deployable to Kubernetes.
- Docker and Docker Compose (for containerized development)
- PHP 8.1+ (for local development without Docker)
- Composer (PHP dependency manager)
- MySQL 8.0+ (or use Docker)
- kubectl and k3d (for Kubernetes deployment testing)
docker-compose up -dThis will:
- Build the PHP application container
- Start MySQL 8.0 database
- Run database migrations automatically
- Start the web server on port 8000
Open your browser and navigate to:
http://localhost:8000/frontend
composer testcomposer run test:unit
# or
php vendor/bin/phpunit --testsuite Unitexport DB_HOST=127.0.0.1
export DB_NAME=requirements_db
export DB_USER=root
export DB_PASS=root
composer run test:integration
# or
php vendor/bin/phpunit --testsuite Integration# Run PHP CodeSniffer (PSR-12 standard)
composer run lint
# or
vendor/bin/phpcs --standard=PSR12 src/The project uses GitHub Actions for continuous integration and deployment. The pipeline includes:
-
Quality Check
- PHP code quality checks (PSR-12)
- Unit tests
- SonarQube static analysis
-
Build & Push
- Docker image build
- Push to DockerHub (on main branch)
-
Integration Tests
- Database migrations
- Integration test suite
-
Deploy to k3d
- Kubernetes deployment to k3d cluster
- Deployment verification
Check the "Actions" tab in your GitHub repository to see pipeline runs and results.
# Install k3d
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
# Create cluster
k3d cluster create my-cluster \
--port 8000:80@loadbalancer \
--k3s-arg "--disable=traefik@server:*"
# Build Docker image
docker build -f docker/Dockerfile -t requirements-app:latest .
# Import image into k3d
k3d image import requirements-app:latest -c my-cluster
# Deploy database
kubectl apply -f k8s/db-deployment.yaml
# Wait for database to be ready
kubectl wait --for=condition=ready pod -l app=db --timeout=120s
# Deploy application
kubectl apply -f k8s/app-deployment.yaml
# Check deployment status
kubectl rollout status deployment/requirements-app --timeout=120s
# Verify pods
kubectl get pods
kubectl get services
# Access the application
# http://localhost:8000
# Cleanup
k3d cluster delete my-cluster# Apply all Kubernetes manifests
kubectl apply -f k8s/
# Check deployment
kubectl get deployments
kubectl get services
kubectl get pods.
├── src/ # Application source code
│ ├── backend/ # PHP backend
│ │ ├── api/ # API endpoints
│ │ │ ├── users.php
│ │ │ ├── projects.php
│ │ │ ├── requirements.php
│ │ │ └── ...
│ │ ├── core/ # Core functionality
│ │ │ ├── db.php # Database connection
│ │ │ └── router.php # Routing logic
│ │ └── models/ # Data models
│ └── frontend/ # Frontend application
│ ├── index.html # Main HTML file
│ ├── css/ # Stylesheets
│ └── js/ # JavaScript files
├── database/ # Database files
│ ├── migrate.php # Migration runner
│ ├── migrations/ # SQL migration files
│ │ ├── 001_initial_schema.sql
│ │ └── 002_sample_data.sql
│ └── schema.sql # Database schema
├── docker/ # Docker configuration
│ └── Dockerfile # Application Dockerfile
├── k8s/ # Kubernetes manifests
│ ├── app-deployment.yaml # Application deployment
│ ├── db-deployment.yaml # Database deployment
│ └── migration-job.yaml # Migration job
├── tests/ # Test files
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── .github/
│ └── workflows/
│ └── ci-cd.yml # CI/CD pipeline
├── docker-compose.yml # Docker Compose configuration
├── composer.json # PHP dependencies
└── phpunit.xml # PHPUnit configuration
The application uses the following environment variables:
| Variable | Description | Default |
|---|---|---|
DB_HOST |
Database host | localhost |
DB_NAME |
Database name | requirements_db |
DB_USER |
Database user | root |
DB_PASS |
Database password | (empty) |
The project uses a custom migration system similar to Flyway. Migrations are automatically run:
- Docker Compose: Via the
migrateservice - Kubernetes: Via init containers in the deployment
- Manual: Run
php database/migrate.php
Migrations are stored in database/migrations/ and are executed in alphabetical order. Applied migrations are tracked in the schema_migrations table.