Skip to content

Production readiness: docs, config, CI, and fixes - #1

Merged
digantadatta merged 3 commits into
mainfrom
production-readiness
Nov 30, 2026
Merged

digantadatta merged 3 commits into
mainfrom
production-readiness

Conversation

@digantadatta

@digantadatta digantadatta commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Makes the project documented, installable and safer to run, without changing normal behaviour.

  • README with features, setup, configuration, run instructions, project structure and usage example
  • LICENSE (MIT, copyright 2026 Diganta Datta)
  • Python .gitignore and a lenient .flake8 config
  • requirements_lib.txt renamed to requirements.txt (no other file referenced the old name) with minimum versions: Flask>=2.3, Flask-SQLAlchemy>=3.0, Flask-Login>=0.6.2
  • SECRET_KEY is now read from the SECRET_KEY environment variable; if unset, an obviously insecure dev key is used and a warning is logged
  • main.py runs in debug mode only when FLASK_DEBUG is set to a truthy value (previously always debug=True)
  • Module docstrings

Bug fixes found while testing with current library versions

  • Sign-up crashed with Invalid hash method 'sha256' on Werkzeug 3 (generate_password_hash(..., method='sha256')). It now uses the Werkzeug default (scrypt on Werkzeug 3), still salted and hashed.
  • db.create_all(app=app) no longer exists in Flask-SQLAlchemy 3; replaced with create_all() inside an app context. The database path is now absolute (website/database.db) so it does not depend on the working directory.
  • /delete-note had no @login_required (an anonymous request would raise an error); added. Malformed JSON or a non-integer id no longer causes a 500.
  • Missing or empty form fields on login, sign-up and add-note no longer raise TypeError; whitespace-only notes are now rejected.

Password handling

Passwords were already hashed (not plain text); no plain-text passwords exist in the code or in the committed database. Verified end to end with a Flask test client: sign-up, add note, delete note, logout, wrong password, login.

Repository hygiene

website/__pycache__/*.pyc and website/database.db are no longer tracked (files stay on disk, and are now in .gitignore). The committed database had 0 users and 0 notes, so no user data was exposed.

Things the owner must check

  1. License holder: LICENSE says "Copyright (c) 2026 Diganta Datta". Change if you want a different name or license.
  2. CI workflow: .github/workflows/ci.yml is included (separate commit Add GitHub Actions CI workflow). It installs requirements, runs py_compile, flake8 and a small smoke test on Python 3.9 and 3.12. The runner is pinned to ubuntu-24.04 because ubuntu-latest no longer provides Python 3.9. The workflow has run on this PR and passes on both Python versions.
  3. Old secret key in history: the previous hardcoded SECRET_KEY remains in git history. It was a placeholder-style dev key, but do not reuse it anywhere; set a new random SECRET_KEY in any real deployment.
  4. Existing password hashes: none in the committed DB. If you have a local database with users created via the old sha256 method, those hashes will not verify on Werkzeug 3 and those users must sign up again.
  5. CSRF protection is not implemented (would need Flask-WTF and template changes); not added to keep behaviour unchanged.
  6. Screenshot (6).png shows browser tabs and a taskbar. It is referenced in the README; swap it if you prefer a cleaner image.
  7. Tested locally on Python 3.12 with Flask 3.1, Flask-SQLAlchemy 3.1, Flask-Login 0.6.3. Python 3.9 is confirmed by CI.

- Add README, MIT LICENSE, .gitignore and flake8 config
- Rename requirements_lib.txt to requirements.txt with minimum versions
- Read SECRET_KEY from the environment (dev fallback with a warning)
- Run Flask in debug mode only when FLASK_DEBUG is set
- Fix sign-up crash on current Werkzeug (method='sha256' is no longer supported)
- Fix database creation for Flask-SQLAlchemy 3 and use an absolute database path
- Require login on /delete-note and validate request input
- Stop tracking __pycache__ and the local SQLite database
- Add module docstrings
@digantadatta
digantadatta merged commit c8e29e2 into main Nov 30, 2026
2 checks passed
@digantadatta
digantadatta deleted the production-readiness branch November 30, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant