···1+---
2+title: Building Noteleaf
3+sidebar_label: Building
4+sidebar_position: 1
5+description: Build configurations and development workflows.
6+---
7+8+# Building Noteleaf
9+10+Noteleaf uses [Task](https://taskfile.dev) for build automation, providing consistent workflows across development, testing, and releases.
11+12+## Prerequisites
13+14+- Go 1.21 or later
15+- [Task](https://taskfile.dev) (install via `brew install go-task/tap/go-task` on macOS)
16+- Git (for version information)
17+18+## Build Types
19+20+### Development Build
21+22+Quick build without version injection for local development:
23+24+```sh
25+task build
26+```
27+28+Output: `./tmp/noteleaf`
29+30+### Development Build with Version
31+32+Build with git commit hash and development tools enabled:
33+34+```sh
35+task build:dev
36+```
37+38+Version format: `git describe` output (e.g., `v0.1.0-15-g1234abc`)
39+Output: `./tmp/noteleaf`
40+41+### Release Candidate Build
42+43+Build with `-rc` tag, excludes development tools:
44+45+```sh
46+git tag v1.0.0-rc1
47+task build:rc
48+```
49+50+Requirements:
51+52+- Clean git tag with `-rc` suffix
53+- Tag format: `v1.0.0-rc1`, `v2.1.0-rc2`, etc.
54+55+### Production Build
56+57+Build for release with strict validation:
58+59+```sh
60+git tag v1.0.0
61+task build:prod
62+```
63+64+Requirements:
65+66+- Clean semver git tag (e.g., `v1.0.0`, `v2.1.3`)
67+- No uncommitted changes
68+- No prerelease suffix
69+70+## Build Tags
71+72+Production builds use the `prod` build tag to exclude development and seed commands:
73+74+```go
75+//go:build !prod
76+```
77+78+Commands excluded from production:
79+80+- `noteleaf dev` - Development utilities
81+- `noteleaf seed` - Test data generation
82+83+## Version Information
84+85+Build process injects version metadata via ldflags:
86+87+```go
88+// internal/version/version.go
89+var (
90+ Version = "dev" // Git tag or "dev"
91+ Commit = "none" // Git commit hash
92+ BuildDate = "unknown" // Build timestamp
93+)
94+```
95+96+View version information:
97+98+```sh
99+task version:show
100+noteleaf version
101+```
102+103+## Build Artifacts
104+105+All binaries are built to `./tmp/` directory:
106+107+```
108+tmp/
109+โโโ noteleaf # Binary for current platform
110+```
111+112+## Development Workflow
113+114+Full development cycle with linting and testing:
115+116+```sh
117+task dev
118+```
119+120+Runs:
121+122+1. Clean build artifacts
123+2. Run linters (vet, fmt)
124+3. Execute all tests
125+4. Build binary
126+127+## Manual Build
128+129+Build directly with Go (bypasses Task automation):
130+131+```sh
132+go build -o ./tmp/noteleaf ./cmd
133+```
134+135+With version injection:
136+137+```sh
138+go build -ldflags "-X github.com/stormlightlabs/noteleaf/internal/version.Version=v1.0.0" -o ./tmp/noteleaf ./cmd
139+```
140+141+## Cross-Platform Builds
142+143+Build for specific platforms:
144+145+```sh
146+# Linux
147+GOOS=linux GOARCH=amd64 go build -o ./tmp/noteleaf-linux ./cmd
148+149+# Windows
150+GOOS=windows GOARCH=amd64 go build -o ./tmp/noteleaf.exe ./cmd
151+152+# macOS (ARM)
153+GOOS=darwin GOARCH=arm64 go build -o ./tmp/noteleaf-darwin-arm64 ./cmd
154+```
155+156+## Clean Build
157+158+Remove all build artifacts:
159+160+```sh
161+task clean
162+```
163+164+Removes:
165+166+- `./tmp/` directory
167+- `coverage.out` and `coverage.html`
···1+---
2+title: Open Library API
3+sidebar_label: Open Library
4+sidebar_position: 1
5+description: Book metadata via Open Library API integration.
6+---
7+8+# Open Library API
9+10+Noteleaf integrates with [Open Library](https://openlibrary.org) to fetch book metadata, search for books, and enrich your reading list.
11+12+## Overview
13+14+Open Library provides:
15+16+- Book search by title, author, ISBN
17+- Work and edition metadata
18+- Author information
19+- Cover images
20+- Subject classifications
21+- Publication details
22+23+## Configuration
24+25+No API key required. Open Library is a free, open API service.
26+27+Optional user agent configuration is handled automatically:
28+29+```toml
30+# .noteleaf.conf.toml
31+# No configuration needed for Open Library
32+```
33+34+## Rate Limiting
35+36+Open Library enforces rate limits:
37+38+- 180 requests per minute
39+- 3 requests per second
40+- Burst limit: 5 requests
41+42+Noteleaf automatically manages rate limiting to stay within these boundaries.
43+44+## Book Search
45+46+Search for books from the command line:
47+48+```sh
49+noteleaf book search "Design Patterns"
50+noteleaf book search "Neal Stephenson"
51+```
52+53+Interactive selection shows:
54+55+- Title
56+- Author(s)
57+- First publication year
58+- Edition count
59+- Publisher information
60+61+## Book Metadata
62+63+When adding a book, Noteleaf fetches:
64+65+- Title
66+- Author names
67+- Publication year
68+- Edition information
69+- Subjects/genres
70+- Description (when available)
71+- Cover ID
72+73+## API Endpoints
74+75+### Search Endpoint
76+77+```
78+GET https://openlibrary.org/search.json
79+```
80+81+Parameters:
82+83+- `q`: Search query
84+- `offset`: Pagination offset
85+- `limit`: Results per page
86+- `fields`: Requested fields
87+88+### Work Endpoint
89+90+```
91+GET https://openlibrary.org/works/{work_key}.json
92+```
93+94+Returns detailed work information including authors, description, subjects, and covers.
95+96+## Data Mapping
97+98+Open Library data maps to Noteleaf book fields:
99+100+| Open Library | Noteleaf Field |
101+|--------------|----------------|
102+| title | Title |
103+| author_name | Author |
104+| first_publish_year | Notes (included) |
105+| edition_count | Notes (included) |
106+| publisher | Notes (included) |
107+| subject | Notes (included) |
108+| cover_i | Notes (cover ID) |
109+110+## Example API Response
111+112+Search result document:
113+114+```json
115+{
116+ "key": "/works/OL45804W",
117+ "title": "Design Patterns",
118+ "author_name": ["Erich Gamma", "Richard Helm"],
119+ "first_publish_year": 1994,
120+ "edition_count": 23,
121+ "isbn": ["0201633612", "9780201633610"],
122+ "publisher": ["Addison-Wesley"],
123+ "subject": ["Software design", "Object-oriented programming"],
124+ "cover_i": 8644882
125+}
126+```
127+128+## Limitations
129+130+### No Direct Page Count
131+132+Open Library doesn't consistently provide page counts in search results. Use the interactive editor to add page counts manually if needed.
133+134+### Author Keys vs Names
135+136+Work endpoints return author keys (`/authors/OL123A`) rather than full names. Noteleaf displays available author names from search results.
137+138+### Cover Images
139+140+Cover IDs are stored but not automatically downloaded. Future versions may support local cover image caching.
141+142+## Error Handling
143+144+### Network Issues
145+146+```sh
147+noteleaf book search "query"
148+# Error: failed to connect to Open Library
149+```
150+151+Check internet connection and Open Library status.
152+153+### Rate Limit Exceeded
154+155+Noteleaf automatically waits when approaching rate limits. If you see delays, this is normal behavior.
156+157+### No Results
158+159+```sh
160+noteleaf book search "very obscure title"
161+# No results found
162+```
163+164+Try:
165+166+- Different search terms
167+- Author names instead of titles
168+- ISBNs for specific editions
169+170+## API Service Architecture
171+172+Implementation in `internal/services/services.go`:
173+174+```go
175+type BookService struct {
176+ client *http.Client
177+ limiter *rate.Limiter
178+ baseURL string
179+}
180+```
181+182+Features:
183+184+- Automatic rate limiting
185+- Context-aware requests
186+- Proper error handling
187+- Timeout management (30s)
188+189+## Custom User Agent
190+191+Noteleaf identifies itself to Open Library:
192+193+```
194+User-Agent: Noteleaf/v{version} (contact: info@stormlightlabs.org)
195+```
196+197+This helps Open Library track API usage and contact developers if needed.
198+199+## Resources
200+201+- [Open Library API Documentation](https://openlibrary.org/dev/docs/api/books)
202+- [Open Library Search](https://openlibrary.org/dev/docs/api/search)
203+- [Open Library Covers](https://openlibrary.org/dev/docs/api/covers)
204+- [Rate Limiting Policy](https://openlibrary.org/developers/api)
···1+---
2+title: External Integrations
3+sidebar_label: Overview
4+sidebar_position: 1
5+description: Overview of external service integrations.
6+---
7+8+# External Integrations
9+10+Noteleaf integrates with external services to enrich your productivity workflow and extend functionality beyond local storage.
11+12+## Available Integrations
13+14+### Open Library API
15+16+Free book metadata service for building your reading list.
17+18+**Features:**
19+20+- Search books by title, author, ISBN
21+- Fetch metadata (author, year, subjects)
22+- Edition and publication information
23+- No API key required
24+25+**Use Cases:**
26+27+- Adding books to reading list
28+- Enriching book metadata
29+- Discovering related works
30+31+See [Open Library API](./openlibrary.md) for details.
32+33+### Leaflet.pub
34+35+Decentralized publishing platform built on AT Protocol.
36+37+**Features:**
38+39+- Publish notes as structured documents
40+- Pull existing documents into local notes
41+- Update published content
42+- Manage drafts and publications
43+44+**Use Cases:**
45+46+- Blog publishing from terminal
47+- Long-form content management
48+- Decentralized content ownership
49+50+See [Leaflet.pub section](../leaflet/intro.md) for details.
51+52+### AT Protocol (Bluesky)
53+54+Authentication and identity via AT Protocol network.
55+56+**Features:**
57+58+- Decentralized identity (DID)
59+- Session management
60+- Token refresh
61+- Secure authentication
62+63+**Use Cases:**
64+65+- Leaflet.pub authentication
66+- Portable identity across services
67+- Content verification
68+69+See [Authentication](../leaflet/authentication.md) for details.
70+71+## Integration Architecture
72+73+### Service Layer
74+75+External integrations live in `internal/services/`:
76+77+- `services.go` - Open Library API client
78+- `atproto.go` - AT Protocol authentication
79+- `http.go` - HTTP utilities and rate limiting
80+81+### Rate Limiting
82+83+All external services use rate limiting to respect API quotas:
84+85+- Open Library: 3 requests/second
86+- AT Protocol: Per PDS configuration
87+88+Rate limiters are built-in and automatic.
89+90+### Error Handling
91+92+Services implement consistent error handling:
93+94+- Network errors
95+- Rate limit exceeded
96+- Authentication failures
97+- Invalid responses
98+99+Errors propagate to user with actionable messages.
100+101+## Configuration
102+103+Integration configuration in `.noteleaf.conf.toml`:
104+105+```toml
106+# Open Library (no configuration needed)
107+# book_api_key = "" # Reserved for future use
108+109+# AT Protocol / Leaflet.pub
110+atproto_handle = "username.bsky.social"
111+atproto_did = "did:plc:..."
112+atproto_pds_url = "https://bsky.social"
113+atproto_access_jwt = "..."
114+atproto_refresh_jwt = "..."
115+```
116+117+See [Configuration](../Configuration.md) for all options.
118+119+## Offline Support
120+121+Noteleaf works fully offline for local data. Integrations are optional enhancements:
122+123+- Books can be added manually without Open Library
124+- Notes exist locally without Leaflet.pub
125+- Tasks and media work without any external service
126+127+External services enhance but don't require connectivity.
128+129+## Privacy and Data
130+131+### Data Sent
132+133+**Open Library:**
134+135+- Search queries
136+- Work/edition IDs
137+138+**AT Protocol:**
139+140+- Handle/DID
141+- Published note content
142+- Authentication credentials
143+144+### Data Stored Locally
145+146+- API responses (cached)
147+- Session tokens
148+- Publication metadata
149+150+### No Tracking
151+152+Noteleaf does not:
153+154+- Track usage
155+- Send analytics
156+- Share data with third parties
157+- Require accounts (except for publishing)
158+159+## Resources
160+161+- [Open Library API Documentation](https://openlibrary.org/developers/api)
162+- [AT Protocol Docs](https://atproto.com)
163+- [Leaflet.pub](https://leaflet.pub)
164+- [Bluesky](https://bsky.app)
-26
website/docs/leaflet/future.md
···1----
2-title: Leaflet Future Features
3-sidebar_label: Future
4-description: Upcoming enhancements planned for the leaflet integration.
5-sidebar_position: 10
6----
7-8-# Leaflet Future Features
9-10-Planned improvements to leaflet.pub integration:
11-12-**Multiple Publications**: Create and manage separate publications for different topics
13-14-**Image Upload**: Automatically upload images to blob storage and embed in documents
15-16-**Status Management**: Publish drafts and unpublish documents from CLI
17-18-**Metadata Editing**: Update document titles, summaries, and tags
19-20-**Backlink Support**: Parse and resolve cross-references between documents
21-22-**Collaborative Editing**: Pull and merge changes from multiple devices
23-24-**Offline Mode**: Queue posts and patches for later upload
25-26-For the latest roadmap, check the [GitHub repository](https://github.com/stormlightlabs/noteleaf).
···00000000000000000000000000
+1-1
website/docs/notes/best-practices.md
···1112**Tag consistently**: Establish a tagging taxonomy early and stick to it. Review tags periodically with `noteleaf note tags`.
1314-**Link liberally**: Reference related notes, tasks, and articles. Future features will leverage these connections.
1516**Short, focused notes**: Better to have many small notes than few giant ones. Easier to link and reuse.
17
···1112**Tag consistently**: Establish a tagging taxonomy early and stick to it. Review tags periodically with `noteleaf note tags`.
1314+**Link liberally**: Reference related notes, tasks, and articles using markdown links and references.
1516**Short, focused notes**: Better to have many small notes than few giant ones. Easier to link and reuse.
17