This project implements a Peer-to-Peer (P2P) Shopping System that allows users to buy and sell items through a server-mediated communication model. The system uses UDP for general communication and TCP for secure transactions, ensuring the safety and efficiency of peer interactions.
- Registration and Deregistration: Peers can register with the server to participate in the system and deregister when done.
- Item Searching and Offering: Buyers can search for items, and sellers can offer items with a specified price.
- Secure Transactions: Sensitive buyer-seller information is transmitted securely via TCP.
- Dynamic Negotiation: The server facilitates price negotiations between buyers and sellers if no offer matches the buyer's maximum price.
- Persistent State: Both server and peers persist their state to handle restarts without data loss.
- Logging: Comprehensive logging of activities for debugging and tracking purposes.
- Programming Language: Python
- Networking: UDP and TCP sockets
- Data Persistence: JSON-based storage for peer inventory and server state
- Threading: Multithreaded architecture for concurrent request handling
- Logging: Centralized logging for peers and server
- Registration: A peer registers with the server using its unique name and socket details.
- Item Search: Buyers send item search requests to the server, which forwards the search to all registered sellers.
- Offers: Sellers respond with offers if the item is available in their inventory.
- Negotiation: If no valid offers match, the server negotiates with the seller offering the lowest price.
- Transaction Finalization: Once a buyer accepts an offer, TCP connections handle sensitive data exchange (e.g., credit card details and shipping addresses).
- Python 3.6 or higher installed on your system.
-
Clone the repository:
git clone https://github.com/rishit2003/Peer-to-Peer-Shopping-System.git cd Peer-to-Peer-Shopping-System -
Install dependencies (if any).
-
Run the server:
python server.py
-
Run a peer client:
python peer.py
-
Start the Server:
- Run
server.pyand enter the desired UDP port when prompted.
- Run
-
Start a Peer:
- Run
peer.pyfor each peer and provide the server IP, server UDP port, peer name, and peer's UDP and TCP ports.
- Run
-
Interactive Menu:
- The peer provides options to register, deregister, search for items, add inventory items, and exit.
Peer-to-Peer-Shopping-System/
│
├── peer.py # Main script for peer operations
├── <peer_name>_inventory.json # Inventory storage for each peer
├── <peer_name>.log # Peer log file
└── README.md # Project documentation
Peer-to-Peer-Shopping-System/
│
├── server.py # Main script for server operation
├── server.json # Persistent state storage for the server
├── server.log # Server log file
└── README.md # Project documentation
-
Register a Peer:
Peer1 sends aREGISTERrequest to the server. -
Search for an Item:
Peer1 sends aLOOKING_FORrequest for an item (e.g., "Laptop"). -
Receive Offers:
Sellers respond withOFFERmessages if the item is available. -
Transaction Finalization:
Upon acceptance, a TCP connection handles secure credit card and shipping details.
- Server Logs: Logs server operations, requests, and state updates in
server.log. - Peer Logs: Each peer logs its activities (e.g., sent messages, inventory updates) in
<peer_name>.log.
- Add a GUI for easier interaction.
- Implement user authentication for additional security.
- Optimize message handling for scalability.
- Rishit Mittal (rishit2003)
- Rayan Alkayal (Rayan99k)
- Mohammad Natsheh (Mordred311)



