buylog 0.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- buylog-0.1.8/PKG-INFO +403 -0
- buylog-0.1.8/README.md +369 -0
- buylog-0.1.8/pyproject.toml +89 -0
- buylog-0.1.8/src/buylog/__init__.py +4 -0
- buylog-0.1.8/src/buylog/__main__.py +4 -0
- buylog-0.1.8/src/buylog/audit.py +320 -0
- buylog-0.1.8/src/buylog/cli.py +2152 -0
- buylog-0.1.8/src/buylog/config.py +127 -0
- buylog-0.1.8/src/buylog/models.py +368 -0
- buylog-0.1.8/src/buylog/services.py +3823 -0
- buylog-0.1.8/src/buylog/tui.py +1852 -0
buylog-0.1.8/PKG-INFO
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: buylog
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Summary: A purchasing support tool with CLI and TUI interfaces for vendor quote management.
|
|
5
|
+
Keywords: purchasing,quotes,vendor-management,price-tracking,cli,tui,textual
|
|
6
|
+
Author: Shakeeb Alireza
|
|
7
|
+
Author-email: Shakeeb Alireza <shakfu@users.noreply.github.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Office/Business
|
|
17
|
+
Classifier: Topic :: Utilities
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Dist: sqlalchemy>=2.0.40
|
|
20
|
+
Requires-Dist: tabulate>=0.9.0
|
|
21
|
+
Requires-Dist: textual>=7.3.0
|
|
22
|
+
Requires-Dist: textual-dev>=1.8.0
|
|
23
|
+
Requires-Dist: pyperclip>=1.9.0
|
|
24
|
+
Requires-Dist: requests>=2.32.0
|
|
25
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
26
|
+
Maintainer: Shakeeb Alireza
|
|
27
|
+
Maintainer-email: Shakeeb Alireza <shakfu@users.noreply.github.com>
|
|
28
|
+
Requires-Python: >=3.13
|
|
29
|
+
Project-URL: Changelog, https://github.com/shakfu/buylog/blob/main/CHANGELOG.md
|
|
30
|
+
Project-URL: Homepage, https://github.com/shakfu/buylog
|
|
31
|
+
Project-URL: Issues, https://github.com/shakfu/buylog/issues
|
|
32
|
+
Project-URL: Repository, https://github.com/shakfu/buylog
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# buylog
|
|
36
|
+
|
|
37
|
+
A Python tool to help you keep track of what you buy and want to buy.
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Command Line Interface (CLI)** - Full CRUD operations for managing brands, products, vendors, and quotes
|
|
42
|
+
- **Text User Interface (TUI)** - Interactive terminal UI built with Textual
|
|
43
|
+
- **Data Persistence** - SQLAlchemy ORM with SQLite support
|
|
44
|
+
- **Multi-currency Support** - Forex rate tracking with automatic currency conversion
|
|
45
|
+
- **Quote Analysis** - Best price highlighting, price history tracking, and price alerts
|
|
46
|
+
- **Service Layer** - Business logic separation with validation and error handling
|
|
47
|
+
- **Audit Logging** - Track entity creation, updates, and deletions
|
|
48
|
+
- **Testing** - pytest-based test suite with factory pattern
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
pip install buylog
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To build
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Clone the repository
|
|
60
|
+
git clone https://github.com/shakfu/buylog
|
|
61
|
+
cd buylog
|
|
62
|
+
|
|
63
|
+
# Install dependencies
|
|
64
|
+
uv sync
|
|
65
|
+
|
|
66
|
+
# Or install with development dependencies
|
|
67
|
+
uv sync --group dev
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
### Command Line Interface
|
|
73
|
+
|
|
74
|
+
The CLI supports comprehensive CRUD operations:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
# Add entities
|
|
78
|
+
buylog add --brand apple
|
|
79
|
+
buylog add --brand apple --product iphone-14
|
|
80
|
+
buylog add --vendor amazon.com --currency USD
|
|
81
|
+
buylog add --vendor amazon.com --product iphone-14 --quote 600
|
|
82
|
+
|
|
83
|
+
# Add forex rates
|
|
84
|
+
buylog add-fx --code EUR --usd-per-unit 1.085
|
|
85
|
+
buylog add-fx --code GBP --usd-per-unit 1.27 --date 2025-01-15
|
|
86
|
+
|
|
87
|
+
# Add quotes with shipping and tax
|
|
88
|
+
buylog add --vendor amazon.com --product iphone-14 --quote 600 --shipping 10.00 --tax-rate 8.5
|
|
89
|
+
|
|
90
|
+
# List entities
|
|
91
|
+
buylog list brands
|
|
92
|
+
buylog list products
|
|
93
|
+
buylog list vendors
|
|
94
|
+
buylog list quotes
|
|
95
|
+
buylog list brands --filter apple
|
|
96
|
+
|
|
97
|
+
# Search across entities
|
|
98
|
+
buylog search iphone
|
|
99
|
+
|
|
100
|
+
# Update entities
|
|
101
|
+
buylog update brand apple --new-name Apple
|
|
102
|
+
buylog update product iphone-14 --new-name "iPhone 14"
|
|
103
|
+
|
|
104
|
+
# Delete entities
|
|
105
|
+
buylog delete brand --name apple
|
|
106
|
+
buylog delete product --name iphone-14
|
|
107
|
+
buylog delete vendor --name amazon.com
|
|
108
|
+
buylog delete quote --id 1
|
|
109
|
+
|
|
110
|
+
# Seed database with sample data
|
|
111
|
+
buylog seed
|
|
112
|
+
|
|
113
|
+
# Price alerts
|
|
114
|
+
buylog alert add "iPhone 15 Pro" 900 # Create alert when price drops to $900
|
|
115
|
+
buylog alert list # List all alerts
|
|
116
|
+
buylog alert list --triggered # List triggered alerts only
|
|
117
|
+
buylog alert deactivate 1 # Deactivate alert by ID
|
|
118
|
+
|
|
119
|
+
# Price history
|
|
120
|
+
buylog history --product "iPhone 15 Pro" # View price history for a product
|
|
121
|
+
buylog history --quote-id 1 # View price history for a specific quote
|
|
122
|
+
|
|
123
|
+
# Price comparison
|
|
124
|
+
buylog compare --product "iPhone 15 Pro" # Compare prices for a specific product
|
|
125
|
+
buylog compare --search "iPhone" # Compare all products matching search term
|
|
126
|
+
buylog compare --category "Mobile Phones" # Compare all products in a category
|
|
127
|
+
buylog compare --brand "Apple" # Compare all products from a brand
|
|
128
|
+
|
|
129
|
+
# Product categories
|
|
130
|
+
buylog category set "iPhone 15 Pro" "Mobile Phones" # Set product category
|
|
131
|
+
buylog category list # List all categories
|
|
132
|
+
|
|
133
|
+
# Purchase lists
|
|
134
|
+
buylog purchase-list create "My List" --description "Weekend shopping"
|
|
135
|
+
buylog purchase-list add "My List" 123 # Add quote to list
|
|
136
|
+
buylog purchase-list remove "My List" 123 # Remove quote from list
|
|
137
|
+
buylog purchase-list show "My List" # Show list contents
|
|
138
|
+
buylog purchase-list all # List all purchase lists
|
|
139
|
+
buylog purchase-list delete "My List" # Delete a list
|
|
140
|
+
|
|
141
|
+
# Quote status tracking
|
|
142
|
+
buylog status set 123 considering # Set quote status
|
|
143
|
+
buylog status set 123 ordered # Mark as ordered
|
|
144
|
+
buylog status set 123 received # Mark as received
|
|
145
|
+
buylog status list ordered # List quotes by status
|
|
146
|
+
|
|
147
|
+
# Notes
|
|
148
|
+
buylog note add product 1 "Great product!" # Add note to product
|
|
149
|
+
buylog note add vendor 1 "Fast shipping" # Add note to vendor
|
|
150
|
+
buylog note list product 1 # List notes for product
|
|
151
|
+
buylog note delete 1 # Delete note by ID
|
|
152
|
+
|
|
153
|
+
# Tags
|
|
154
|
+
buylog tag add "sale" product 1 # Tag a product
|
|
155
|
+
buylog tag add "priority" quote 123 # Tag a quote
|
|
156
|
+
buylog tag remove "sale" product 1 # Remove tag
|
|
157
|
+
buylog tag list # List all tags
|
|
158
|
+
buylog tag list --entity-type product --entity-id 1 # List tags for entity
|
|
159
|
+
buylog tag search "sale" # Find entities by tag
|
|
160
|
+
|
|
161
|
+
# Watchlist
|
|
162
|
+
buylog watchlist add "iPhone 15" --target-price 800 # Add to watchlist
|
|
163
|
+
buylog watchlist list # List active watchlist
|
|
164
|
+
buylog watchlist list --all # Include inactive items
|
|
165
|
+
buylog watchlist update 1 --target-price 750 # Update target price
|
|
166
|
+
buylog watchlist remove 1 # Remove from watchlist
|
|
167
|
+
|
|
168
|
+
# Import data
|
|
169
|
+
buylog import quotes data.csv # Import quotes from CSV
|
|
170
|
+
buylog import quotes data.json # Import quotes from JSON
|
|
171
|
+
buylog import quotes data.csv --no-create # Don't create missing entities
|
|
172
|
+
|
|
173
|
+
# Export data
|
|
174
|
+
buylog export quotes --format csv --file quotes.csv # Export to CSV
|
|
175
|
+
buylog export quotes --format markdown --file report.md # Export to Markdown
|
|
176
|
+
buylog export quotes --filter "iPhone" # Export filtered quotes
|
|
177
|
+
buylog export products --file products.csv # Export products
|
|
178
|
+
buylog export vendors --file vendors.csv # Export vendors
|
|
179
|
+
|
|
180
|
+
# Backup and restore
|
|
181
|
+
buylog backup # Create timestamped backup
|
|
182
|
+
buylog backup --output my-backup.db # Custom backup path
|
|
183
|
+
buylog restore my-backup.db # Restore from backup
|
|
184
|
+
buylog restore my-backup.db --no-backup # Restore without backing up current
|
|
185
|
+
buylog backups # List available backups
|
|
186
|
+
|
|
187
|
+
# Find and merge duplicates
|
|
188
|
+
buylog duplicates vendors # Find similar vendors
|
|
189
|
+
buylog duplicates vendors --threshold 0.7 # Custom similarity threshold
|
|
190
|
+
buylog duplicates products # Find similar products
|
|
191
|
+
buylog duplicates merge-vendors 1 2 3 # Merge vendors 2,3 into vendor 1
|
|
192
|
+
buylog duplicates merge-products 1 2 3 # Merge products 2,3 into product 1
|
|
193
|
+
|
|
194
|
+
# Clipboard support
|
|
195
|
+
buylog clipboard quote 123 # Copy quote to clipboard
|
|
196
|
+
buylog clipboard product "iPhone 15 Pro" # Copy product to clipboard
|
|
197
|
+
buylog clipboard vendor "Amazon US" # Copy vendor to clipboard
|
|
198
|
+
|
|
199
|
+
# Vendor URL management
|
|
200
|
+
buylog vendor-url set "Amazon US" "https://amazon.com" # Set vendor URL
|
|
201
|
+
buylog vendor-url open "Amazon US" # Open vendor URL in browser
|
|
202
|
+
buylog vendor-url clear "Amazon US" # Clear vendor URL
|
|
203
|
+
|
|
204
|
+
# Receipt attachments
|
|
205
|
+
buylog receipt attach 123 receipt.pdf # Attach receipt to quote
|
|
206
|
+
buylog receipt open 123 # Open attached receipt
|
|
207
|
+
buylog receipt detach 123 # Remove receipt from quote
|
|
208
|
+
buylog receipt list # List quotes with receipts
|
|
209
|
+
|
|
210
|
+
# Web scraping
|
|
211
|
+
buylog scrape url "https://example.com/product" # Scrape price from URL
|
|
212
|
+
buylog scrape quote "https://example.com/product" --vendor "Amazon US" --product "iPhone 15" # Create quote from URL
|
|
213
|
+
|
|
214
|
+
# HTML reports
|
|
215
|
+
buylog report price-comparison # Compare prices across vendors
|
|
216
|
+
buylog report price-comparison --filter "iPhone" # Filter by product name
|
|
217
|
+
buylog report price-comparison --output report.html # Save to file
|
|
218
|
+
buylog report purchase-summary --output summary.html # Summary by status
|
|
219
|
+
buylog report vendor-analysis --output vendors.html # Vendor statistics
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Text User Interface (TUI)
|
|
223
|
+
|
|
224
|
+
Launch the interactive TUI:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
buylog tui
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
The TUI provides:
|
|
231
|
+
|
|
232
|
+
- Tabbed interface for Brands, Products, Vendors, Quotes, Forex rates, Alerts, Lists, and Watchlist
|
|
233
|
+
- DataTables with row selection
|
|
234
|
+
- Modal forms for adding entities
|
|
235
|
+
- Search/filter functionality
|
|
236
|
+
- **Quote Analysis Features**:
|
|
237
|
+
- Best prices highlighted in green
|
|
238
|
+
- Total cost calculation (with discount, shipping, tax)
|
|
239
|
+
- Price trend indicators (^ up, v down, - stable, * new)
|
|
240
|
+
- Sparkline mini-graphs showing price history
|
|
241
|
+
- Triggered alerts highlighted in yellow
|
|
242
|
+
- **Status column** with color coding (considering=cyan, ordered=yellow, received=green)
|
|
243
|
+
- **Workflow Features**:
|
|
244
|
+
- **Lists tab** - View and manage purchase lists
|
|
245
|
+
- **Watchlist tab** - Monitor products with target prices
|
|
246
|
+
- Set quote status with `t` key
|
|
247
|
+
- Add to watchlist with `w` key
|
|
248
|
+
- **Integration Features**:
|
|
249
|
+
- **URL column** in Vendors tab showing link indicators
|
|
250
|
+
- Copy to clipboard with `y` key (quotes, products, vendors)
|
|
251
|
+
- Open vendor URL with `o` key (on Vendors tab)
|
|
252
|
+
- **Quick Filters** for quotes by vendor, brand, or price range
|
|
253
|
+
- **Inline Editing** - Edit entities directly with `e` key
|
|
254
|
+
- **Column Sorting** - Click headers or press number keys to sort
|
|
255
|
+
- **Price Comparison** - Compare prices with `c` key (select type: Product/Search/Category/Brand)
|
|
256
|
+
- Keyboard shortcuts:
|
|
257
|
+
- `q` - Quit
|
|
258
|
+
- `a` - Add new entity
|
|
259
|
+
- `c` - Compare prices
|
|
260
|
+
- `d` - Delete selected entity
|
|
261
|
+
- `e` - Edit selected entity
|
|
262
|
+
- `f` - Filter quotes
|
|
263
|
+
- `o` - Open vendor URL (vendors tab)
|
|
264
|
+
- `r` - Refresh data
|
|
265
|
+
- `s` or `/` - Focus search
|
|
266
|
+
- `t` - Set quote status
|
|
267
|
+
- `w` - Add to watchlist
|
|
268
|
+
- `y` - Copy to clipboard
|
|
269
|
+
- `Ctrl+1-8` - Switch tabs directly
|
|
270
|
+
- `h/l` - Previous/next tab (vim-style)
|
|
271
|
+
- `j/k` - Move cursor down/up (vim-style)
|
|
272
|
+
- `1-7` - Sort by column number
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
### Running Tests
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Run all tests
|
|
280
|
+
make test
|
|
281
|
+
# or
|
|
282
|
+
uv run pytest
|
|
283
|
+
|
|
284
|
+
# Run with coverage report
|
|
285
|
+
make coverage
|
|
286
|
+
# or
|
|
287
|
+
uv run pytest --cov-report=html:cov_html --cov-report=term-missing --cov=buylog
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Generate ER Diagram
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
make diagram
|
|
294
|
+
# or
|
|
295
|
+
uv run python src/buylog/models.py
|
|
296
|
+
|
|
297
|
+
# Output: doc/er_model.svg
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Clean Build Artifacts
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
make clean
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Architecture
|
|
307
|
+
|
|
308
|
+
### Project Structure
|
|
309
|
+
|
|
310
|
+
```text
|
|
311
|
+
buylog/
|
|
312
|
+
├── src/buylog/ # Main package
|
|
313
|
+
│ ├── models.py # SQLAlchemy ORM models
|
|
314
|
+
│ ├── cli.py # CLI interface
|
|
315
|
+
│ ├── tui.py # Textual TUI interface
|
|
316
|
+
│ ├── services.py # Business logic layer
|
|
317
|
+
│ ├── config.py # Configuration management
|
|
318
|
+
│ ├── audit.py # Audit logging
|
|
319
|
+
│ └── cache.py # Caching utilities
|
|
320
|
+
├── tests/ # Test suite
|
|
321
|
+
│ ├── conftest.py # pytest fixtures
|
|
322
|
+
│ ├── factories.py # Factory Boy test data
|
|
323
|
+
│ ├── test_models.py # Model tests
|
|
324
|
+
│ ├── test_services.py # Service layer tests
|
|
325
|
+
│ └── test_quote_analysis.py # Quote analysis feature tests
|
|
326
|
+
├── doc/ # Documentation
|
|
327
|
+
│ └── er_model.svg # Auto-generated ER diagram
|
|
328
|
+
└── pyproject.toml # Project dependencies
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Data Model
|
|
332
|
+
|
|
333
|
+
The core domain models:
|
|
334
|
+
|
|
335
|
+
- **Vendor** - Selling entities with currency, discount codes, and brand relationships
|
|
336
|
+
- **Brand** - Manufacturing entities linked to products and vendors
|
|
337
|
+
- **Product** - Items with brand associations that can be quoted by vendors
|
|
338
|
+
- **Quote** - Price quotes from vendors with shipping, tax, status, and total cost calculation
|
|
339
|
+
- **QuoteHistory** - Price change tracking for quotes (create/update events)
|
|
340
|
+
- **PriceAlert** - Price threshold alerts for products
|
|
341
|
+
- **Forex** - Currency exchange rates for multi-currency support
|
|
342
|
+
- **PurchaseList** - Named shopping lists grouping quotes
|
|
343
|
+
- **Note** - Freeform notes attachable to any entity (polymorphic)
|
|
344
|
+
- **Tag** - Categorization tags with optional color
|
|
345
|
+
- **EntityTag** - Junction table for tagging any entity
|
|
346
|
+
- **Watchlist** - Product monitoring with target prices
|
|
347
|
+
|
|
348
|
+
Key relationships:
|
|
349
|
+
|
|
350
|
+
- Many-to-many between Vendors and Brands (via `vendor_brand` junction table)
|
|
351
|
+
- One-to-many from Brand to Products
|
|
352
|
+
- One-to-many from Vendor and Product to Quotes
|
|
353
|
+
- One-to-many from Quote to QuoteHistory
|
|
354
|
+
- One-to-many from Product to PriceAlert
|
|
355
|
+
- Many-to-many between PurchaseList and Quotes (via `purchase_list_quote` junction table)
|
|
356
|
+
- One-to-many from Product to Watchlist
|
|
357
|
+
|
|
358
|
+
See the auto-generated ER diagram: `doc/er_model.svg`
|
|
359
|
+
|
|
360
|
+
### Service Layer
|
|
361
|
+
|
|
362
|
+
Business logic is separated into service classes:
|
|
363
|
+
|
|
364
|
+
- `BrandService` - Brand CRUD with validation
|
|
365
|
+
- `ProductService` - Product management with eager loading
|
|
366
|
+
- `VendorService` - Vendor operations
|
|
367
|
+
- `QuoteService` - Quote management with currency conversion, best price detection, price updates, and status tracking
|
|
368
|
+
- `QuoteHistoryService` - Price history tracking and trend computation
|
|
369
|
+
- `PriceAlertService` - Price alert creation, triggering, and management
|
|
370
|
+
- `ComparisonService` - Price comparison by product, search, category, or brand
|
|
371
|
+
- `PurchaseListService` - Purchase list CRUD, add/remove quotes
|
|
372
|
+
- `NoteService` - Note CRUD for any entity type
|
|
373
|
+
- `TagService` - Tag management and entity tagging
|
|
374
|
+
- `WatchlistService` - Watchlist management with target prices
|
|
375
|
+
- `ReportService` - HTML report generation (price comparison, purchase summary, vendor analysis)
|
|
376
|
+
- `AuditService` - Entity change tracking
|
|
377
|
+
|
|
378
|
+
## Technologies
|
|
379
|
+
|
|
380
|
+
- **Python 3.13+** - Core language
|
|
381
|
+
- **SQLAlchemy 2.0+** - ORM and database abstraction
|
|
382
|
+
- **Textual** - Modern terminal UI framework
|
|
383
|
+
- **pytest** - Testing framework
|
|
384
|
+
- **Factory Boy** - Test data generation
|
|
385
|
+
- **uv** - Fast Python package manager
|
|
386
|
+
- **eralchemy** - ER diagram generation
|
|
387
|
+
- **tabulate** - CLI table formatting
|
|
388
|
+
|
|
389
|
+
## Configuration
|
|
390
|
+
|
|
391
|
+
The application uses a configuration system via `config.py`:
|
|
392
|
+
|
|
393
|
+
- Database path: `~/.buylog/buylog.db` (configurable via `BUYER_DB_PATH`)
|
|
394
|
+
- Log level: `INFO` by default (configurable via `BUYER_LOG_LEVEL`)
|
|
395
|
+
- Logging: Configured for both file and console output
|
|
396
|
+
|
|
397
|
+
## License
|
|
398
|
+
|
|
399
|
+
MIT
|
|
400
|
+
|
|
401
|
+
## Contributing
|
|
402
|
+
|
|
403
|
+
Feedback, bug reports and code contributions are welcome!
|