Backend Setup
Prerequisites
- PHP 8.3+
- Composer
- Docker Desktop (for PostgreSQL)
Environment
Backend env file: backend/.env
Required database values for Laravel:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=techtutor
DB_USERNAME=techtutor_user
DB_PASSWORD=techtutor_passRequired values for Docker Postgres service (read through Compose env file):
POSTGRES_DB=techtutor
POSTGRES_USER=techtutor_user
POSTGRES_PASSWORD=techtutor_passOptional mail values for email notifications:
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_USERNAME=your-mailbox@example.com
MAIL_PASSWORD=your-app-password
MAIL_FROM_ADDRESS=your-mailbox@example.com
MAIL_FROM_NAME=TechTutorUse an app password for Gmail SMTP. Do not commit real mail credentials.
Start Database
From project root:
docker compose up -dPostgres data is persisted under:
backend/database/data
Install and Run Backend
From backend:
composer install
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan serveSeeded Demo Accounts
After php artisan migrate --seed or composer db:fresh, these local demo accounts are available (password: password):
admin@techtutor.test— adminbackend@techtutor.test— instructor (backend course owner)frontend@techtutor.test— instructor (frontend course owner)ml@techtutor.test— instructor (ml course owner)devops@techtutor.test— instructor (devops course owner)student@techtutor.test— student (enrolled in seeded courses)student2@techtutor.test— student (additional student)banned@techtutor.test— banned student (for ban enforcement tests)
Shared password for all demo accounts:
passwordUseful Commands
php artisan migrate:fresh --seed
composer cleanup
composer cleanup:optimize
composer start:fresh
composer start:fresh:seed
php artisan test
vendor/bin/pintCleanup
composer cleanupClears Laravel’s compiled and runtime caches to restore a clean application state.
Internally runs:
php artisan optimize:clearphp artisan config:clearphp artisan cache:clearphp artisan route:clearphp artisan view:clearphp artisan event:clear
Use this after:
- changing
.envvalues - pulling new branches
- dependency updates
- encountering unexpected cached behavior during local development
Cleanup + Optimize
composer cleanup:optimizeRuns the standard cleanup and then rebuilds optimized caches using:
php artisan optimize
This is useful when you want a clean but fully optimized local state.
Reset Database Quickly
First-start cleanup and migrate from backend:
composer start:freshThis runs the cleanup command and then executes database migrations.
First-start cleanup, migrate, and seed from backend:
composer start:fresh:seedThis performs the same cleanup, then runs a fresh migration and seeds the database.
Soft reset from backend:
composer db:freshThis recreates all tables and reseeds the database, but keeps the Postgres data directory/container in place.
INFO
In this project, docker compose down -v alone does not fully wipe Postgres data because the database is stored in a bind-mounted folder at backend/database/data, not a named Docker volume.