Skip to content

About

Sync unformatted data from Notion Database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SyncUnformattedData

A .NET 10 console tool that syncs spending/transfer entries from Notion Reflection pages into a local MongoDB database and reports monthly summaries.


Prerequisites

Requirement Version
.NET SDK 10.0+
Docker / Docker Desktop any recent

Quickstart

# 1. Clone the repo
git clone <repo-url>
cd SyncUnformattedData

# 2. Fill in credentials
cp .env.example .env
#    Edit .env — set NOTION_API_KEY and NOTION_DATABASE_ID

# 3. Start MongoDB
docker compose up -d

# 4. Sync Notion pages into MongoDB
dotnet run --project DataSync -- sync

Configuration

Copy .env.example to .env and set the following variables:

Variable Description
NOTION_API_KEY Notion Internal Integration Token
NOTION_DATABASE_ID ID of the Notion database containing Reflection pages
MONGO_CONNECTION_STRING MongoDB connection string (default: mongodb://localhost:27017)

The .env file is loaded automatically at startup. It is git-ignored and must never be committed.


Commands

sync

Fetches all Reflection <Month> <Year> pages from Notion, parses transaction lines, and upserts the results into MongoDB.

dotnet run --project DataSync -- sync

Add --dry-run to parse without writing to MongoDB (useful for verification):

dotnet run --project DataSync -- sync --dry-run

Example output:

Fetching Reflection pages from Notion…
Found 3 Reflection page(s).
  Processing 'Reflection October 2026'… 12 transaction(s) upserted.
  Processing 'Reflection November 2026'… 9 transaction(s) upserted.
  Processing 'Reflection June 2026 + Q2'… 7 transaction(s) upserted.

Sync complete. 28 transaction(s) upserted.

list

Lists raw parsed transactions stored in MongoDB for a given month and year.

dotnet run --project DataSync -- list --month 10 --year 2026
# or
dotnet run --project DataSync -- list --month october --year 2026

Defaults to the current month and year when options are omitted.

Example output:

Date         Destination          Source               Amount (IDR)
----------------------------------------------------------------------
2026-10-11   Blu                  -                       4,357,625
2026-10-11   BCA                  -                         500,000
2026-10-18   Blu                  -                       3,700,001
----------------------------------------------------------------------
Total rows:                                                        3

report

Prints aggregated totals per destination account for a given month and year.

dotnet run --project DataSync -- report --month 10 --year 2026
# or
dotnet run --project DataSync -- report --month october --year 2026

Defaults to the current month and year when options are omitted.

Example output:

Report — October 2026
==========================================
  BCA                          4,585,901
  Blu                          8,057,626
------------------------------------------
  Grand Total                 12,643,527

Project Structure

DataSync/
  Commands/         # CLI verb handlers (sync, list, report)
  Models/           # Transaction, ReflectionPageInfo, RawPageBlock
  Parser/           # AmountParser, DateHeadingParser, LineParser, ReflectionParser
  Repositories/     # TransactionRepository (MongoDB)
  Services/         # NotionService
  Program.cs        # Entry point — loads .env, builds RootCommand
DataSync.Tests/     # xUnit unit tests (47 tests)
docker-compose.yml  # MongoDB 7 service
.env.example        # Environment variable template

About

Sync unformatted data from Notion Database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages