Commit Graph

38 Commits

Author SHA1 Message Date
744df6b3b8 feat: add SaaS endpoints — auth, inventory, availability, admin users
New endpoints:
- Auth: register, login, refresh, me
- Admin: list users, activate/deactivate
- Inventory: mapping CRUD, file upload (CSV/Excel), history, items list
- Parts: availability across warehouses, aftermarket alternatives
- Routes: login.html, bodega pages
- Fix: admin stats use pg_class estimates for large tables

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:24:45 +00:00
09d3304b21 feat: add JWT auth module — login, tokens, role-based middleware
Implements hash_password, check_password, create_access_token,
create_refresh_token, decode_token, and require_auth() decorator
for role-based endpoint protection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:24:38 +00:00
c5e5f6ef7e feat: add SaaS schema migration — sessions, inventory, mappings tables
Creates sessions, warehouse_inventory, inventory_uploads,
inventory_column_mappings tables. Extends users with business_name,
is_active, last_login. Updates roles to ADMIN/OWNER/TALLER/BODEGA.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:24:33 +00:00
6ef39d212c feat: add JWT auth and inventory dependencies
Add PyJWT, bcrypt, openpyxl to requirements.
Add JWT_SECRET, JWT_ACCESS_EXPIRES, JWT_REFRESH_EXPIRES to config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:24:26 +00:00
f89d591fa9 chore: update .gitignore — exclude data/, WAL files, and diagram images
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:24:20 +00:00
2c6b6e0160 fix(console): fix PostgreSQL connection + add Metabase Actions guide
- Fix console/main.py: import DB_URL instead of missing DB_PATH
- Add sqlalchemy text() import for connection test
- Replace file-exists check with actual PostgreSQL connection test
- Mask password in startup banner
- Add docs/METABASE_ACTIONS.md: complete guide for data entry via
  Metabase Actions (models, forms, dashboard layout, workflows)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 05:52:12 +00:00
7b2a904498 feat: migrate to PostgreSQL + SQLAlchemy ORM, rebrand to Nexus Autoparts
- Migrate from SQLite to PostgreSQL with normalized schema
- Add 11 lookup tables (fuel_type, body_type, drivetrain, transmission,
  materials, position_part, manufacture_type, quality_tier, countries,
  reference_type, shapes)
- Rewrite dashboard/server.py (76 routes) using SQLAlchemy text() queries
- Rewrite console/db.py (27 methods) using SQLAlchemy ORM
- Add models.py with 27 SQLAlchemy model definitions
- Add config.py for centralized DB_URL configuration
- Add migrate_to_postgres.py migration script
- Add docs/METABASE_GUIDE.md with complete data entry guide
- Rebrand from "AUTOPARTS DB" to "NEXUS AUTOPARTS"
- Fill vehicle data gaps via NHTSA API + heuristics:
  engines (cylinders, power, torque), brands (country, founded_year),
  models (body_type, production years), MYE (drivetrain, transmission, trim)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 05:24:47 +00:00
