The Asset Trading Tracker is a backend application that allows users to manage and trade digital assets. Users can create, list, and trade assets on a marketplace, negotiate prices, and track the trading history of each asset.
- User registration and authentication with JWT
- Asset creation, management, and publishing
- Marketplace listing and asset trading
- Price negotiation and trading history tracking
- Node.js: Server-side JavaScript runtime
- Express.js: Web framework for Node.js
- MongoDB: NoSQL database for storing user and asset data
- JWT: JSON Web Tokens for user authentication
- Mongoose: ODM for MongoDB
/backend
├── /controllers # Business logic for each route
├── /models # Mongoose models and schemas
├── /routes # API route definitions
├── /middleware # Authentication and other middleware
├── /config # Configuration files
├── /utils # Utility functions
├── app.js # Express app
├── server.js # Entry point of the application
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/anshul9809/asset-trader cd backend -
Install dependencies
npm install
-
Create a .env file in the root directory and add your environment variables:
PORT=3000 MONGODB_URI=mongodb://localhost:27017/asset-trading JWT_SECRET=your_jwt_secret CLOUDINARY_CLOUD_NAME = YOUR_CLOUD_NAME CLOUDINARY_API_KEY = YOUR_API_KEY CLOUDINARY_API_SECRET = YOUR_API_SECRET
-
Start the server:
npm start
- User Signup
- Endpoint:
POST /auth/signup
- Request:
{ "username": "testuser", "email": "[email protected]", "password": "password123" } - Response:
{ "token": "your_jwt_token", "user": { "id": "your_user_id", "username": "testuser", "email": "[email protected]" } }
- User Login
-
Endpoint:
POST /auth/login
-
Request:
{ "email": "[email protected]", "password": "password123" } -
Response:
{ "token": "your_jwt_token", "user": { "id": "your_user_id", "username": "testuser", "email": "[email protected]" } }
- Create Asset
-
Endpoint:
POST /assets/
-
Request:
{ "name": "Bitcoin", "description": "Digital currency", "image": "https://example.com/bitcoin.jpg", "price": 30000 } -
Response:
{ "message": "Asset created successfully", "assetId": assetId }
- Update Asset
-
Endpoint:
PUT /assets/:assetId
-
Request:
{ "name": "Bitcoin", "description": "Digital currency", "image": "https://example.com/bitcoin.jpg", "price": 30000 } -
Response:
{ "message": "Asset updated successfully", "assetId" : assetId }
- Get Asset Details
-
Endpoint:
GET /assets/:assetId
-
Response:
{ "asset": { "id": assetId, "name": "Bitcoin", "description": "Digital currency", "image": "https://example.com/bitcoin.jpg", "price": 30000 } }
- Create Request
-
Endpoint:
POST /assets/{assetId}/requests -
Request:
{ "proposedPrice": 30000 } -
Response:
{ "message": "Request sent successfully", "requestId": requestId }
- Accept Request
-
Endpoint:
PUT /requests/:id/accept
-
Response:
{ "message": "Request accepted successfully", "requestId": requestId }
- Reject Request
-
Endpoint:
PUT /requests/:id/deny
-
Response:
{ "message": "Request rejected successfully", "requestId": requestId }
- Get Request Details
-
Endpoint:
GET /requests/:id
-
Response:
{ "request": { "id": requestId, "proposedPrice": 30000, "porposedAsset": assetId, } }
Thanks for using the Asset Trading Tracker API documentation. If you have any questions or need further assistance, feel free to reach out! Email : [email protected]