# natalrhyme/pricetrackerpro architecture

> Architecture diagram of the GitHub repository natalrhyme/pricetrackerpro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/natalrhyme/pricetrackerpro
- Repository: https://github.com/natalrhyme/pricetrackerpro

## Overview

- Frontend (Client):
- Components: The “client” folder holds the React user interface, which includes:
- Pages such as auth-page, dashboard, home-page, and not-found.
- UI components (divided into feature-driven components like product-card, add-product-dialog, price-chart, etc.) and many reusable shadcn/ui themed components.
- Hooks, libraries (for authentication, mobile handling, and toast notifications), and utility functions.
- Responsibilities: Render the user interface, handle user interactions (such as product tracking and price alerts), and manage state with TanStack Query.

- Backend (Server):
- Components: The “server” folder contains core server functionality:
- Authentication (server/auth.ts) using Passport.js for session-based auth.
- APIs/routes (server/routes.ts, server/index.ts): Manage endpoints for tracking products, handling alerts, and user data.
- Database integration (server/db.ts), storage (server/storage.ts), and possibly the scraper (from client/src/lib/scraper.ts) responsibilities.
- Responsibilities: Validate requests, execute business logic, handle user authentication, manage sessions, interface with the database, and provide data to the client.

- Database:
- Use of PostgreSQL (with Drizzle ORM indicated by drizzle.config.ts) to store data like user information, tracked products, price histories, and target prices.

- Shared Modules:
- “shared/schema.ts” which likely contains shared data models or validation schemas used by both client and server for consistency.

##### Relationships and Data Flow
- The Backend authenticates requests (using server/auth.ts with Passport.js) and processes product tracking requests.
- The Database (PostgreSQL) is queried and updated by the server (using Drizzle ORM in server/db.ts), showing flow of data between backend and database.

##### Incorporate Important Architectural Patterns
- Separation of Concerns: Clearly differentiate between the Client (presentation layer) and the Backend (business logic, persistence).
- MVC / RESTful API Design: Even if not explicitly MVC, the server’s organization (routes, authentication, DB access) follows RESTful principles.
- Modular Design: Each component (UI components, hooks, server routes, data access layers) is self-contained, emphasizing reusability and testability.
- Shared schemas and utilities improve consistency between the client and server.

##### Specify Relevant Technologies, Frameworks, and Libraries
- Frontend: React, TanStack Query, Tailwind CSS, and shadcn/ui.
- Backend: Express.js, Passport.js (authentication), and Vite (for development, as seen by vite.ts in server and vite.config.ts in root).
- Database: PostgreSQL with Drizzle ORM.
- Additional libraries: Recharts for interactive price history charts, and other UI components for a rich responsive experience.

##### Final Assembly
- Modularity of the system by grouping related components (shared schemas, hooks, and utilities) within their respective clusters.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        PAGES["Pages (auth-page, dashboard, home-page, not-found)"]:::frontend
        UI["UI Components (product-card, add-product-dialog, price-chart, shadcn/ui)"]:::frontend
        HOOKS["Hooks (use-auth, use-mobile, use-toast)"]:::frontend
        LIB["Lib Utilities (protected-route, queryClient, scraper, utils)"]:::frontend
    end

    subgraph "Backend"
        API["API Routes & Server Entry"]:::backend
        AUTH["Authentication (Passport.js)"]:::backend
        DBINT["DB Integration (Drizzle ORM)"]:::backend
        STORAGE["Storage Module"]:::backend
        DEV["Dev Config (Vite)"]:::backend
    end

    subgraph "Database"
        POSTGRES["PostgreSQL Database (Drizzle ORM)"]:::database
    end

    SHARED["Shared Modules (Schemas)"]:::shared
    ECOM["E-commerce Platforms"]:::external

    %% Relationships - Frontend to Backend
    PAGES -->|"API_call"| API
    UI -->|"API_call"| API
    HOOKS -->|"API_call"| API
    LIB -->|"API_call"| API

    %% Backend internal flows
    API -->|"auth_process"| AUTH
    API -->|"DB_query"| DBINT
    DBINT -->|"data_storage"| POSTGRES
    API -->|"storage_access"| STORAGE
    API -->|"scrape_data"| ECOM
    API -->|"schema_validation"| SHARED
    LIB -->|"shared_logic"| SHARED

    %% Click Events
    click PAGES "https://github.com/natalrhyme/pricetrackerpro/tree/main/client/src/pages"
    click UI "https://github.com/natalrhyme/pricetrackerpro/tree/main/client/src/components"
    click HOOKS "https://github.com/natalrhyme/pricetrackerpro/tree/main/client/src/hooks"
    click LIB "https://github.com/natalrhyme/pricetrackerpro/tree/main/client/src/lib"
    click API "https://github.com/natalrhyme/pricetrackerpro/blob/main/server/routes.ts"
    click AUTH "https://github.com/natalrhyme/pricetrackerpro/blob/main/server/auth.ts"
    click DBINT "https://github.com/natalrhyme/pricetrackerpro/blob/main/server/db.ts"
    click STORAGE "https://github.com/natalrhyme/pricetrackerpro/blob/main/server/storage.ts"
    click DEV "https://github.com/natalrhyme/pricetrackerpro/blob/main/server/vite.ts"
    click POSTGRES "https://github.com/natalrhyme/pricetrackerpro/blob/main/drizzle.config.ts"
    click SHARED "https://github.com/natalrhyme/pricetrackerpro/blob/main/shared/schema.ts"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef database fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef shared fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
