How jabesinhoo/pdf-catalogo works
1. This repo is a two-tier application: a React/Vite frontend and a Node.js backend. The product is a “catalog PDF” tool that ingests products from Tecnonacho URLs, lets the user edit/organize them, and generates downloadable documents.
2. The frontend is the interactive workspace. Its main screen is composed from MainLayout, a top bar, sidebar navigation, search/history panels, product cards, quote editors, and admin screens. It also includes login/session UI, saved documents/quotes panels, and modal-based editing flows for product and quote adjustments.
3. Frontend state is split between server-backed data and browser persistence. Utilities like documentStorage, quoteStorage, and savedQuotes indicate local caching of user work, while useSessionKeepAlive suggests the browser keeps the authenticated session alive with periodic backend calls.
4. The backend is organized as a classic API layer with controllers and routes. Separate route groups exist for auth, admin, documents, PDFs, products, stats, and cache, with controllers handling the request/response boundary and services holding the domain logic.
5. Product ingestion is a distinct subsystem. tecnonachoScraper pulls data from external Tecnonacho pages, productService and realPriceService normalize or enrich that data, and productCacheService keeps a server-side cache so repeated lookups are cheaper and more consistent.
6. Document generation is another major pipeline. pdfService and the catalogTemplate / quoteTemplate modules build the output artifacts, while the public/flipbooks directories show that generated HTML “flipbook” outputs are written to disk and then served statically by the backend.
7. Persistence is handled through a SQL database with migration scripts. The migrations create and evolve at least three core tables: documents, users, and product cache. A databaseService abstraction sits between the app and the database, so the rest of the backend likely does not talk to SQL directly.
8. Authentication and administration are first-class concerns. There are dedicated auth and admin controllers/routes, a session config module, a user service, and scripts for creating an admin account and generating password hashes. This points to server-managed login sessions rather than purely token-based auth.
9. Operational safeguards are built into the backend. rateLimiter and validators sit in middleware, which means request throttling and input validation are enforced before controllers run. loggerService and statsService suggest the system also records activity and exposes usage metrics.
10. The backend also exposes a product cache/admin statistics surface. Separate cache and stats routes imply that cache maintenance and reporting are explicitly available as API concerns, likely for internal/admin use rather than normal end-user workflows.
11. The main data flow is: user inputs a Tecnonacho URL in the frontend → backend scrapes and normalizes product data → products are edited/organized in the UI → backend generates catalog/quote artifacts → generated files are stored under public assets and returned to the user. Saved work can be revisited via document and quote history.
12. Deployment is automated with GitHub Actions, and the backend includes migration/run scripts for environment setup. That suggests the repo expects repeatable database migrations and server deployment as part of its release process.
Main entry points: routes API routes · MainLayout.jsx Main layout · services Core services · databaseService.js Database
Components 20
Frontend
React/Vite workspace for searching, editing, and organizing catalog content.
- Main layout · Primary workspace composition for the app shell and core panels.
frontend/src/layouts/MainLayout.jsx - Top bar · Header actions, navigation, and session-related controls.
frontend/src/components/TopBar.jsx - Sidebar nav · Document and workspace navigation panel.
frontend/src/components/SidebarDocumentNav.jsx - Search panel · Product search and browsing entry point.
frontend/src/components/SearchPanel.jsx - Product cards · Draggable product presentation and organization surface.
frontend/src/components/DraggableProductCard.jsx - Quote editor · Table and form tools for quote editing and recalculation.
frontend/src/components/QuoteEditorTable.jsx - Saved work · Panels for saved documents, quotes, and action history.
frontend/src/components/SavedDocuments.jsx - Auth UI · Login and user/session status controls.
frontend/src/components/Login.jsx - Edit modals · Modal flows for product, price, and confirmation edits.
frontend/src/components/EditProductModal.jsx - Local state · Browser-side persistence for documents, quotes, and saved items.
frontend/src/utils/documentStorage.js - Keepalive · Periodic session refresh to keep authentication active.
frontend/src/hooks/useSessionKeepAlive.js
Backend
Node.js API, ingestion, persistence, and document generation services.
- API app · Backend application entry and server wiring.
backend/src/app.js - API routes · Route boundaries for auth, admin, documents, PDFs, products, cache, and stats.
backend/src/routes - Core services · Business logic for products, documents, users, stats, logging, and storage.
backend/src/services - Tecnonacho ingest · External product scraping and normalization pipeline.
backend/src/scrapers/tecnonachoScraper.js - PDF pipeline · Catalog and quote template rendering plus PDF/export handling.
backend/src/services/pdfService.js - Templates · Catalog and quote document layouts used by generation services.
backend/src/templates/catalogTemplate.js - Database · Database config, migrations, and persistence abstraction for users, documents, and cache.
backend/src/services/databaseService.js - Security · Session, validation, and rate limiting controls around API access.
backend/src/middleware/validators.js - Ops tools · Migration, admin creation, and deployment scripts.
backend/scripts/run-migrations.js
Connections 22
- Main layout → Top bar: composes · The app shell includes top-level chrome.
- Main layout → Sidebar nav: composes · Workspace navigation is part of the main layout.
- Main layout → Search panel: hosts · Search and browsing are central workspace panels.
- Main layout → Product cards: hosts · Product organization happens inside the main workspace.
- Main layout → Quote editor: hosts · Quote editing is embedded in the workspace.
- Main layout → Saved work: hosts · Saved items and history panels are reachable from the main layout.
- Auth UI → Keepalive: extends session · Authentication state is maintained in the browser.
- Local state → Saved work: backs · Local persistence feeds the saved documents/quotes UI.
- Search panel → API routes: queries · Search and product ingestion actions call backend APIs.
- Quote editor → API routes: saves · Quote edits and document actions are persisted server-side.
- Auth UI → API routes: authenticates · Login/session flows depend on backend auth endpoints.
- API app → API routes: mounts · The server exposes grouped HTTP routes.
- API routes → Security: guards · Middleware enforces validation and throttling before handlers.
- API routes → Core services: delegates · Controllers and routes hand off to domain services.
- Core services → Tecnonacho ingest: ingests · Product services rely on Tecnonacho scraping and normalization.
- Core services → PDF pipeline: renders · Document services generate catalog and quote artifacts.
- PDF pipeline → Templates: uses · Templates define the output document structure.
- Core services → Database: stores · Domain services read and write through the database abstraction.
- Tecnonacho ingest → Database: caches · Scraped product data is normalized and cached server-side.
- Ops tools → Database: migrates · Scripts manage schema creation and updates.
- Ops tools → API app: deploys · Operational scripts support server startup and release workflows.
- Core services → API routes: serves · Service outputs are exposed through controllers and routes.