This project is a barter trading system that allows users to trade items with each other. It includes features for user authentication, item management, trade creation, and more.
- User Authentication: Register, login, and manage user profiles.
- Item Management: Create, update, and delete items for trade.
- Trade Creation: Propose trades between users with offered and requested items.
- Trade Status Updates: Accept or reject trades, which updates the status of the items involved.
- Messaging: Users can send messages within a trade to communicate.
The project includes comprehensive tests to ensure functionality and reliability.
To run the tests, use the following command:
npm testTo run the tests serially (recommended to avoid race conditions), use:
npm test -- --runInBand- Node.js: Backend runtime environment.
- Express.js: Web framework for building the API.
- MongoDB: Database for storing user and item data.
- Mongoose: ODM for MongoDB.
- Jest: Testing framework for unit and integration tests.
- Cypress: End-to-end testing framework.
- Clone the repository.
- Install dependencies:
npm install
- Set up your environment variables (e.g.,
MONGODB_URI). - Run the application:
npm run dev
- Run the tests:
npm test
- Docker installed on your system
- Docker Compose (optional, for easier management)
First, create a Docker network for container communication:
docker network create my-networkStart the MongoDB container:
docker run --network my-network \
-p 27017:27017 \
--name mongodb \
mongoVerify MongoDB is running:
docker ps | grep mongodbBuild the Docker image for the application:
docker build -t thenusan/barter-trading-system .Run the application container with MongoDB connection:
docker run -p 3000:3000 \
--network my-network \
-e MONGODB_URI=mongodb://mongodb:27017/barter-trading \
thenusan/barter-trading-system- Check if MongoDB is accessible:
docker exec -it mongodb mongosh --eval "db.runCommand({ ping: 1 })"- Access the application in your browser:
http://localhost:3000
- Check MongoDB container status:
docker ps | grep mongodb- Check network connectivity:
docker network inspect my-network- Verify MongoDB logs:
docker logs mongodb- Check application logs:
docker logs <container_id>- Verify environment variables:
docker exec -it <container_id> env | grep MONGODB_URIWhen you're done, you can clean up the containers and network:
# Stop containers
docker stop mongodb
docker stop <app_container_id>
# Remove containers
docker rm mongodb
docker rm <app_container_id>
# Remove network
docker network rm my-network
# Remove image
docker rmi thenusan/barter-trading-systemContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.