Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Firbease configuration
NEXT_PUBLIC_FIREBASE_API_KEY=TU_API_KEY
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=TU_AUTH_DOMAIN
NEXT_PUBLIC_FIREBASE_PROJECT_ID=TU_PROJECT_ID
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=TU_STORAGE_BUCKET
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=TU_MESSAGING_SENDER_ID
NEXT_PUBLIC_FIREBASE_APP_ID=TU_APP_ID

# Trustless Work API
NEXT_PUBLIC_API_URL=https://dev.api.trustlesswork.com
NEXT_PUBLIC_API_KEY=TU_API_KEY


18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
.pnp.js
.yarn/install-state.gz

# testing
/coverage
Expand All @@ -28,14 +24,18 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*
# local env files
.env*.local
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# instructions
instructions/
instructions/*
191 changes: 117 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,140 @@
# πŸš€ TrustBridge

**TrustBridge** is a decentralized platform aimed at enhancing P2P transactions by providing secure microloan agreements powered by blockchain and trustless technologies. Our goal is to ensure transparency, trust, and automation in financial transactions, making lending seamless and cost-effective.
**TrustBridge** is a decentralized lending platform built on the Stellar blockchain and integrated with Trustless Work for smart contract management. It enables users to request and fund secure loans, ensuring transparency, automation, and security without traditional intermediaries.

## 🎯 Key Benefits and Objectives

- Enhance trust in microloan agreements through blockchain transparency.
- Provide automated and secure smart contract execution.
- Minimize transaction costs and maximize accessibility.
- Facilitate access to secure, decentralized loans via the Stellar network.
- Connect borrowers and lenders through a transparent marketplace.
- Automate escrow creation with Trustless Work for secure fund handling.

## πŸ”’ Why Choose TrustBridge?

### βš™οΈ Core Advantages

- **Security:** End-to-end encryption and decentralized architecture protect sensitive data.
- **Transparency:** Blockchain ledger ensures all transactions are publicly verifiable.
- **Decentralization:** Removes intermediaries, reducing costs and increasing efficiency.
- **Automation:** Smart contracts handle agreement execution without manual intervention.
- **Security:** Funds are managed by smart contracts, not centralized entities.
- **Transparency:** All loan activities are verifiable on the blockchain.
- **Efficiency:** Fast transactions and no intermediaries.
- **Smart Automation:** Conditions are enforced automatically via escrow contracts.

## 🌟 Key Features
## 🌟 Marketplace Features

- **🏦 Secure Microloan Agreements:** Ensure safety and compliance in financial transactions.
- **πŸ”— Blockchain-Powered Transparency:** All actions are recorded and verifiable.
- **⚑ Smart Contract Automation:** Automate loan agreements with predefined conditions.
- **πŸ’° Low Transaction Fees:** Cost-effective solutions with minimal overhead.
- 🧾 Browse approved loan requests
- πŸ“Š View key loan details: amount, borrower, date, conditions
- πŸ”Ž Search and filter by title, minimum amount, and date
- 🧩 Fund directly from wallet via Trustless Work API
- πŸ” Fully decentralized and trustless escrow deployment

## πŸ› οΈ How It Works

### Step-by-Step Process
1. **Borrower submits a loan request.**
2. **Loan is reviewed and approved by the platform.**
3. **The request appears in the marketplace.**
4. **Lenders fund loans via their Stellar wallet.**
5. **A smart contract is deployed through Trustless Work.**
6. **Loan is disbursed automatically.**

1. **πŸ—οΈ Loan Creation:** Borrower submits a loan request through the TrustBridge platform.
2. **πŸ’΅ Funding:** Investors review and fund loan requests via secure wallets.
3. **πŸ“„ Agreement Execution:** Smart contracts automate terms and conditions.
4. **πŸ”„ Loan Repayment or Default Handling:** Repayments are tracked, and defaults managed transparently.
---

## βš™οΈ Getting Started

### πŸ“‹ Prerequisites

- **πŸ–₯️ Node.js** (v14 or later)
- **πŸ” Wallet Integration** (Albedo, Freighter)
- **🌐 API Access Setup** (Registration required)

### πŸ› οΈ Installation

1. **🍴 Forking and Cloning the Repository**
```bash
git clone https://github.com/TrustBridgeCR/dApp-TrustBridge.git
cd dApp-TrustBridge
```
2. **πŸ”„ Adding Remote Upstream**
```bash
git remote add upstream https://github.com/TrustBridgeCR/dApp-TrustBridge.git
```
3. **βš™οΈ Setting Up Environment Variables**
Create a `.env` file and configure required API keys.
4. **πŸ“¦ Installing Dependencies**
```bash
npm install
```
5. **▢️ Running the Development Server**
```bash
npm run dev
```

## πŸ“‘ API Reference

### Key Endpoints

- **πŸ†• `/loan/initiate`** - Start a new loan agreement.
- **πŸ’° `/loan/fund`** - Fund an existing agreement.
- **βœ… `/loan/settle`** - Settle a completed agreement.

## πŸ—οΈ Tech Stack

- **πŸ’» Frontend:** Next.js, TypeScript, Tailwind CSS.
- **πŸ” Blockchain:** Smart Contracts, Trustless Transactions.
- **🌐 Backend Integration:** API services for seamless escrow management.

## πŸ§ͺ Testing Infrastructure

### Guidelines

- **🧩 Unit and E2E Testing:** Implemented with Jest and Cypress.
- **πŸƒ Running Tests:**
```bash
npm test
npm run test:e2e
npm run test:coverage
```
- **πŸ”„ CI/CD Setup:** Automated using GitHub Actions.
Follow the steps below to get started with this project:

### πŸ“¦ Installation

1. Install dependencies:

```bash
npm i
```

2. Format the code using Prettier:

```bash
npx prettier --write .
```

3. Start the development server:

```bash
npm run dev
```

---

## πŸ” Environment Variables

Create a `.env` file in the root of the project with the following:

```env
# Firebase configuration
NEXT_PUBLIC_FIREBASE_API_KEY=TU_API_KEY
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=TU_AUTH_DOMAIN
NEXT_PUBLIC_FIREBASE_PROJECT_ID=TU_PROJECT_ID
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=TU_STORAGE_BUCKET
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=TU_MESSAGING_SENDER_ID
NEXT_PUBLIC_FIREBASE_APP_ID=TU_APP_ID

# Trustless Work API
NEXT_PUBLIC_API_URL=https://dev.api.trustlesswork.com
NEXT_PUBLIC_API_KEY=TU_API_KEY
```

### API Key Video

[dApp Trustless Work](https://dapp.trustlesswork.com)

https://github.com/user-attachments/assets/69f0adf2-cb5f-48ff-a4eb-bb1870fa35fa

### Firebase Video

[Firebase](https://firebase.google.com)

https://github.com/user-attachments/assets/0c4a8a80-33f1-41ae-819b-6a38abf30e4b

---

## πŸ”₯ Firebase Setup

Once you have your Firebase database ready, add the following document in the `trustlines` collection:

```
name: "USDC" (string)
trustline: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5" (string)
trustlineDecimals: 10000000 (number)
```

---

## πŸ”‘ Wallet Requirements

To use this platform, install one of the following wallets:

- Freighter
- Albedo
- xBull
- LOBSTR

### Wallet Usage Note

Ensure your wallet is set to "test net". If you see "Not Available" in Freighter:

- Go to **Security > Manage Connected Wallets**
- Remove **localhost**
- Reload and reconnect

If problems persist, contact support.

---

## 🧠 IMPORTANT NOTE (Husky Setup)

We use **Husky** to ensure code formatting and linting on `git push`. If `npm run format` or `npm run lint` fail, your push will be blocked.

Fix any errors before retrying your push.

---

## πŸ“œ License

Β© 2025 TrustBridge. Released under the MIT License.

🌟 Join TrustBridge today and transform how you manage microloans! 🌟
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
Expand Down
20 changes: 20 additions & 0 deletions firebase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore/lite";
import { getStorage } from "firebase/storage";

const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
};

// Initialize Firebase
export const firebaseApp = initializeApp(firebaseConfig);

export const firebaseDB = getFirestore(firebaseApp);

export const firebaseStorage = getStorage(firebaseApp);
Loading