7ecf1295a5 fix: performance improvements, shared UI, and cross-reference data quality
Backend (server.py):
- Fix N+1 query in /api/diagrams/<id>/parts with batch cross-ref query
- Add LIMIT safety nets to 15 endpoints (50-5000 per data type)
- Add pagination to /api/vehicles, /api/model-year-engine, /api/vehicles/<id>/parts, /api/admin/export
- Optimize search_vehicles() EXISTS subquery to JOIN
- Restrict static route to /static/* subdir (security fix)
- Add detailed=true support to /api/brands and /api/models

Frontend:
- Extract shared CSS into shared.css (variables, reset, buttons, forms, scrollbar)
- Create shared nav.js component (logo + navigation links, auto-highlights)
- Update all 4 HTML pages to use shared CSS and nav
- Update JS to handle paginated API responses

Data quality:
- Fix cross-reference source field: map 72K records from catalog names to actual brands
- Fix aftermarket_parts manufacturer_id: correct 8K records with wrong brand attribution
- Delete 98MB backup file, orphan records, and garbage cross-references
- Add import scripts for DAR, FRAM, WIX, MOOG, Cartek catalogs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 03:09:22 +00:00
3ea2de61e2 refactor(console): remove modern renderer, keep VT220 only
Remove the Rich-based textual renderer and all --mode modern references.
The console now runs exclusively in VT220 curses mode (green on black).
No external dependencies required.

Removed: console/renderers/textual_renderer.py, --mode flag, DEFAULT_MODE
Updated: main.py, config.py, README.md, console/README.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:37:35 +00:00
7866194e65 ui(console): center menu in a bordered box with better spacing
Both renderers now draw the menu inside a centered box with:
- Rounded corners (modern) / box-drawing (VT220)
- Title centered inside the box top
- Section separators as horizontal lines within the box
- Selected item highlighted across the full box width
- Vertical and horizontal centering on screen

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:31:54 +00:00
a3aa2a7608 fix(console): arrow keys and layout in modern renderer
Two bugs fixed:

1. Arrow keys detected as ESC: sys.stdin.read(1) uses Python's internal
   buffer, so after reading ESC byte, the remaining escape sequence
   bytes ([A for up-arrow) were in Python's buffer but not visible to
   select.select() on the OS fd. Switched to os.read(fd, 1) which
   reads directly from the file descriptor, bypassing Python's buffer.

2. Footer positioned wrong: draw_footer() counted buffer items to
   calculate padding, but a Rich Table renders as multiple lines.
   Added _line_count tracker with _add_line() and _add_lines(n) so
   footer padding is calculated from actual rendered line count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:29:32 +00:00
8c7caf3969 fix(console): rewrite modern renderer with buffered output
Major issues fixed:
- Rich printed directly to stdout causing visible flicker on every redraw
- get_key() toggled raw mode per keypress causing glitches and slowness
- No alternate screen buffer — output contaminated terminal scrollback

Rewrite approach:
- Use alternate screen buffer (ESC[?1049h) for clean enter/exit
- Persistent raw mode for entire session instead of per-keypress toggle
- Buffer all Rich renderables during render cycle, flush once in refresh()
- Render to StringIO then write entire frame in single sys.stdout.write()
- Reduced ESC sequence timeout from 50ms to 20ms for snappier response

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:25:35 +00:00
f5e0525dfc perf(console): reduce ESC key delay from 1000ms to 25ms
Curses waits up to 1 second after ESC to distinguish it from escape
sequences (arrow keys, F-keys). Set ESCDELAY=25 before curses.initscr()
so ESC responds near-instantly while still handling escape sequences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:22:01 +00:00
274cf30e79 perf(console): persistent DB connection, query cache, PRAGMA tuning
- Reuse a single SQLite connection instead of open/close per query
- Add in-memory cache for frequently accessed data (brands, models,
  categories) — 1000x faster on repeated access
- Enable WAL journal mode, 8MB cache, 64MB mmap for faster reads
- Cache terminal size per render cycle to avoid repeated getmaxyx()
- Close DB connection on app exit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:19:50 +00:00
5444cf660a fix(console): deduplicate models and engines in vehicle navigation
Models and engines tables have many duplicate names (e.g. 24 ASTRA rows,
210 F-150 rows, 398 "5.7L 350CID V8" rows). Changed get_models() and
get_engines() to use GROUP BY UPPER(name) instead of DISTINCT on id+name
so each model/engine appears only once in the navigation lists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:12:36 +00:00
4af3a09b03 docs: add console system documentation and design docs
Console README with usage instructions, keybindings reference, architecture
overview, and test commands. Updated root README with console section, updated
architecture diagram, and installation instructions. Includes approved design
doc and implementation plan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:03:22 +00:00
64503ca363 feat(console): add integration tests and polish error handling
Add MockRenderer-based integration tests that verify the full screen-to-
renderer pipeline without a real terminal. Update main.py with proper
--db flag handling, database existence check, startup banner, and
graceful error handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:59:08 +00:00
7bf50a2c67 feat(console): add Rich-based modern renderer
Implement TextualRenderer in console/renderers/textual_renderer.py using
the Rich library for a modern dark-themed TUI with blue/cyan accents.
All 18 BaseRenderer methods are implemented: lifecycle (init_screen,
cleanup), primitives (clear, refresh, get_key, get_size), widgets
(draw_header, draw_footer, draw_menu, draw_table, draw_detail,
draw_form, draw_filter_list, draw_comparison, draw_text, draw_box),
and dialogs (show_message, show_input). Keyboard input uses raw
terminal mode via tty/termios with full escape sequence decoding
for arrow keys, F-keys, Page Up/Down, Home/End.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:57:25 +00:00
8194167c51 feat(console): add admin CRUD screens for parts, manufacturers, crossref, import
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:53:36 +00:00
15f3c9c9fe feat(console): add part detail and comparator screens
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:52:46 +00:00
b042853408 feat(console): add catalog, search, and VIN decoder screens
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:49:15 +00:00
69fb26723d feat(console): add vehicle drill-down navigation screen
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:47:23 +00:00
e3ad101d56 feat(console): add app controller, main menu and statistics screen
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:45:03 +00:00
269bb9030b feat(console): add curses VT220 renderer with full widget set
Implements BaseRenderer abstract interface and CursesRenderer with
green-on-black VT220 aesthetic. Includes all 18 widget methods: header,
footer, menu, table, detail, form, filter list, comparison view, box
drawing, message dialogs, and input prompts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:41:51 +00:00
211883393e feat(console): add formatting utils and VIN API client
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:38:28 +00:00
ceacab789b feat(console): add core framework - keybindings, navigation, screen base
Add the three core modules that all screens depend on:
- keybindings.py: Key constants (curses codes) and KeyBindings registry
- navigation.py: Stack-based screen navigation with breadcrumbs
- screens.py: Screen base class with on_enter/on_key/render lifecycle

Includes 31 tests covering all public APIs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:38:02 +00:00
3b884e24d3 feat(console): add database abstraction layer with tests
Implement console/db.py with Database class providing all data access
methods for the console application, plus 36 passing tests in
console/tests/test_db.py covering vehicle navigation, parts catalog,
search, VIN cache, stats, manufacturers, and admin CRUD operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:34:22 +00:00
7cf3ddc758 feat(console): scaffold project structure and config
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:29:54 +00:00
140117a8e5 Fix 7 frontend bugs found during audit
- Fix breadcrumb group name fetch using existing /api/categories/<id>/groups
- Fix diagramModalLabel → diagramModalTitle DOM ID mismatch
- Replace bootstrap.Modal.getInstance() with classList.remove('active') for modal close
- Escape single quotes in brand/model names in breadcrumb onclick handlers
- Implement editAftermarket() form population in admin panel
- Handle VIN decoder response wrapper in landing page
- Fetch models count from API instead of hardcoded '13K+'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:59:53 +00:00
ad79724e8a Fix case-insensitive brand search, add hotspots endpoint and clean URLs
- Make brand and model name queries case-insensitive using UPPER()
- Add /api/diagrams/<id>/hotspots endpoint for fetching diagram hotspots
- Add /admin and /landing clean URL routes for HTML pages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:42:19 +00:00
e66b18f6ae Add admin panel, enhanced search, Gonher import and expand API
- Add admin interface (admin.html, admin.js) for managing catalog data
- Add enhanced search module with advanced filtering capabilities
- Expand server.py with new API endpoints and admin functionality
- Add Gonher catalog import scripts (import_gonher_catalog.py, import_gonher_complete.py)
- Add demo data population script and sample CSV data
- Update customer landing page and dashboard with UI improvements
- Update database with enriched vehicle and parts data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:35:05 +00:00
6fb2a52f86 Update vehicle cards to show complete motor specs
Vehicle cards now display 6 motor data fields:
1. Fuel type (Gasolina/Diésel/Híbrido/Eléctrico)
2. Power (HP)
3. Torque (Nm) - NEW
4. Displacement (formatted as liters, e.g., 3.0L)
5. Cylinders
6. Engine config (V6, I4, etc. - derived from name)

Changes:
- dashboard.js: Added helper functions for formatting
  - getEngineConfig(): Extracts V6, I4, H4, etc. from engine name
  - formatDisplacement(): Converts cc to liters
  - formatFuelType(): Spanish translations
- server.py: Added torque_nm to vehicles API response

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 08:42:46 +00:00
d213ec2df0 Add engine data enrichment script and populate tech specs
New script (enrich_engine_data.py):
- Parses engine names to extract displacement, cylinders, fuel type
- Estimates HP and torque based on engine characteristics
- Turbo engines get +35% power estimate
- Handles V6, V8, I4, diesel, electric, hybrid patterns

Results:
- 13,287 engines updated with technical data
- 99% coverage for displacement_cc
- 59% coverage for cylinders
- 99.9% coverage for fuel_type
- 95.7% coverage for power_hp and torque_nm

Example data:
- Chevrolet avg: 4945cc, 337HP, 7.6 cyl
- Toyota avg: 2767cc, 202HP, 6.5 cyl
- BMW avg: 3117cc, 262HP, 8.7 cyl

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 08:38:56 +00:00
834d7d2d96 Add landing page and redesign catalog with dark theme
Landing page (customer-landing.html):
- Modern dark theme with orange accent (#ff6b35)
- Dynamic stats, categories, products from API
- Integrated search modal with FTS
- VIN decoder section
- Responsive design with mobile support

Catalog redesign (index.html):
- Unified design matching landing page
- Custom modal system (removed Bootstrap dependency)
- Simplified breadcrumb navigation
- Updated card styles with hover effects
- Consistent color scheme and typography

JavaScript updates (dashboard.js):
- Custom modal open/close methods
- Updated element IDs for new HTML
- Paginated response handling
- Search input event binding

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 08:33:15 +00:00
d4d1c9b7ba Implement complete autoparts catalog system (5 phases)
FASE 1: Parts Database
- Added part_categories, part_groups, parts, vehicle_parts tables
- 12 categories, 190 groups with Spanish translations
- API endpoints for categories, groups, parts CRUD

FASE 2: Cross-References & Aftermarket
- Added manufacturers, aftermarket_parts, part_cross_references tables
- 24 manufacturers, quality tier system (economy/standard/premium/oem)
- Part number search across OEM and aftermarket

FASE 3: Exploded Diagrams
- Added diagrams, vehicle_diagrams, diagram_hotspots tables
- SVG viewer with zoom controls and interactive hotspots
- 3 sample diagrams (brake, oil filter, suspension)

FASE 4: Search & VIN Decoder
- SQLite FTS5 full-text search with auto-sync triggers
- NHTSA VIN decoder API integration with 30-day cache
- Unified search endpoint

FASE 5: Optimization & UX
- API pagination (page/per_page, max 100 items)
- Dark mode with localStorage persistence
- Keyboard shortcuts (/, Ctrl+K, Escape, Backspace, Ctrl+D)
- Breadcrumb navigation
- ARIA accessibility (labels, roles, focus management)
- Skip link for keyboard users

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 07:13:46 +00:00
61474f7abe Update multibrand scraper v3 with all RockAuto brands
Added 108 brands total:
- 90 main brands (international)
- 18 regional brands (Mexico, China, etc.)

Features:
- Interactive menu with multiple options
- Search brand by name
- Select by initial letter
- Process range of brands (e.g., 1-10)
- View all brands status with pagination
- Skip wait time with ENTER
- Years: 1975-2026, 5 years per batch
2026-01-19 09:17:54 +00:00
997f777514 Add multibrand scraper v2
New brands: Dodge, Honda, Mitsubishi, Jeep, BMW, Fiat,
Hyundai, Infiniti, Kia, Land Rover, Lexus

Features:
- Interactive menu to select brand and batch
- Skip wait time by pressing ENTER
- Years range: 1975-2026
- 5 years per batch with 3 min pause
2026-01-19 09:04:07 +00:00
f395d67136 Initial commit: Sistema Autoparts DB
- Base de datos SQLite con información de vehículos
- Dashboard web con Flask y Bootstrap
- Scripts de web scraping para RockAuto
- Interfaz CLI para consultas
- Documentación completa del proyecto

Incluye:
- 12 marcas de vehículos
- 10,923 modelos
- 10,919 especificaciones de motores
- 12,075 combinaciones modelo-año-motor
2026-01-19 08:45:03 +00:00