Skip to content

DocuChain-Document-Ownership-DApp/DocuChain-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DocuChain: Blockchain-Powered Document Management Platform πŸ”’πŸ“„

Revolutionizing Document and Property Management with Blockchain & NFTs

Overview

DocuChain is a cutting-edge, secure document management platform leveraging blockchain technology to provide immutable, verifiable, and transparent document handling. Built with Node.js, Ethereum, and IPFS, DocuChain ensures document integrity, traceability, and ownership verification.

🌟 Key Features

  • Immutable Document Storage: Leverage blockchain's inherent security
  • Decentralized File Storage: Utilize IPFS for distributed file management
  • Ownership Tracking: Real-time document ownership transfer and verification
  • Comprehensive Logging: Detailed audit trails for every document action
  • Secure Document Issuance: Cryptographically signed and verifiable documents

πŸ›  Technology Stack

  • Backend: Node.js, Express.js
  • Blockchain: Ethereum, Solidity
  • File Storage: IPFS
  • Database: MongoDB
  • Logging: Custom logging service
  • Smart Contracts: Truffle Framework

πŸ“¦ Project Structure

DocuChain-Backend/
β”‚
β”œβ”€β”€ build/
β”‚   └── contracts/
β”‚
β”œβ”€β”€ logs/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ routes/
β”‚   └── services/
β”‚
└── truffle/
    β”œβ”€β”€ contracts/
    └── migrations/

πŸš€ Endpoints

1. Issue Document

  • Endpoint: POST http://localhost:3000/api/documents/issue
  • Purpose: Upload and register a new document on blockchain
  • Request Headers:
    • Authorization: Bearer {access_token}
  • Request Body (Form-Data):
    • document: File to be uploaded
    • recipientAddress: Ethereum address of document recipient

2. Get Document

  • Endpoint: POST http://localhost:3000/api/documents/get
  • Purpose: Retrieve a specific document
  • Request Headers:
    • Authorization: Bearer {access_token}
  • Request Body:
    {
      "docId": "unique-document-identifier"
    }

3. Verify Document

  • Endpoint: POST http://localhost:3000/api/documents/verify
  • Purpose: Validate document authenticity
  • Request Headers:
    • Authorization: Bearer {access_token}
  • Request Body:
    {
      "docId": "unique-document-identifier"
    }

4. Transfer Document Ownership

  • Endpoint: POST http://localhost:3000/api/documents/transfer
  • Purpose: Transfer document ownership between addresses
  • Request Headers:
    • Authorization: Bearer {access_token}
  • Request Body:
    {
      "docId": "unique-document-identifier",
      "newOwner": "Ethereum address of document's current owner"
    }

5. Search Documents

  • Endpoint: POST http://localhost:3000/api/documents/search
  • Purpose: Search documents by issuer or recipient
  • Request Headers:
    • Authorization: Bearer {access_token}
  • Request Body:
    {
      "recipientAddress": "Ethereum address of document recipient"
    }

Authentication Flow

1. Signup Endpoint

  • Endpoint: http://localhost:3000/auth/signup
  • HTTP Method: POST
  • Content-Type: multipart/form-data
  • Purpose: Creating New Account on platform

Request

{
  walletAddress: string,   // Ethereum wallet address
  name: string,           // User's full name
  email: string,          // Valid email address
  phone: string,          // Phone number with country code
  uid: string,           // Unique identifier
  dob: string,           // Date of birth (MM/DD/YYYY)
  role: string,          // User role (default: 'user')
  photo: File,           // User photo (JPEG/PNG)
  idDocument: File       // Identity document (PDF)
}

Response

{
  "success": true,
  "walletAddress": "0x092Afb01ADFf2ca70860A7441AB12dae96b75Bae",
  "processingTime": 92
}

2. Generate Nonce Endpoint

  • Endpoint: http://localhost:3000/auth/generate-nonce
  • HTTP Method: POST
  • Purpose: Generate a unique nonce for signature challenge

Request

{
    "walletAddress": "0xUserWalletAddress"
}

Response

{
    "nonce": "0xWalletAddress:Timestamp:RandomString"
}

3. Verify Signature Endpoint

  • Endpoint: http://localhost:3000/auth/verify-signature
  • HTTP Method: POST
  • Purpose: Verify user's cryptographic signature and issue authentication tokens

Request Body

{
    "walletAddress": "0xUserWalletAddress",
    "signature": "0xSignatureGeneratedByWallet",
    "nonce": "0xGeneratedNonceFromPreviousStep"
}

Response

{
    "accessToken": "JWT_ACCESS_TOKEN",
    "refreshToken": "JWT_REFRESH_TOKEN"
}

4. Refresh Token Endpoint

  • Endpoint: http://localhost:3000/auth/refresh-token
  • HTTP Method: POST
  • Purpose: Generate a new access token using a valid refresh token

Request Body

{
    "refreshToken": "EXISTING_REFRESH_TOKEN"
}

Response

{
    "accessToken": "NEW_JWT_ACCESS_TOKEN"
}

πŸ” Security Features

  • Ethereum address validation
  • Multer-based file upload security
  • IPFS decentralized storage
  • Blockchain-based document verification
  • Comprehensive error logging
  • File size limitations (50MB)

πŸ“ Prerequisites

  • Node.js (v14+ recommended)
  • MongoDB
  • Ethereum Wallet
  • Truffle
  • IPFS Node

πŸ›  Installation

  1. Clone the repository

    git clone https://github.com/DocuChain-Document-Ownership-DApp/DocuChain-Backend.git
  2. Install dependencies

    npm install
  3. Configure environment variables

    cp .env.example .env
  4. Compile The Contracts

    npm run compile
  5. Migrate the Contract

    npm run migrate
  6. Start the server

    npm run start

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Ethereum Foundation
  • IPFS Team
  • OpenZeppelin
  • Truffle Suite

Built with ❀️ by the DocuChain Team

About

Revolutionizing Document and Property Management with Blockchain & NFTs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •