DEV Community

Sabin Sim
Sabin Sim

Posted on

My Project 2: Building a Simple Memo App with Python + Streamlit

After completing the basics of Python, I'm now moving into creating small, practical projects. Today’s project is a simple Memo App that stores notes in a JSON file. I built two versions:

  • Console Version (memo_app.py)
  • Streamlit Web Version (memo_app_streamlit.py)

This project is small, but very meaningful — it teaches file handling, JSON storage, user interaction, and how to transform a console app into a clean web UI using Streamlit.


🧱 1. Project Overview

The memo app allows me to:

  • Add a new memo
  • Store it in a memos.json file
  • View all saved memos
  • Use it either in the console or through a Streamlit UI

Simple idea → Practical tool → Easy to expand later.


📂 2. Project Structure

memo_app/
│
├── memo_app.py               # Console version
├── memo_app_streamlit.py     # Streamlit version
└── memos.json                # Memo storage file

🖥️ 3. Console Version (memo_app.py)

Key features:

  • Save memos as a list of objects in memos.json
  • Simple text input interface
  • Shows all memos with timestamps

📌 Code

import json
import os
from datetime import datetime

now = datetime.now().strftime("%Y-%m-%d")

FILE_NAME = "memos.json"

if not os.path.exists(FILE_NAME):
    with open(FILE_NAME, "w") as f:
        json.dump([], f)

def load_memos():
    with open(FILE_NAME, "r") as f:
        return json.load(f)

def save_memos(memos):
    with open(FILE_NAME, "w") as f:
        json.dump(memos, f, indent=2)

print("=== Sabin's Memo App ===")
print("1) Add Memo")
print("2) Show Memos")

choice = input("Select option: ")

if choice == "1":
    memo = input("Write memo: ")
    memos = load_memos()
    memos.append({
        "text": memo,
        "date": now
    })
    save_memos(memos)
    print("Memo saved!")

elif choice == "2":
    memos = load_memos()
    print("=== Memo List ===")
    for i, m in enumerate(memos, start=1):
        print(f"{i}. {m['text']}  ({m['date']})")

else:
    print("Invalid option.")
Enter fullscreen mode Exit fullscreen mode

🌐 4. Streamlit Version (memo_app_streamlit.py)

Why Streamlit?

Because Streamlit allows you to turn Python scripts into clean and interactive web apps instantly — perfect for tools like memo pads.

Added features:

  • Clean web interface
  • Input validation
  • Radio menu navigation
  • Instant memo display

📌 Code

import streamlit as st
import json
import os
from datetime import datetime

FILE_NAME = "memos.json"

if not os.path.exists(FILE_NAME):
    with open(FILE_NAME, "w") as f:
        json.dump([], f)

def load_memos():
    with open(FILE_NAME, "r") as f:
        return json.load(f)

def save_memos(memos):
    with open(FILE_NAME, "w") as f:
        json.dump(memos, f, indent=2)

st.title("📝 Sabin's Memo App (Streamlit Version)")

menu = st.radio("Select an option:", ["Add Memo", "Show Memos"])

if menu == "Add Memo":
    text = st.text_input("Write your memo:")

    if st.button("Save Memo"):
        if text.strip() == "":
            st.warning("Memo cannot be empty.")
        else:
            now = datetime.now().strftime("%Y-%m-%d")
            memos = load_memos()
            memos.append({"text": text, "date": now})
            save_memos(memos)
            st.success("Memo saved!")

elif menu == "Show Memos":
    memos = load_memos()

    if not memos:
        st.info("No memos yet.")
    else:
        st.subheader("📄 Memo List")
        for i, memo in enumerate(memos, start=1):
            st.write(f"**{i}. {memo['text']}**  ({memo['date']})")
Enter fullscreen mode Exit fullscreen mode

⚙️ 5. How to Run

✔ Console Version

python3 memo_app.py

✔ Streamlit Version


pip install streamlit
streamlit run memo_app_streamlit.py

Streamlit will automatically open the web UI in your browser.


📚 6. What I Learned

  • How to store data using JSON files
  • How to read/write local storage safely
  • How to add a UI layer using Streamlit
  • How to upgrade a CLI tool into a web app
  • Why small projects help build strong foundations

🔧 7. Future Improvements

  • Add memo deletion
  • Add memo editing
  • Move storage to SQLite
  • Add search/filter function
  • Streamlit dark/light mode toggle

Top comments (0)