@@ -15,6 +15,7 @@ A Laravel package for synchronizing Markdown documentation with [BookStack](http
1515## Features
1616
1717- ** Bidirectional Sync** : Push local Markdown files to BookStack or pull BookStack content to local files
18+ - ** Local SQLite Cache** : Reduces API calls by caching wiki structure locally with change detection
1819- ** Bookmark Conversion** : Automatically converts AI-generated bookmarks (Claude, Cursor, etc.) to BookStack's URL-encoded format
1920- ** Spanish Character Support** : Full support for UTF-8 characters (á, é, í, ó, ú, ñ, ç, ü, etc.)
2021- ** Artisan Commands** : Easy-to-use CLI commands for all operations
@@ -115,6 +116,41 @@ php artisan bookstack:search "configuration"
115116php artisan bookstack:search " instalación" --limit=50
116117```
117118
119+ #### Sync Wiki Structure to Local Cache
120+
121+ ``` bash
122+ # Sync all wiki structure to local SQLite database
123+ php artisan bookstack:sync
124+
125+ # Fresh sync (deletes existing database first)
126+ php artisan bookstack:sync --fresh
127+
128+ # Sync only specific entities
129+ php artisan bookstack:sync --no-shelves --no-chapters
130+ ```
131+
132+ #### Query Local Cache
133+
134+ ``` bash
135+ # Show database statistics
136+ php artisan bookstack:db stats
137+
138+ # List cached entities
139+ php artisan bookstack:db shelves
140+ php artisan bookstack:db books
141+ php artisan bookstack:db chapters --book=5
142+ php artisan bookstack:db pages --book=5 --chapter=10
143+
144+ # Include deleted items
145+ php artisan bookstack:db pages --deleted
146+
147+ # Show database path and size
148+ php artisan bookstack:db path
149+
150+ # Delete local database
151+ php artisan bookstack:db delete --force
152+ ```
153+
118154### Programmatic Usage
119155
120156``` php
@@ -216,6 +252,37 @@ Configure sync behavior in `config/bookstack-sync.php`:
216252],
217253```
218254
255+ ## Local Database Configuration
256+
257+ The package includes a local SQLite cache to reduce API calls and enable change detection:
258+
259+ ``` php
260+ 'database' => [
261+ // Enable/disable local database caching
262+ 'enabled' => env('BOOKSTACK_LOCAL_DB', true),
263+
264+ // Database path (relative to storage/ or absolute path)
265+ 'path' => env('BOOKSTACK_DB_PATH', 'bookstack-sync.sqlite'),
266+ ],
267+ ```
268+
269+ ### Environment Variables
270+
271+ ``` env
272+ # Enable local SQLite cache (default: true)
273+ BOOKSTACK_LOCAL_DB=true
274+
275+ # Custom database path (default: storage/bookstack-sync.sqlite)
276+ BOOKSTACK_DB_PATH=bookstack-sync.sqlite
277+ ```
278+
279+ ### How It Works
280+
281+ 1 . Run ` php artisan bookstack:sync ` to populate the local cache
282+ 2 . The cache stores all shelves, books, chapters, and pages with their metadata
283+ 3 . During push/pull operations, the package uses content hashes to skip unchanged files
284+ 4 . Deleted items in BookStack are marked with ` is_deleted ` flag for tracking
285+
219286## Spanish Character Encoding Reference
220287
221288| Character | URL Encoded |
0 commit comments