JournalLM is a Python script that provides personalized insights based on your journal, using the Claude API.
- You provide your journal as an export from Day One or as a single file
- Your journal entries are sent to Claude AI with a carefully designed prompt
- Claude analyzes your journal and provides personalized insights and advice
- The response is saved as a markdown file
- In the report, JournalLM asks you to provide additional context to improve its advice over time
- Optional features are provided for more advanced usage
- Clone this repository
git clone https://github.com/Ari-Zerner/journallm cd journallm - Install dependencies:
pip install -r requirements.txt - Get an Anthropic API key:
- Sign up at Anthropic
- Create an API key
- Either:
- Create a
.envfile in the project directory withAPI_KEY = <your_anthropic_api_key>, or - When using the web interface, enter your API key directly if one isn't configured in the environment
- Create a
- Prepare your journal in one of these formats:
- Export your Day One journal (select JSON format, provide the exported ZIP file)
- Create a file with your journal entries in XML, JSON, MD, or TXT format
- See the XML Format section for a recommended format
- Run the script:
python journallm.py [your_journal_file] - Your JournalLM report will be saved as a markdown file named
advice-<date>-<time>.mdin the project directory- Tip: You can use md-to-pdf to turn the report into a nicely-formatted PDF
If you want to automatically download Day One backups from Google Drive rather than export manually:
- Set up Google Drive API:
- Go to the Google Cloud Console
- Create a new project
- Enable the Google Drive API
- Configure the OAuth consent screen:
- Set the app name and user support email
- Select "Internal" for the user type (or "External" if needed)
- Add contact information
- Create OAuth 2.0 Client ID credentials:
- Select "Desktop app" as the application type
- Download the credentials JSON file
- Save the file as
credentials.jsonin the project directory (or another location)
- Find your Google Drive folder ID:
- Navigate to your Day One backups folder in Google Drive
- The folder ID is the part of the URL after "folders/" when you open the folder
- Example: In
https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i, the folder ID is1a2b3c4d5e6f7g8h9i
- Add the folder ID and credentials file path to your
.envfile (see.env.examplefor reference) - Run the script with the
--google-driveflag to download the latest backup from Google Drive
The first time you run the application with Google Drive, it will open a browser window asking you to authorize access to your Google Drive. After authorization, a token will be saved to token.json in the project directory, so you won't need to authorize again unless the token expires.
If you want to add the generated insights directly to your Day One journal:
- Install the Day One CLI:
Note: You may need to enter your macOS device login password.
sudo bash /Applications/Day\ One.app/Contents/Resources/install_cli.sh - Verify the installation:
dayone2 -h - Run the script with the
--add-to-journalflag to add the generated insights to your Day One journal
python journallm.py [input_file] [options]
input_fileor--input PATH: Path to a local file containing journal entries (ZIP, JSON, or XML)--google-drive: Download the latest backup from Google Drive instead of using a local file--output PATH: Output filename for advice (default: auto-generated)--save-journal [PATH]: Save journal entries (pre-processed to be more readable for Claude) as an XML file with a specified or automatically-generated name--interactive [REPORT_FILE]: Start an interactive session after processing. If REPORT_FILE is provided, use that report instead of generating one--no-report: Skip report generation (for use with --interactive or --save-journal)--add-to-journal [JOURNAL]: Add the generated report to Day One in the specified journal or the default journal if not specified (see Day One CLI Setup)--debug: Enable debug logging
Process a local Day One backup ZIP file:
python journallm.py DayOneBackup.zip
# or
python journallm.py --input DayOneBackup.zip
Process a single JSON journal file:
python journallm.py journal.json
# or
python journallm.py --input journal.json
Process a pre-extracted XML file:
python journallm.py journal.xml
# or
python journallm.py --input journal.xml
Download and process the latest backup from Google Drive:
python journallm.py --google-drive
Save the report to a specific file:
python journallm.py DayOneBackup.zip --output report.md
Start an interactive session after generating a report:
python journallm.py DayOneBackup.zip --interactive
Start an interactive session to chat about your journal without generating a full report:
python journallm.py DayOneBackup.zip --no-report --interactive
Start an interactive session with a previously generated report:
python journallm.py DayOneBackup.zip --interactive advice.md
Extract journal entries from Google Drive without generating a report:
python journallm.py --google-drive --no-report --save-journal journal.xml
Get insights from a pre-extracted journal file:
python journallm.py --journal journal.xml
Add the generated insights to Day One (default journal):
python journallm.py DayOneBackup.zip --add-to-journal
Add the generated insights to a specific Day One journal:
python journallm.py DayOneBackup.zip --add-to-journal "JournalLM Reports"
Enable debug logging:
python journallm.py --debug
When processing a Day One export, JournalLM creates an XML structure with the following format:
<journal_entries>
<entry>
<created>2023-01-01T12:00:00Z</created>
<modified>2023-01-01T12:00:00Z</modified>
<journal>Journal Name 1</journal> <!-- Only included if multiple journals -->
<loc>Location information</loc>
<text>Journal entry text</text>
</entry>
<entry>
<created>2023-01-02T15:30:00Z</created>
<modified>2023-01-02T15:30:00Z</modified>
<journal>Journal Name 2</journal> <!-- Only included if multiple journals -->
<loc>Coffee Shop</loc>
<text>Another journal entry</text>
</entry>
<!-- More entries, sorted by creation date -->
</journal_entries>This is the output of the --save-journal flag, and the recommended input format for providing your own journal entries.
JournalLM includes a web interface for easy file uploads and processing. To run the web app:
-
Make sure you have the required dependencies installed:
pip install flask markdown2 -
Start the web server:
python web_app.py -
Open your browser to
http://localhost:5000
The web interface provides:
- Simple drag-and-drop file upload
- Support for ZIP, JSON, and XML files
- Real-time processing status
- Nicely formatted report display
- Option to download report as markdown
Note: The web interface requires the API_KEY environment variable to be set, just like the command line interface.
If you see an error about missing environment variables, check that:
- You have created a
.envfile in the project directory - The file contains the required variables
If you see an error processing a local file:
- Make sure the file exists and is readable
- Verify that it's a valid ZIP file containing JSON files or a valid JSON file
- Check that the JSON structure matches the expected Day One format
If you see an error like Credentials file not found: credentials.json, you need to:
- Make sure your credentials file exists at the path specified in the
GOOGLE_CREDENTIALS_FILEenvironment variable - If you don't have a credentials file, go to the Google Cloud Console and create one as described in the Setup section
If you encounter Google Drive authentication errors:
- Delete the
token.jsonfile if it exists - Run the script again to go through the authentication flow
- Make sure you grant the necessary permissions when prompted
If you see an error like No Day One backup files found in the folder:
- Check that your FOLDER_ID is correct
- Verify that the folder contains Day One backup ZIP files
- Run with
--debugflag to see more detailed information about the files in the folder
If you see an error like Day One CLI not found when using --add-to-journal:
- Make sure Day One app is installed on your Mac
- Install the CLI tool by running:
sudo bash /Applications/Day\ One.app/Contents/Resources/install_cli.sh - Verify the installation by running:
dayone2 -h
If you see an error like Journal not found in Day One:
- Make sure you've specified the correct journal name (case-sensitive)
- Open Day One app and verify the journal exists
- If you're unsure of the journal name, try using
--add-to-journalwithout specifying a journal name to use the default journal