{"id":159,"date":"2025-10-28T02:17:59","date_gmt":"2025-10-28T02:17:59","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=159"},"modified":"2025-10-28T02:17:59","modified_gmt":"2025-10-28T02:17:59","slug":"22-real-world-python-projects-personal-diary-journal-app","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=159","title":{"rendered":"22 &#8211; Real-World Python Projects &#8211; Personal Diary \/ Journal App"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\"><\/h6>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83c\udfaf <strong>Project Objective<\/strong><\/h3>\n\n\n\n<p>To create a secure and organized digital diary application that allows users to <strong>write, view, edit, search, and save personal notes<\/strong> with date and time stamps \u2014 optionally password-protected.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\udde9 1. <strong>Project Overview<\/strong><\/h2>\n\n\n\n<p>A <strong>Personal Diary App<\/strong> helps users record daily thoughts, plans, and experiences.<br>This project combines <strong>file handling<\/strong>, <strong>datetime<\/strong>, <strong>encryption<\/strong>, and <strong>GUI (optional)<\/strong> for a professional journaling experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2728 Real-World Uses:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maintain a digital journal securely<\/li>\n\n\n\n<li>Track daily moods or productivity<\/li>\n\n\n\n<li>Store study or work reflections<\/li>\n\n\n\n<li>Create private notes with password protection<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2699\ufe0f 2. <strong>Required Modules<\/strong><\/h2>\n\n\n\n<p>These modules will auto-install if missing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nimport datetime\nimport getpass\n\n# Auto-install modules if missing\ntry:\n    from cryptography.fernet import Fernet\nexcept ModuleNotFoundError:\n    import subprocess\n    subprocess.check_call(&#91;\"pip\", \"install\", \"cryptography\"])\n    from cryptography.fernet import Fernet\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\udde0 3. <strong>Generate Encryption Key<\/strong><\/h2>\n\n\n\n<p>To secure diary entries, we\u2019ll use encryption.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def generate_key():\n    \"\"\"Generate and store a key for encryption\"\"\"\n    if not os.path.exists(\"secret.key\"):\n        key = Fernet.generate_key()\n        with open(\"secret.key\", \"wb\") as key_file:\n            key_file.write(key)\n    else:\n        with open(\"secret.key\", \"rb\") as key_file:\n            key = key_file.read()\n    return Fernet(key)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\uddfe 4. <strong>Add New Diary Entry<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def add_entry():\n    fernet = generate_key()\n    entry = input(\"Write your diary entry:\\n\")\n    date = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n    encrypted_entry = fernet.encrypt(entry.encode())\n\n    with open(\"diary.txt\", \"ab\") as file:\n        file.write(f\"\\n&#91;{date}] \".encode() + encrypted_entry + b\"\\n\")\n    print(\"\u2705 Entry saved successfully!\")\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcd6 5. <strong>View Diary Entries<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def view_entries():\n    fernet = generate_key()\n    if not os.path.exists(\"diary.txt\"):\n        print(\"No diary entries found.\")\n        return\n\n    with open(\"diary.txt\", \"rb\") as file:\n        lines = file.readlines()\n\n    print(\"\\n\ud83d\udcd3 Your Diary Entries:\\n\")\n    for line in lines:\n        if line.strip():\n            try:\n                if line.startswith(b\"&#91;\"):\n                    timestamp = line.decode(errors=\"ignore\").split(\"]\")&#91;0] + \"]\"\n                    print(timestamp)\n                else:\n                    print(fernet.decrypt(line.strip()).decode())\n            except:\n                continue\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd0d 6. <strong>Search Entries by Keyword<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def search_entries(keyword):\n    fernet = generate_key()\n    if not os.path.exists(\"diary.txt\"):\n        print(\"No diary entries found.\")\n        return\n\n    with open(\"diary.txt\", \"rb\") as file:\n        lines = file.readlines()\n\n    print(f\"\\n\ud83d\udd0e Search results for '{keyword}':\\n\")\n    for i in range(0, len(lines), 2):\n        if len(lines) &gt; i + 1:\n            timestamp = lines&#91;i].decode(errors=\"ignore\")\n            entry = fernet.decrypt(lines&#91;i + 1].strip()).decode()\n            if keyword.lower() in entry.lower():\n                print(f\"{timestamp}\\n{entry}\\n{'-' * 40}\")\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd12 7. <strong>Optional: Password Protection<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def authenticate():\n    password = \"mysecret123\"\n    user_input = getpass.getpass(\"Enter diary password: \")\n    if user_input != password:\n        print(\"\u274c Incorrect password!\")\n        exit()\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\uddf0 8. <strong>Main Program Menu<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def main():\n    authenticate()  # Comment this out to disable password\n\n    while True:\n        print(\"\\n=== Personal Diary App ===\")\n        print(\"1. Add New Entry\")\n        print(\"2. View Entries\")\n        print(\"3. Search Entries\")\n        print(\"4. Exit\")\n\n        choice = input(\"Choose an option: \")\n\n        if choice == \"1\":\n            add_entry()\n        elif choice == \"2\":\n            view_entries()\n        elif choice == \"3\":\n            keyword = input(\"Enter keyword to search: \")\n            search_entries(keyword)\n        elif choice == \"4\":\n            print(\"Goodbye \ud83d\udc4b\")\n            break\n        else:\n            print(\"Invalid choice. Try again.\")\n\nif __name__ == \"__main__\":\n    main()\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udca1 9. <strong>Enhancements &amp; Ideas<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ud83e\ude9f Add <strong>Tkinter GUI<\/strong> for user-friendly interface<\/li>\n\n\n\n<li>\ud83d\udd10 Enable <strong>per-entry encryption passwords<\/strong><\/li>\n\n\n\n<li>\u2601\ufe0f Sync diary entries to <strong>Google Drive or Dropbox<\/strong><\/li>\n\n\n\n<li>\ud83d\udcc5 Add <strong>calendar view<\/strong> to select dates<\/li>\n\n\n\n<li>\ud83e\udde0 Include <strong>sentiment analysis<\/strong> using <code>textblob<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 <strong>Summary<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>\ud83d\udd10 Security<\/td><td>Encrypts entries using <code>cryptography<\/code><\/td><\/tr><tr><td>\ud83d\uddd3 Timestamp<\/td><td>Automatically logs date\/time<\/td><\/tr><tr><td>\ud83d\udcdd Editing<\/td><td>Simple file-based system<\/td><\/tr><tr><td>\ud83d\udd0d Search<\/td><td>Keyword-based entry lookup<\/td><\/tr><tr><td>\u2699\ufe0f Extendable<\/td><td>Easily add GUI or cloud sync<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83c\udfaf Project Objective To create a secure and organized digital diary application that allows users to write, view, edit, search, and save personal notes with date and time stamps \u2014 optionally password-protected. \ud83e\udde9 1. Project Overview A Personal Diary App helps users record daily thoughts, plans, and experiences.This project combines file handling, datetime, encryption, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=159"}],"version-history":[{"count":1,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/159\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}