Skip to content

anshul9809/asset-trader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Asset Trading Tracker - Backend

Overview

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.

Features

  • User registration and authentication with JWT
  • Asset creation, management, and publishing
  • Marketplace listing and asset trading
  • Price negotiation and trading history tracking

Technologies Used

  • 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

Project Structure

/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

Getting Started

Prerequisites

  • Node.js
  • MongoDB

Installation

  1. Clone the repository:

    git clone https://github.com/anshul9809/asset-trader
    cd backend
  2. Install dependencies

    npm install
  3. 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
  4. Start the server:

    npm start

API Endpoints

User Authentication

  1. 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]"
      }
    }
  1. 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]"
      }
    }

Asset Management

  1. 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
    }
  1. 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
    }
  1. Get Asset Details
  • Endpoint:

    GET /assets/:assetId
  • Response:

    {
      "asset": {
        "id": assetId,
        "name": "Bitcoin",
        "description": "Digital currency",
        "image": "https://example.com/bitcoin.jpg",
        "price": 30000
      }
    }

Request

  1. Create Request
  • Endpoint:

    POST /assets/{assetId}/requests
  • Request:

    {
      "proposedPrice": 30000
    }
  • Response:

    {
      "message": "Request sent successfully",
      "requestId": requestId
    }
  1. Accept Request
  • Endpoint:

    PUT /requests/:id/accept
  • Response:

    {
      "message": "Request accepted successfully",
      "requestId": requestId
    }
  1. Reject Request
  • Endpoint:

    PUT /requests/:id/deny
  • Response:

    {
      "message": "Request rejected successfully",
      "requestId": requestId
    }
  1. 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]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published