# ahappymosquito/love_book architecture

> Architecture diagram of the GitHub repository ahappymosquito/love_book, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahappymosquito/love_book
- Repository: https://github.com/ahappymosquito/love_book

## Overview

Love Book is a private shared journal for two people. The user-facing workflow is to enter the Next.js handoff, create or browse shared memories, plans, gifts, habits, and cycle records, then persist and retrieve that pair’s data through FastAPI. Backend routes own feature behavior; shared authentication, models, database, and media storage support those routes. The README documents the main capabilities, but most frontend-to-API wiring was not shown, so those links are omitted rather than inferred.

Main entry points: [`app/main.py`](https://github.com/ahappymosquito/love_book/blob/master/app/main.py) (FastAPI routing), [`app/api/routes/events.py`](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/events.py) (Timeline events), [`app/api/routes/todos.py`](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/todos.py) (Todo planning), [`app/api/routes/love_receipts.py`](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/love_receipts.py) (Gift receipts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webhome["Home and entry<br/>[page.tsx]"]
  node_timeline["Timeline memories<br/>[page.tsx]"]
  node_create["Create records<br/>[page.tsx]"]
  node_todo_ui["Shared Todo<br/>[page.tsx]"]
  node_habits_ui["Habits dashboard<br/>[page.tsx]"]
  node_cycle_ui["Cycle calendar"]
  node_gift_ui["Gift events<br/>[page.tsx]"]
  node_profile_ui["Profile and content<br/>[page.tsx]"]
  node_game_ui["Flower runner<br/>[xiaohua-runner.tsx]"]
end

subgraph group_api["API features"]
  node_auth["Authentication<br/>[auth.py]"]
  node_events["Timeline events<br/>[events.py]"]
  node_todos["Todo planning<br/>[todos.py]"]
  node_habits["Habit tracking<br/>[habits.py]"]
  node_cycles["Cycle records<br/>[cycles.py]"]
  node_receipts["Gift receipts<br/>[love_receipts.py]"]
  node_contents["Shared content<br/>[contents.py]"]
  node_meetings["Meeting ranges"]
  node_game["Game scores<br/>[game.py]"]
  node_admin["Administration<br/>[admin.py]"]
  node_login["Admin authentication<br/>[admin_auth.py]"]
end

subgraph group_shared["Shared backend"]
  node_runtime["FastAPI routing<br/>[main.py]"]
  node_dependencies["Auth and pair access<br/>[dependencies.py]"]
  node_models["Domain models<br/>[models.py]"]
  node_database[("Database<br/>[database.py]")]
  node_media["Media processing<br/>[media.py]"]
  node_storage["Media storage<br/>[storage.py]"]
  node_habit_logic["Habit reminders<br/>[habits.py]"]
end

subgraph group_integrations["External services"]
  node_ai["LLM configuration<br/>[ai_config.py]"]
  node_amap["AMap lookup<br/>[amap_mcp.py]"]
  node_smtp["Email delivery<br/>[emailer.py]"]
  node_mail_service["SMTP service"]
end

node_couple(("Two partners"))

node_couple -->|"opens"| node_webhome
node_webhome -->|"enters journal"| node_timeline
node_couple -->|"records activity"| node_create
node_runtime -->|"registers"| node_auth
node_runtime -->|"registers"| node_events
node_runtime -->|"registers"| node_todos
node_runtime -->|"registers"| node_habits
node_runtime -->|"registers"| node_cycles
node_runtime -->|"registers"| node_receipts
node_runtime -->|"registers"| node_contents
node_runtime -->|"registers"| node_meetings
node_runtime -->|"registers"| node_game
node_runtime -->|"registers"| node_admin
node_runtime -->|"registers"| node_login
node_runtime -->|"initializes"| node_database
node_runtime -->|"schedules reminders"| node_habit_logic
node_auth -->|"uses access checks"| node_dependencies
node_events -->|"uses pair access"| node_dependencies
node_todos -->|"uses pair access"| node_dependencies
node_habits -->|"uses pair access"| node_dependencies
node_cycles -->|"uses pair access"| node_dependencies
node_receipts -->|"uses pair access"| node_dependencies
node_meetings -->|"uses pair access"| node_dependencies
node_events -->|"reads and writes"| node_models
node_todos -->|"reads and writes"| node_models
node_receipts -->|"reads and writes"| node_models
node_habits -->|"reads and writes"| node_models
node_cycles -->|"reads and writes"| node_models
node_database -->|"maps schema"| node_models
node_events -->|"processes images"| node_media
node_events -->|"stores media"| node_storage
node_todos -->|"stores media"| node_storage
node_receipts -->|"processes images"| node_media
node_receipts -->|"stores media"| node_storage
node_habits -->|"uses habit logic"| node_habit_logic
node_todos -->|"uses classification"| node_ai
node_todos -->|"requests place data"| node_amap
node_auth -.->|"sends notifications"| node_smtp
node_events -->|"sends notifications"| node_smtp
node_habits -->|"sends reminders"| node_smtp
node_receipts -->|"sends notifications"| node_smtp
node_smtp -->|"delivers email"| node_mail_service

click node_webhome "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/page.tsx"
click node_timeline "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/timeline/page.tsx"
click node_create "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/create/page.tsx"
click node_todo_ui "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/todo/page.tsx"
click node_habits_ui "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/habits/page.tsx"
click node_cycle_ui "https://github.com/ahappymosquito/love_book/blob/master/web/src/components/cycle-calendar-dashboard.tsx"
click node_gift_ui "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/love-receipts/page.tsx"
click node_profile_ui "https://github.com/ahappymosquito/love_book/blob/master/web/src/app/me/page.tsx"
click node_game_ui "https://github.com/ahappymosquito/love_book/blob/master/web/src/components/xiaohua-runner.tsx"
click node_auth "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/auth.py"
click node_events "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/events.py"
click node_todos "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/todos.py"
click node_habits "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/habits.py"
click node_cycles "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/cycles.py"
click node_receipts "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/love_receipts.py"
click node_contents "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/contents.py"
click node_meetings "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/meeting_sessions.py"
click node_game "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/game.py"
click node_admin "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/admin.py"
click node_login "https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/admin_auth.py"
click node_runtime "https://github.com/ahappymosquito/love_book/blob/master/app/main.py"
click node_dependencies "https://github.com/ahappymosquito/love_book/blob/master/app/api/dependencies.py"
click node_models "https://github.com/ahappymosquito/love_book/blob/master/app/models.py"
click node_database "https://github.com/ahappymosquito/love_book/blob/master/app/core/database.py"
click node_media "https://github.com/ahappymosquito/love_book/blob/master/app/media.py"
click node_storage "https://github.com/ahappymosquito/love_book/blob/master/app/storage.py"
click node_habit_logic "https://github.com/ahappymosquito/love_book/blob/master/app/habits.py"
click node_ai "https://github.com/ahappymosquito/love_book/blob/master/app/ai_config.py"
click node_amap "https://github.com/ahappymosquito/love_book/blob/master/app/amap_mcp.py"
click node_smtp "https://github.com/ahappymosquito/love_book/blob/master/app/emailer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webhome,node_timeline,node_create,node_todo_ui,node_habits_ui,node_cycle_ui,node_gift_ui,node_profile_ui,node_game_ui toneBlue
class node_auth,node_events,node_todos,node_habits,node_cycles,node_receipts,node_contents,node_meetings,node_game,node_admin,node_login toneAmber
class node_runtime,node_dependencies,node_models,node_database,node_media,node_storage,node_habit_logic toneMint
class node_ai,node_amap,node_smtp,node_mail_service toneRose
class node_couple toneIndigo
```

## Components

### Web experience

- [Home and entry](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/page.tsx): `web/src/app/page.tsx`
- [Timeline memories](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/timeline/page.tsx): `web/src/app/timeline/page.tsx`
- [Create records](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/create/page.tsx): `web/src/app/create/page.tsx`
- [Shared Todo](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/todo/page.tsx): `web/src/app/todo/page.tsx`
- [Habits dashboard](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/habits/page.tsx): `web/src/app/habits/page.tsx`
- [Cycle calendar](https://github.com/ahappymosquito/love_book/blob/master/web/src/components/cycle-calendar-dashboard.tsx): `web/src/components/cycle-calendar-dashboard.tsx`
- [Gift events](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/love-receipts/page.tsx): `web/src/app/love-receipts/page.tsx`
- [Profile and content](https://github.com/ahappymosquito/love_book/blob/master/web/src/app/me/page.tsx): `web/src/app/me/page.tsx`
- [Flower runner](https://github.com/ahappymosquito/love_book/blob/master/web/src/components/xiaohua-runner.tsx): `web/src/components/xiaohua-runner.tsx`

### API features

- [Authentication](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/auth.py): `app/api/routes/auth.py`
- [Timeline events](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/events.py): `app/api/routes/events.py`
- [Todo planning](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/todos.py): `app/api/routes/todos.py`
- [Habit tracking](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/habits.py): `app/api/routes/habits.py`
- [Cycle records](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/cycles.py): `app/api/routes/cycles.py`
- [Gift receipts](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/love_receipts.py): `app/api/routes/love_receipts.py`
- [Shared content](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/contents.py): `app/api/routes/contents.py`
- [Meeting ranges](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/meeting_sessions.py): `app/api/routes/meeting_sessions.py`
- [Game scores](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/game.py): `app/api/routes/game.py`
- [Administration](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/admin.py): `app/api/routes/admin.py`
- [Admin authentication](https://github.com/ahappymosquito/love_book/blob/master/app/api/routes/admin_auth.py): `app/api/routes/admin_auth.py`

### Shared backend

- [FastAPI routing](https://github.com/ahappymosquito/love_book/blob/master/app/main.py): `app/main.py`
- [Auth and pair access](https://github.com/ahappymosquito/love_book/blob/master/app/api/dependencies.py): `app/api/dependencies.py`
- [Domain models](https://github.com/ahappymosquito/love_book/blob/master/app/models.py): `app/models.py`
- [Database](https://github.com/ahappymosquito/love_book/blob/master/app/core/database.py): `app/core/database.py`
- [Media processing](https://github.com/ahappymosquito/love_book/blob/master/app/media.py): `app/media.py`
- [Media storage](https://github.com/ahappymosquito/love_book/blob/master/app/storage.py): `app/storage.py`
- [Habit reminders](https://github.com/ahappymosquito/love_book/blob/master/app/habits.py): `app/habits.py`

### External services

- [LLM configuration](https://github.com/ahappymosquito/love_book/blob/master/app/ai_config.py): `app/ai_config.py`
- [AMap lookup](https://github.com/ahappymosquito/love_book/blob/master/app/amap_mcp.py): `app/amap_mcp.py`
- [Email delivery](https://github.com/ahappymosquito/love_book/blob/master/app/emailer.py): `app/emailer.py`
- **SMTP service**

### Other components

- **Two partners**

## Connections

- Two partners → Home and entry: opens
- Home and entry → Timeline memories: enters journal
- Two partners → Create records: records activity
- FastAPI routing → Authentication: registers (evidence: `app/main.py`)
- FastAPI routing → Timeline events: registers (evidence: `app/main.py`)
- FastAPI routing → Todo planning: registers (evidence: `app/main.py`)
- FastAPI routing → Habit tracking: registers (evidence: `app/main.py`)
- FastAPI routing → Cycle records: registers (evidence: `app/main.py`)
- FastAPI routing → Gift receipts: registers (evidence: `app/main.py`)
- FastAPI routing → Shared content: registers (evidence: `app/main.py`)
- FastAPI routing → Meeting ranges: registers (evidence: `app/main.py`)
- FastAPI routing → Game scores: registers (evidence: `app/main.py`)
- FastAPI routing → Administration: registers (evidence: `app/main.py`)
- FastAPI routing → Admin authentication: registers (evidence: `app/main.py`)
- FastAPI routing → Database: initializes (evidence: `app/main.py`)
- FastAPI routing → Habit reminders: schedules reminders (evidence: `app/main.py`)
- Authentication → Auth and pair access: uses access checks (evidence: `app/api/routes/auth.py`)
- Timeline events → Auth and pair access: uses pair access (evidence: `app/api/routes/events.py`)
- Todo planning → Auth and pair access: uses pair access (evidence: `app/api/routes/todos.py`)
- Habit tracking → Auth and pair access: uses pair access (evidence: `app/api/routes/habits.py`)
- Cycle records → Auth and pair access: uses pair access (evidence: `app/api/routes/cycles.py`)
- Gift receipts → Auth and pair access: uses pair access (evidence: `app/api/routes/love_receipts.py`)
- Meeting ranges → Auth and pair access: uses pair access (evidence: `app/api/routes/meeting_sessions.py`)
- Timeline events → Domain models: reads and writes (evidence: `app/api/routes/events.py`)
- Todo planning → Domain models: reads and writes (evidence: `app/api/routes/todos.py`)
- Gift receipts → Domain models: reads and writes (evidence: `app/api/routes/love_receipts.py`)
- Habit tracking → Domain models: reads and writes (evidence: `app/api/routes/habits.py`)
- Cycle records → Domain models: reads and writes (evidence: `app/api/routes/cycles.py`)
- Database → Domain models: maps schema (evidence: `app/core/database.py`)
- Timeline events → Media processing: processes images (evidence: `app/api/routes/events.py`)
- Timeline events → Media storage: stores media (evidence: `app/api/routes/events.py`)
- Todo planning → Media storage: stores media (evidence: `app/api/routes/todos.py`)
- Gift receipts → Media processing: processes images (evidence: `app/api/routes/love_receipts.py`)
- Gift receipts → Media storage: stores media (evidence: `app/api/routes/love_receipts.py`)
- Habit tracking → Habit reminders: uses habit logic (evidence: `app/api/routes/habits.py`)
- Todo planning → LLM configuration: uses classification (evidence: `app/api/routes/todos.py`)
- Todo planning → AMap lookup: requests place data (evidence: `app/api/routes/todos.py`)
- Authentication → Email delivery: sends notifications
- Timeline events → Email delivery: sends notifications (evidence: `app/api/routes/events.py`)
- Habit tracking → Email delivery: sends reminders
- Gift receipts → Email delivery: sends notifications (evidence: `app/api/routes/love_receipts.py`)
- Email delivery → SMTP service: delivers email (evidence: `app/emailer.py`)
