Website for Optimal SES, a family-owned construction company providing comprehensive construction solutions throughout the Chicago area.
Built by the GSU Software Engineering Club using Flask, SQLAlchemy, and modern web technologies.
Optimal SES Website is a professional web presence for a construction company with:
- Lead Generation: Contact and quote forms with database persistence
- Admin Dashboard: View and manage all submissions
- Email Notifications: Automatic email alerts when leads submit forms
- Bilingual Support: English/Spanish interface highlighting Spanish language capabilities
- Security: CSRF protection, rate limiting, input validation, email sanitization
- Professional Design: Dark theme with orange accent color
- Flask 3.0.0 - Web framework
- SQLAlchemy - ORM for database management
- Flask-Migrate - Database migrations
- Flask-Mail - Email sending via Gmail SMTP
- Flask-Limiter - Rate limiting on forms and login
- Flask-WTF - CSRF protection
- SQLite - Local development
- PostgreSQL (Supabase) - Production on Render
- HTML5 - Semantic markup
- CSS3 - Custom dark theme with responsive design
- Vanilla JavaScript - Mobile menu toggle
- Render - Hosting and auto-deployment
- GitHub - Version control with branch protection
- Gmail SMTP - Email sending
- π Home - Hero section with service cards
- π About - Company mission, values, and credentials
- ποΈ Projects - Showcase of completed work
- β Testimonials - Client reviews and statistics
- π Contact - Direct contact form
- π¬ Quote - Detailed project quote request form
- π Bilingual - Spanish language messaging
- π Admin Login - Secure authentication
- π Leads Dashboard - View all form submissions
- π§ Email Notifications - Automatic alerts when leads submit
- β±οΈ Session Management - 2-hour session timeout
- π Security - Rate limiting, CSRF protection
- β Rate Limiting - 3 form submissions/hour, 5 login attempts/minute
- β CSRF Protection - Token validation on all forms
- β Input Validation - Strict checks on all user inputs
- β Email Sanitization - Prevents header injection attacks
- β Session Security - 2-hour timeout, automatic refresh
- β Email Validation - Format checking on all email addresses
- β Payload Limits - Maximum message length (5000 chars)
- Python 3.12+
- Git
- GitHub account
- Gmail account (with 2FA and app password)
- Render account (for deployment)
git clone https://github.com/Governors-State-Technology-Clubs/OptimalSES_Website.git
cd OptimalSES_Websitepython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root:
# Flask Configuration
SECRET_KEY=<generate-via-command-below>
# Database (SQLite for local development)
DATABASE_URL=sqlite:///app.db
# Admin Credentials
ADMIN_USERNAME=admin
ADMIN_PASSWORD=<strong-password-16-chars>
# Email Configuration (Gmail SMTP)
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=465
MAIL_USE_TLS=False
MAIL_USERNAME=<your-gmail-account>
MAIL_PASSWORD=<gmail-app-password>
MAIL_FROM_EMAIL=<your-email>
ADMIN_EMAIL=<your-email>python -c "import secrets; print(secrets.token_urlsafe(32))"
# Copy output to SECRET_KEY- Go to https://myaccount.google.com/
- Click Security
- Enable 2-Step Verification (if not already enabled)
- Go to App passwords
- Select Mail and Windows Computer
- Copy the 16-character password
flask db upgradeIf migrations folder doesn't exist:
flask db init
flask db migrate -m "Initial migration"
flask db upgradepython app.pyVisit http://localhost:5000
- Visit http://localhost:5000/quote
- Fill in all fields
- Submit
- Check your email inbox (~10 seconds)
- Visit http://localhost:5000/contact
- Fill in all fields
- Submit
- Check your email inbox
- Visit http://localhost:5000/admin/login
- Username:
admin - Password: (from your
.env) - View all submitted leads
- Click logout
- Submit 4 quotes in 1 hour
- 4th submission should fail with "Rate limit exceeded"
git add .
git commit -m "feat: initial production setup"
git push origin main- Go to https://render.com
- Click New + β Web Service
- Connect your GitHub repository
- Configure:
- Name:
optimal-ses - Environment:
Python 3 - Build Command:
pip install -r requirements.txt - Start Command:
gunicorn app:app
- Name:
In Render dashboard β Settings β Environment:
SECRET_KEY=<your-secret-key>
DATABASE_URL=sqlite:///app.db
ADMIN_USERNAME=admin
ADMIN_PASSWORD=<your-password>
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=465
MAIL_USE_TLS=False
MAIL_USERNAME=<gmail-account>
MAIL_PASSWORD=<app-password>
MAIL_FROM_EMAIL=<email>
ADMIN_EMAIL=<email>
Click Deploy and wait for build to complete (~2 minutes)
- Visit your Render URL:
https://optimal-ses.onrender.com - Test quote/contact forms
- Check email inbox
- Test admin panel
- Go to https://supabase.com
- Sign up with GitHub
- Create project (save database password)
- Wait for database creation (~30 sec)
- In Supabase dashboard β Settings β Database
- Copy URI connection string
- Replace
[YOUR-PASSWORD]with your database password
Example:
postgresql://postgres:YourPassword@db.xxxxx.supabase.co:5432/postgres
DATABASE_URL=postgresql://postgres:YourPassword@db.xxxxx.supabase.co:5432/postgrespip install psycopg2-binary==2.9.9flask db upgradeUpdate DATABASE_URL in Render environment variables with Supabase connection string.
Note: Local development works fine with SQLite. Only use Supabase in production if needed.
-
Enable 2FA on your Gmail account
-
Generate App Password:
- Go to https://myaccount.google.com/security
- Click App passwords
- Select Mail and Windows Computer
- Copy 16-character password
-
Update
.env:MAIL_USERNAME=your-gmail@gmail.com MAIL_PASSWORD=xxxx xxxx xxxx xxxx
-
Test by submitting a form
- Port 465 (SSL) - Recommended, works for most networks
- Port 587 (TLS) - Alternative if 465 blocked
Current setup uses Port 465 (SSL).
- Visit
/admin/login - Enter credentials (from
.env) - View all form submissions in table format
- View all submissions - Contact and quote forms
- Click "View Message" - Read full submission details
- Export data - Copy submission info for CRM
- Session times out after 2 hours of inactivity
- Failed login attempts are logged for security monitoring
- Rate limiting: Max 5 login attempts per minute
| Threat | Protection |
|---|---|
| Bot spam | Rate limiting (3/hour) |
| Brute force login | Rate limiting (5/min) |
| Email injection | Header sanitization |
| CSRF attacks | Token validation |
| Session hijacking | 2-hour timeout |
| Invalid data | Input validation |
| Oversized payloads | Message length limits |
- β
Never commit
.envto GitHub - β Use strong admin password (16+ chars)
- β Regenerate Gmail app password every 6 months
- β Monitor admin login attempts in logs
- β Keep dependencies updated
-
Create feature branch:
git checkout -b feature/your-feature-name git checkout -b fix/bug-name
-
Make changes and commit:
git add . git commit -m "feat: description of changes" git push origin feature/your-feature-name
-
Open Pull Request:
- Go to GitHub
- Click "Compare & pull request"
- Fill out PR template
- Add screenshots (desktop + mobile)
- Request review
-
Code Review:
- At least 1 approval required
- Address feedback
- Merge when approved
feat: add new feature
fix: fix bug
docs: update documentation
style: code style changes
refactor: code refactoring
# Test locally
python app.py
# Test quote form
# Test contact form
# Test admin login
# Test rate limitingCheck:
- Gmail app password is correct
- 2FA is enabled on Gmail
- Port 465 is not blocked on your network
MAIL_USERNAMEandMAIL_PASSWORDmatch.env
Fix:
python -c "
import smtplib, ssl
context = ssl.create_default_context()
server = smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context)
server.login('your-email@gmail.com', 'app-password')
print('β
Email works!')
server.quit()
"SQLite table doesn't exist:
flask db upgradePostgreSQL connection failed:
- Check DATABASE_URL in
.env - Verify password doesn't have special characters (use
%40for@) - Confirm Supabase is reachable
You're submitting too many forms. Wait 1 hour or:
- Clear browser cookies
- Use incognito/private window
- Wait for rate limit to reset
- Check username/password in
.env - Clear browser cookies
- Try incognito window
- Rate limited? (max 5 attempts/min)
OptimalSES_Website/
βββ app.py # Main Flask application
βββ models.py # Database models
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (not in git)
βββ .gitignore # Git ignore rules
βββ templates/ # HTML templates
β βββ base.html # Base template (navbar, footer)
β βββ index.html # Home page
β βββ about.html # About page
β βββ projects.html # Projects page
β βββ testimonials.html # Testimonials page
β βββ contact.html # Contact form
β βββ quote.html # Quote form
β βββ admin_login.html # Admin login
β βββ admin_leads.html # Admin dashboard
β βββ 404.html # 404 error page
β βββ 500.html # 500 error page
βββ static/ # Static files
β βββ css/
β βββ style.css # Main stylesheet
βββ migrations/ # Database migrations
βββ instance/ # Instance files (app.db, etc)
βββ README.md # This file
# Required
SECRET_KEY # Flask session encryption key
ADMIN_USERNAME # Admin login username
ADMIN_PASSWORD # Admin login password
MAIL_USERNAME # Gmail account
MAIL_PASSWORD # Gmail app password
ADMIN_EMAIL # Email to receive submissions
# Optional
DATABASE_URL # Database connection (default: SQLite)
MAIL_SERVER # SMTP server (default: smtp.gmail.com)
MAIL_PORT # SMTP port (default: 465)
MAIL_USE_TLS # Use TLS (default: False for port 465)
MAIL_FROM_EMAIL # From email addressLocated in app.py:
- Session timeout: 2 hours
- Rate limits: 3 forms/hour, 5 logins/minute
- Message length: 10-5000 characters
- Name length: 2-100 characters
- Phone length: Max 20 characters
- β Handles 100+ monthly form submissions
- β Database scales to 10,000+ leads
- β Email sending <1 second
- β Form validation <10ms
When you need more:
- Upgrade to Supabase paid tier (auto-scaling)
- Add Redis for caching
- Implement queue system for emails (Bull, Celery)
- Add CDN for static assets (CloudFlare)
- Monitor with Sentry or New Relic
- Issues: Create GitHub issue with details
- Questions: Ask in PR comments
- Security: Never commit sensitive data (.env, passwords)
MIT License - See LICENSE file for details
Built by the GSU Software Engineering Club
- Mario Mendez - Backend/Setup
- GSU SWE Club Members
- Fork repository
- Create feature branch
- Make changes
- Open pull request
- Get approval and merge
- Individual user accounts (vs shared admin)
- SMS notifications for leads
- Mobile app
- CRM integration
- Payment processing
- Live chat support
- Email campaign system
- Advanced analytics
- All
.envvariables set - Email tested locally
- Admin panel tested locally
- Quote/contact forms tested locally
- Code pushed to main branch
- Render build successful
- Email working in production
- Admin panel working in production
- Forms working in production
Last Updated: January 6, 2026 Status: β Production Ready