A modern, responsive web application for custom coffee blending and ordering, featuring Firebase authentication, Google Sign-In, and an interactive Coffee Studio for creating personalized coffee blends.
π₯ Team Project Setup: This is a collaborative team project. Firebase configuration and environment files will be provided by the project lead. Follow the setup instructions below to get started.
- π₯ Firebase Authentication - Secure user authentication with Google Sign-In integration
- β Coffee Studio - Interactive DIY coffee blending and premade selections
- π Shopping Cart - Add custom blends to cart and manage orders
- π± Responsive Design - Mobile-first design with Bootstrap 5
- π¨ Modern UI - Apple Garamond typography and coffee-themed design
- π Security - CSRF protection, rate limiting, and secure middleware
- PHP 7.4+ (Recommended: PHP 8.1+)
- Composer (Dependency manager)
- Git (Version control)
π Note: This is a team project. Firebase keys and environment configuration will be provided by the project lead.
# Clone the repository
git clone <team-repo-url> costobrew
cd costobrew
# Install PHP dependencies
composer install
Contact the project lead to obtain:
.env
file (environment configuration)config/firebase-service-account.json
(Firebase authentication keys)
Place these files in the project root and config directory respectively.
β οΈ Important: Never commit.env
or Firebase service account files to version control!
# Start PHP development server
php -S localhost:8000
# Application will be available at:
# http://localhost:8000
- Open browser to
http://localhost:8000
- Test Firebase authentication by trying to login/signup
- Explore Coffee Studio features
π You're ready to develop! The application should be running with full Firebase authentication.
- Go to Firebase Console
- Create a new project
- Enable Authentication > Sign-in method > Google
- Project Settings > Service Accounts
- Generate new private key
- Save as
config/firebase-service-account.json
- Project Settings > General > Your apps
- Add web app and copy config
- Update
.env
with the values
Example config/firebase-service-account.json
:
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
"auth_uri": "...",
"token_uri": "...",
"auth_provider_x509_cert_url": "...",
"client_x509_cert_url": "..."
}
π Detailed Firebase setup instructions: See
FIREBASE_SETUP.md
οΏ½ Google Sign-In setup instructions: SeeGOOGLE_SIGNIN_SETUP.md
# Ensure mod_rewrite is enabled
# .htaccess file is already configured
server {
listen 80;
server_name yourdomain.com;
root /path/to/costobrew;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
php -S localhost:8000 -t public index.php
# Make cache and logs writable
chmod -R 755 cache/
chmod -R 755 logs/
# Secure sensitive files
chmod 600 .env
chmod 600 config/firebase-service-account.json
costobrew/
βββ app/
β βββ config/ # Configuration files
β βββ controller/ # Application controllers
β βββ core/ # Core framework files
β βββ middleware/ # Security & auth middleware
β βββ model/ # Data models
β βββ view/ # HTML templates
βββ cache/ # Application cache
βββ logs/ # Application logs
βββ src/
β βββ assets/ # Images & static files
β βββ css/ # Stylesheets
β βββ js/ # JavaScript files
βββ config/ # Firebase & external configs
βββ .env # Environment variables
βββ .htaccess # Apache configuration
βββ composer.json # PHP dependencies
βββ index.php # Application entry point
# Start PHP development server (this is what we use)
php -S localhost:8000
π Team Note: We use the PHP built-in development server for this project. No need for XAMPP/WAMP.
- Home:
/
- Coffee Studio:
/studio
- DIY Blends:
/studio/diy
- Premade Blends:
/studio/premade
- Login:
/login
- Cart:
/cart
# Check PHP errors
tail -f logs/php-error.log
# Test Firebase connection
php -r "require 'vendor/autoload.php'; echo 'Dependencies loaded successfully';"
- CSRF Protection - All forms protected with CSRF tokens
- Rate Limiting - Prevents brute force attacks
- Input Validation - Server-side validation for all inputs
- Secure Headers - CSP, HSTS, and security headers
- Firebase Auth - Industry-standard authentication
- Chrome 90+ β
- Firefox 88+ β
- Safari 14+ β
- Edge 90+ β
- Mobile browsers β
# Set production environment
APP_ENV=production
FIREBASE_DISABLE_SSL_VERIFY=false
# Optimize Composer autoloader
composer install --no-dev --optimize-autoloader
# Clear development cache
rm -rf cache/*
- Update all default passwords
- Enable HTTPS
- Configure proper file permissions
- Set up regular backups
- Monitor logs for security issues
- Update
.env
with production values
1. Firebase Authentication Not Working
# Check service account file exists
ls -la config/firebase-service-account.json
# Verify environment variables
cat .env | grep FIREBASE
2. Database Connection Issues
# Test database connection
php -r "
$pdo = new PDO('mysql:host=localhost;dbname=costobrew_db', 'user', 'pass');
echo 'Database connected successfully';
"
3. 404 Errors
- Ensure
.htaccess
is in place for Apache - Check web server URL rewriting is enabled
- Verify
index.php
is in the correct location
4. Permission Errors
# Fix file permissions
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod 600 .env config/firebase-service-account.json
For setup assistance or bug reports:
- Email: support@costobrew.com
- Documentation: Check
FIREBASE_SETUP.md
andGOOGLE_SIGNIN_SETUP.md
This project is proprietary software. All rights reserved.
Made with β by the Costobrew Team
<FilesMatch ".php$"> Require all denied Require expr "%{REQUEST_URI} =~ m#^/index.php#" Require expr "%{REQUEST_URI} =~ m#^/firebase-setup.php#" Require expr "%{REQUEST_URI} =~ m#^/test-routes.php#"
#### Nginx
```nginx
server {
listen 80;
server_name localhost;
root /path/to/costobrew;
index index.php;
# Security headers
add_header X-Frame-Options DENY always;
add_header X-Content-Type-Options nosniff always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Route all requests to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP processing
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Deny access to sensitive files
location ~ /\. {
deny all;
}
location ~ /(config|app)/ {
deny all;
}
}
- Start your web server
- Visit
http://localhost:8000
- Use
/firebase-setup.php
to verify your Firebase configuration - Register a new account or login
/
- Homepage/login
- User login/signup
- User registration/community
- Browse products/community/product/{id}
- Product details
/studio
- Coffee Studio main page/studio/diy
- DIY coffee builder/studio/premade
- Premade coffee selection/cart
- Shopping cart/checkout
- Order checkout/orders
- Order history/settings
- User settings
GET /api/auth/check
- Check authentication statusGET /api/auth/user
- Get current user infoPOST /logout
- Logout user
- Firebase Authentication - Secure token-based authentication
- CSRF Protection - Prevents cross-site request forgery
- Rate Limiting - Prevents abuse and spam
- Security Headers - XSS protection, content type sniffing prevention
- Input Validation - Server-side validation for all inputs
- Secure Sessions - HTTP-only, secure cookies in production
costobrew/
βββ app/
β βββ config/ # Configuration files
β β βββ database.php
β β βββ firebase.php
β βββ controller/ # Application controllers
β βββ core/ # Core framework files
β βββ middleware/ # Security and auth middleware
β βββ model/ # Data models
β βββ view/ # HTML templates
βββ config/ # Configuration directory
βββ src/ # Static assets
β βββ css/
β βββ js/
β βββ assets/
βββ vendor/ # Composer dependencies
βββ .env # Environment configuration
βββ composer.json # PHP dependencies
βββ index.php # Application entry point
βββ firebase-setup.php # Firebase setup wizard
- Check
firebase-setup.php
for configuration status - Verify service account file exists and has correct permissions
- Ensure Firebase project has Authentication enabled
- Check browser console for JavaScript errors
# Make sure web server can read files
chmod 644 .env
chmod 644 config/firebase-service-account.json
chmod -R 755 app/ src/
# Clear composer cache
composer clear-cache
composer install --no-cache
// In index.php
$router->get('/new-route', 'ControllerName@method', ['FirebaseAuthMiddleware']);
// In app/middleware/
class CustomMiddleware {
public static function handle($request) {
// Middleware logic
}
}
All configuration should use environment variables defined in .env
:
$setting = $_ENV['SETTING_NAME'] ?? 'default_value';
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the
/firebase-setup.php
page for configuration help - Review the troubleshooting section above
- Create an issue on GitHub
Note: Make sure to keep your Firebase service account key secure and never commit it to version control!