Phua KY profile picture

Phua KY

Biz Sale Platform

Motivation for building this project

I started building this project because I felt existing business for sale platforms had outdated designs and limited search capabilities. My goal was to leverage modern web development tools and AI to create a better user experience.

Specifically, I wanted to improve upon a few key areas:

  • Search functionality - I aimed to implement natural language processing and algorithms to enable more intuitive search based on business descriptions, not just titles. This would help users find relevant businesses that suit their interests and criteria.

  • User experience - By utilizing a modern tech stack and UI libraries, I could create a more visually appealing and user-friendly interface compared to traditional platforms. Smooth UX improves engagement.

  • Data insights - There was an opportunity to apply AI and data analytics to extract and surface helpful insights about listings, like estimated valuation, profitability metrics, and investment outlook. This additional context aids decision making.

  • Mobile experience - Optimizing for mobile and responsive design opens the platform to on-the-go usage and expands accessibility. Many existing platforms are desktop-centric.

Overall, my motivation was to modernize and enhance the business for sale search process through technology and design. By improving search, UX, insights, and mobility, I could create a more useful and engaging platform for buyers and sellers alike. The existing offerings felt outdated, so I saw potential to innovate.

What have i already build?

  1. Next.js Application: The use of next in the package names and scripts suggests that this is a Next.js project. Next.js is a popular React framework that enables functionalities like server-side rendering and generating static websites.

  2. Firebase: The presence of firebase and firebase-admin in the dependencies indicates that Firebase is being used. This could be for authentication, database, hosting, or other Firebase services.

  3. Typesense: The typesense and typesense-instantsearch-adapter dependencies suggest that Typesense is used for search functionality. Typesense is a fast, typo-tolerant search engine that provides instant search experiences.

  4. Algolia Search: The algoliasearch, instantsearch.css, and instantsearch.js dependencies indicate that Algolia’s search UI libraries are also being used, which is interesting because it’s another search platform similar to Typesense. It’s possible that the project started with Algolia and then switched to Typesense, or it could be using both for different purposes.

  5. Styling and UI Components: Dependencies like tailwindcss, daisyui, react-select, and react-toastify suggest that the project uses Tailwind CSS for styling, DaisyUI for UI components, and provides select input and toast notifications functionalities.

  6. Development Tools: The project uses TypeScript (typescript), ESLint (eslint), and various type definitions (e.g., @types/node, @types/react) for development, which helps with type safety and code quality.

  7. Scripts: The scripts section in package.json defines commands for running the development server (dev), building the project (build), starting the production server (start), linting the code (lint), and a custom script for indexing a collection to Typesense (index-collection).

  8. Firebase Hosting and Emulators: The firebase.json file configures Firebase hosting and emulators, which suggests that the application might be hosted on Firebase and uses emulators for local development and testing.

  9. Data Collection: The presence of packages like axios, node-fetch, and jsdom in the Getting Biz Data snippet suggests that there might be a component of the project dedicated to collecting business data, possibly through web scraping or API calls.

  10. Environment Configuration: The .firebaserc file specifies a default project ID for Firebase, and the use of dotenv indicates that environment variables are used for configuration.

From these details, it seems that “next-biz-listings” is a web application for listing businesses, with a focus on providing a searchable interface, possibly for users to find businesses for sale. It uses modern web development tools and practices, and it’s configured for both development and production environments.

Flow of the Project

  1. Next.js Application: The Next.js app (next-biz-listings) is indeed designed to display data to users. It likely uses Typesense to provide full-text search capabilities, allowing users to search through business listings with advanced filtering options.

  2. Data Population: The Getting Biz Data folder contains scripts that are responsible for fetching new business data. These scripts compare the new data against existing data to determine what needs to be updated or appended.

  3. Firestore Synchronization: Once the new business data is processed, it is appended to Firestore, which is Google’s NoSQL cloud database. The synchronization between Firestore and Typesense ensures that the search data in Typesense is up-to-date with the latest business listings stored in Firestore.

  4. Typesense Database: Typesense is configured to index the data from Firestore, making it searchable through its fast search engine. This indexed data is what powers the search functionality in the Next.js application.

  5. Advanced Filtering: The Next.js app leverages Typesense’s search capabilities to allow users to perform advanced filtering when searching for business listings. This could include filters like location, industry, price range, etc.

Main Logic Flows for Getting new data to typesense.

  1. Load configuration
  2. Check data is synchronized
  3. Load old listings data
  4. Fetch new listings data
  5. Fetch details for listings
  6. Process listings data
  7. Combine old and new listings
  8. Save combined data to database
  9. Index combined data to search engine
  10. Update metadata
  11. Log errors
  12. add listed

Described Flow

// 1. It checks if the current data is synchronized with the source it's fetching from. If not, it stops the process to avoid errors.
// 2. It decides whether to re-fetch all listings or just the new ones based on a configuration setting.
// 3. It fetches the old listings from the database to compare with the new data.
// 4. It looks for new, sold, or deleted listings by comparing the old data with the newly fetched data.
// 5. It processes the listings, which could involve cleaning up the data or transforming it into a more useful format.
// 6. It saves the processed listings to Firestore.
// 7. It updates the metadata, which is data about the data, like how many listings there are in total.
// 8. It indexes the listings in Typesense, which makes them searchable.

To do 3 jan 2023.

  1. Modularize the Code:

Identify common patterns and repeated code blocks. Refactor these into separate functions or modules. Ensure each module has a single responsibility and clear interface.

  1. Asynchronous Operations:

Identify I/O operations (like file system access or network requests). Use async/await or Promises to handle these operations asynchronously. Batch Processing:

Group similar operations together. Use database and API features that allow for batch operations. Caching:

Determine which data is accessed frequently and doesn’t change often. Store this data in memory or a local cache for faster access. Optimize Comparisons:

Replace array searches with Set or Map lookups where appropriate. Use algorithms with better time complexity for data comparison. Error Handling:

Add try/catch blocks around operations that may fail. Implement retry logic for transient errors. Logging and Monitoring:

Add logging statements to track the script’s progress and key events. Use monitoring tools to track performance metrics. Parallel Processing:

Identify independent tasks that can be run in parallel. Use Node.js worker threads or child processes to execute these tasks concurrently. Review External Services:

Check the documentation for Firestore and Typesense for best practices on bulk operations. Optimize queries and updates based on those best practices. Code Profiling:

Use profiling tools like Node.js built-in profiler or third-party tools to identify slow code. Focus optimization efforts on the slowest parts of the script. Configuration Management:

Externalize configuration settings into environment variables or a configuration file. Use a library like dotenv for managing environment variables. Testing:

Write unit tests for each function or module. Use a testing framework like Jest or Mocha to automate testing. Start with one strategy at a time, test thoroughly after each change, and measure the impact on performance. This will help you understand which optimizations are most effective and prevent introducing new issues into the script.


Phua KY profile picture
Multiple business owner wannabe. Big on finding out my fullest potential through mental toughness.
contact