Goal: Transform Connectly into a production-grade, secure, reliable, and industry-standard real-time chat application.
Must be completed before any feature or UI work.
- Replace plaintext password storage with Argon2 hashing
- Use
werkzeug.security.generate_password_hash - Use
werkzeug.security.check_password_hash
- Remove all hardcoded secrets from
app.py - Add
python-dotenvsupport - Load
SECRET_KEY,DATABASE_URLfrom environment - Create
config.pywith Dev / Staging / Prod configs
- Enable CSRF protection using
Flask-WTFCSRFProtect - Add strict Content Security Policy (CSP) headers
- No inline scripts
- No eval
- Secure session cookies:
-
HttpOnly -
Secure -
SameSite=Lax
-
- Prevent SQL Injection:
- Migrate raw SQL to
SQLAlchemyORM
- Migrate raw SQL to
- Backend ReCAPTCHA verification on
/register - Rate limiting with
Flask-Limiter:- Auth routes
- Chat routes
- Split
app.pyinto Blueprints:-
auth -
chat -
main
-
- Implement Application Factory Pattern (
create_app()) - Introduce
services/layer for business logic- Keep routes thin, logic in services
- Enable WAL mode for concurrency
- Enable foreign key enforcement
- Integrate
Flask-Migrate(Alembic)
- Use UUIDs for primary keys
- Add indexes:
-
user_id -
chat_id -
timestamp
-
- Add type hints to all functions
- Add docstrings (Google or NumPy style)
- Enforce formatting & linting:
-
black -
rufforflake8
-
- Centralized error handling:
- JSON errors for APIs
- HTML errors for views
- Replace generic div containers with:
-
<main> -
<header> -
<section>
-
- Enforce one
<h1>per page - Maintain logical heading hierarchy
- Replace
div.buttonwith<button type="button">
- Add
aria-labelto icon-only buttons - Ensure all form inputs have
<label for=""> - Add
aria-live="polite"for incoming messages - Ensure color contrast β₯ 4.5:1
- Full keyboard navigation with visible focus states
- Unique
<title>per page - Unique
<meta description>per page - Ensure
<html lang="en"> - Add Open Graph tags (optional)
- Adopt BEM naming convention
- Refactor
stylechat.cssandstylelogin.css - Remove all inline styles
- Define CSS Variables for:
- Colors
- Spacing
- Typography
- Use
clamp()for fluid typography - Mobile-first media queries (min-width)
- Use logical properties (
margin-inline,padding-block)
- Material 3 inspired UI
- Glassmorphism / premium gradients
- Micro-animations (hover, focus, transitions)
- Dark & Light mode via CSS variables
- Use ES2020+
- Switch to ES Modules (
type="module") - Use
const/letonly - Eliminate global scope pollution
- Debounce / throttle typing indicators
- Optimistic UI message rendering
- WebSocket reconnect logic with backoff
- Virtualize message list (if needed)
- Escape all user-generated content
- Never trust client-side validation alone
- Set up
pytest - Unit tests:
- Auth logic
- Chat logic
- Integration tests for API endpoints
- Lighthouse audit (target β₯ 95 all categories)
- Convert images to WebP
- Minify CSS and JS
- Enable GZIP / Brotli (
Flask-Compress)
-
README.mdwith:- Architecture overview
- Setup guide
- API documentation (OpenAPI / Markdown)
- GitHub Actions:
- Linting
- Tests
- Fail on error
- Structured JSON logs
- Log levels (DEBUG β CRITICAL)
- No sensitive data in logs
- Correlation IDs per request
- Separate access & error logs
-
/healthendpoint -
/readyendpoint - Track:
- Auth failures
- WebSocket disconnects
- Message send failures
- Basic metrics (RPS, error rate)
- Global exception handler
- Graceful shutdown handling
- Document restart strategy
- Token-based socket authentication
- Reject unauthenticated connections
- Per-user socket isolation
- Socket rate limiting
- Message size limits
- Heartbeat / ping-pong
- Stale connection cleanup
- Message ACK & delivery status
- Offline message handling
- Spam detection
- Temporary mute / cooldown
- Server-side typing throttling
- Message hash / checksum
- Server-side timestamps only
- Soft deletes (
deleted_at) - UTC everywhere
- Automated SQLite backups
- Backup rotation
- Restore procedure documented
- WAL checkpoint strategy
- Message retention policy
- Session cleanup job
- Orphaned data cleanup
- Test on Chromium & Firefox
- WebSocket fallback handling
- Avoid experimental JS APIs
- Empty states everywhere
- Loading skeletons
- Error states with retry
- Offline detection
- Failed message retry UI
- UTF-8 everywhere
- Emoji-safe rendering
- RTL-safe layout
- Date/time abstraction
-
LICENSEfile - Dependency attribution
- Privacy policy
- Terms of service
-
SECURITY.md - Vulnerability reporting process
- Responsible disclosure note
-
.editorconfig - Pre-commit hooks
- Conventional commits
- Clean commit history
- Architecture Decision Records (ADRs)
- Data model diagram
- Request/response examples
- Known limitations section
- Fully documented
.env.example - Config validation at startup
- Fail-fast on missing config