Skip to content

TCG Enhanced Retailer is a comprehensive online platform built with React, enabling users to search for, collect, and purchase popular trading cards. Users can compile their unique collections, create decks, and shop for cards.

Notifications You must be signed in to change notification settings

reedoooo/enhanced-card-store-backend

Repository files navigation

enhanced-card-store-backend

Netlify Status

1. Client-Side (Front-end)

Your frontend will typically make HTTP requests (using libraries/frameworks like Axios, Fetch, or tools in frameworks like React, Angular, etc.) to your server's endpoints.

Example Client Interaction

  1. Trigger Scraping: The client might have a button labeled "Fetch Latest Prices". When this button is clicked, the client sends a request to the server endpoint to initiate scraping, e.g., sending a GET request to /scrape.

  2. Retrieve Data: After scraping, you might want to retrieve and display the latest data. The client could send a GET request to an endpoint, e.g., /getLatestPrices, and the server would respond with the required data which would be displayed on the frontend.

2. Server-Side (Backend)

The server will handle various responsibilities:

  1. Managing Scraping: When it receives a request from the client to start scraping (e.g., a GET request to /scrape), it'll run the scraper code to collect data from the target website.

  2. Storing Data: Once the scraping completes, the server can save the scraped data to a database (e.g., MongoDB as in the example).

  3. Responding to Client Data Requests: When the client asks for the latest data, the server will fetch it from the database and send it in the response.

Example Server Endpoints

  1. Start Scraping:

    app.get("/scrape", async (req, res) => {
      //... (as provided in the scraping script)
      res.send("Scraping completed");
    });
  2. Get Latest Prices:

    app.get("/getLatestPrices", async (req, res) => {
      const data = await collection.find().toArray(); // get all the data or filter as needed
      res.json(data);
    });

3. Database

The database (e.g., MongoDB) will store the data that's been scraped, enabling the server to quickly retrieve it when the client requests.

General Interaction Flow

  1. Client (e.g., browser) sends an HTTP request to the Server to initiate scraping.
  2. Server runs the scraping logic and collects data from the target website.
  3. Server then stores this scraped data into the Database.
  4. Client requests the latest scraped data.
  5. Server fetches the required data from the Database.
  6. Server sends the data back to the Client in the response.
  7. Client processes and displays this data to the user.

Additional Considerations

  1. Error Handling: Ensure there's error handling in place. For instance, if scraping fails, the server should send an appropriate error message to the client.

  2. Rate Limiting and Scheduling: Consider implementing rate limiting to avoid overloading the target website. If you're initiating scraping at regular intervals, you might want to use packages like node-cron to schedule scraping tasks.

  3. Real-time Updates: If you want real-time data updates on the client side after scraping, consider using WebSockets (with libraries like socket.io). This allows the server to push new data to the client immediately after scraping.

  4. User Feedback: If scraping takes a while, consider giving feedback to the user, such as displaying a loader or a progress bar.

  5. Authentication & Authorization: Depending on your application, you might want to restrict who can initiate scraping or who can access the data. Implementing authentication and authorization mechanisms will be crucial in such cases.

This should give you a good starting point for building an end-to-end system where the client, server, and scraper interact seamlessly.

About

TCG Enhanced Retailer is a comprehensive online platform built with React, enabling users to search for, collect, and purchase popular trading cards. Users can compile their unique collections, create decks, and shop for cards.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published