Part 1 of 5

The Project Structure

What files we need and why.

Before we ask AI to build anything, let's understand what we're creating. The “Brain” is surprisingly simple—just a few files working together.

The Files We Need

second-brain/
├── app.py
# Main Slack bot logic
├── brain.py
# AI reasoning & routing
├── notion_service.py
# Notion API wrapper
├── .env
# Your secrets (never commit!)
├── Dockerfile
# Container definition
├── docker-compose.yml
# Easy startup config
└── requirements.txt
# Python dependencies

What Each File Does

app.py — The Listener

Connects to Slack via Socket Mode, receives messages, and calls the brain to process them.

brain.py — The Thinker

Sends your message to the AI, parses the response, and decides what action to take.

notion_service.py — The Memory

Handles all Notion API calls: creating pages, querying databases, updating entries.

Why Separate Files?

When Notion changes their API (they will), you only fix notion_service.py. When you want smarter routing, you only touch brain.py. Clean separation makes debugging 10x easier.