Whether you're a car enthusiast, a mechanic, or a regular vehicle owner, PartsPal is designed to help you quickly find the exact parts you need for your vehicle maintenance or repair projects.
- Search and compare car parts from multiple providers
- Real-time price and availability updates
- User-friendly Fyne desktop application
- Websocket API for easy integration into other applications
- Go (version 1.16 or higher)
- Fyne (installation guide: https://github.com/fyne-io/fyne)
- Gorilla Websocket (installation guide: https://github.com/gorilla/websocket)
- Clone the repository:
git clone <repository-url>
- Install dependencies:
go mod download
3.1. Build the Fyne application:
go build cmd/parts-pal/main.go
3.2. Build the Websocket server:
go build cmd/api/main.go
- Run the built executables:
./main
- Packaging the Fyne application (optional):
fyne package -os <operating-system> -icon <icon-file> # https://developer.fyne.io/started/packaging
- Run the Fyne application:
./main
- Enter the product code information and click the "Search" button
- Run the Websocket server:
./main
- Connect to the server using a websocket client on localhost:3000/ws/scrape
- Send a simple byte message containing the product code information: "27025"
- The server will respond with a JSON message containing the product information. There are 2 types of messages: " bestDeal" and "deal"
- The "bestDeal" message contains the best deal for the product, while the "deal" message contains a deal from one of the providers
package main
import (
"log"
"github.com/gorilla/websocket"
)
func main() {
// Establish a WebSocket connection
conn, _, err := websocket.DefaultDialer.Dial("ws://localhost:3000/ws/scrape", nil)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
// Send a simple message with the product code
err = conn.WriteMessage(websocket.TextMessage, []byte("PRODUCT_CODE"))
if err != nil {
log.Fatal(err)
}
// Receive and handle WebSocket messages
for {
_, message, err := conn.ReadMessage()
if err != nil {
log.Fatal(err)
}
// Handle the received message
log.Println("Received message:", string(message))
}
}
Replace "PRODUCT_CODE" in the code above with the actual product code you want to search for.