Skip to content

soumyadeepsarkar-2004/blockchain-tutor

Repository files navigation

Blockchain Tutor

Decentralized Course Booking Platform with AI Assistance


Overview

Blockchain Tutor is a decentralized course booking platform that leverages Web3 technologies and AI assistance to provide a secure, transparent, and intelligent learning marketplace.

The platform enables:

  • Decentralized course management – Courses, enrollments, and transactions are managed via smart contracts, reducing the need for centralized intermediaries.
  • Secure payments with Web3 – Students can book courses using crypto wallets (e.g., MetaMask), ensuring transparent and verifiable transactions.
  • AI-powered guidance – An integrated AI assistant helps learners discover courses, get personalized recommendations, and ask questions about the platform.
  • Ownership and trust – Blockchain-backed records provide tamper-resistant proof of enrollment and course ownership.

This repository contains the frontend and/or backend code (primarily in TypeScript) for interacting with the blockchain, integrating the AI assistant, and building the user interface for learners and instructors.


Features

  • Course Marketplace
    • Create, list, and manage courses.
    • View course details, instructor information, and pricing.
  • Decentralized Booking
    • Book courses using a Web3 wallet (e.g., MetaMask).
    • On-chain records of enrollments and payments.
  • AI Assistant
    • Helps users find relevant courses.
    • Answers common questions and guides users through the booking process.
  • Web3 Integration
    • Wallet connection and account detection.
    • Network status and contract interaction in TypeScript.
  • Scalable Architecture
    • TypeScript-based project, ready for extension and integration with APIs and smart contracts.

Tech Stack

  • Language: TypeScript
  • Web3: Likely ethers.js or web3.js (adjust as appropriate)
  • Wallet Integration: MetaMask (via browser extension)
  • AI Integration: HTTP-based AI API (e.g., OpenAI or similar; adjust to match your usage)
  • Build/Tooling: Node.js, npm/yarn (and optional bundlers like Vite/Webpack)

Update this section to reflect the exact libraries and frameworks you use (e.g., React, Next.js, Express, Hardhat, etc.).


Getting Started

Prerequisites

Ensure you have the following installed:

  • Node.js (recommended LTS)
  • npm (bundled with Node.js) or yarn
  • A Web3-enabled browser with MetaMask installed
  • (Optional) A testnet or local blockchain (e.g., Hardhat, Ganache, or a public test network like Sepolia/Goerli)

Repository Setup

# Clone the repository
git clone https://github.com/soumyadeepsarkar-2004/blockchain-tutor.git

# Enter the project directory
cd blockchain-tutor

# Install dependencies (choose one)
npm install
# or
yarn install

If the project has separate frontend / backend folders, you may need:

cd frontend
npm install

cd ../backend
npm install

Adjust as needed for your actual structure.


Configuration

The project likely uses environment variables for:

  • Blockchain RPC settings
  • Smart contract addresses
  • AI API keys and endpoints
  • Application configuration (e.g., app URL, default network)

Create a .env file in the root (or in frontend / backend as applicable), based on a sample file like .env.example (if present). A typical configuration could look like:

# Blockchain / Web3
VITE_RPC_URL=https://sepolia.infura.io/v3/<YOUR_INFURA_PROJECT_ID>
VITE_CHAIN_ID=11155111
VITE_CONTRACT_ADDRESS=0xYourContractAddress

# AI Assistant
VITE_AI_API_KEY=your_ai_api_key_here
VITE_AI_API_BASE_URL=https://api.your-ai-provider.com/v1

# App
VITE_APP_NAME=Blockchain Tutor
VITE_DEFAULT_NETWORK=sepolia

For a backend service:

RPC_URL=https://sepolia.infura.io/v3/<YOUR_INFURA_PROJECT_ID>
CHAIN_ID=11155111
CONTRACT_ADDRESS=0xYourContractAddress
AI_API_KEY=your_ai_api_key_here
AI_API_BASE_URL=https://api.your-ai-provider.com/v1
PORT=4000

Replace names and variables to match your actual code. Never commit real secrets to the repository.


Project Structure

Below is a generic example; update it to match your repository:

blockchain-tutor/
├─ src/
│  ├─ components/        # UI components (e.g., course cards, wallet button)
│  ├─ hooks/             # Custom React/Web3 hooks (e.g., useWallet, useContract)
│  ├─ lib/               # Web3/AI helpers and utilities
│  ├─ pages/             # Page components (if using Next.js or a similar framework)
│  ├─ types/             # TypeScript type definitions
│  └─ index.tsx          # Application entry point
├─ contracts/            # Smart contract interfaces or ABIs (if included)
├─ public/               # Static assets
├─ test/                 # Tests (unit/integration)
├─ package.json
├─ tsconfig.json
├─ .env.example
└─ README.md

Adjust this tree to reflect the actual layout once finalized.


Usage

Running the Application (Development)

From the project root (or frontend directory if applicable):

# Development server
npm run dev
# or
yarn dev

Then open the printed URL in your browser (commonly http://localhost:3000).

Connecting MetaMask

  1. Install the MetaMask browser extension.
  2. Create or import a wallet.
  3. Switch to the correct network (e.g., Sepolia testnet or your local network).
  4. Fund the wallet with test ETH if using a testnet.
  5. Click “Connect Wallet” or similar button in the app.
  6. Approve the connection in MetaMask.

Booking a Course (Example Flow)

  1. Browse the course catalog on the home page.
  2. Select a course to see details (description, price, instructor, etc.).
  3. Click “Book Course”.
  4. Confirm the transaction in MetaMask (gas fees + course price).
  5. Wait for the transaction to be mined; your enrollment should appear under “My Courses”.

Using the AI Assistant

Depending on your implementation, the AI assistant may appear as:

  • A chat widget (e.g., bottom-right of the screen).
  • A dedicated “AI Tutor” or “Ask AI” page.
  • An integrated sidebar for course pages.

Example usage:

  • Ask: “Recommend beginner-level blockchain courses.”
  • Ask: “Explain how smart contracts handle course enrollments on this platform.”
  • Ask: “Which courses are suitable for learning Solidity basics?”

Code Examples

Below are illustrative TypeScript snippets that you may adapt to match your actual implementation.

Connecting to a Contract (Frontend, using ethers.js)

// src/lib/contract.ts
import { ethers } from "ethers";

const CONTRACT_ADDRESS = import.meta.env.VITE_CONTRACT_ADDRESS;
const CONTRACT_ABI = [/* ABI JSON here */];

export function getCourseContract() {
  if (!window.ethereum) {
    throw new Error("MetaMask is not available");
  }

  const provider = new ethers.BrowserProvider(window.ethereum);
  const signer = provider.getSigner();
  return new ethers.Contract(CONTRACT_ADDRESS, CONTRACT_ABI, signer);
}

Booking a Course

// src/lib/courseService.ts
import { getCourseContract } from "./contract";

export async function bookCourse(courseId: number, priceWei: bigint) {
  const contract = getCourseContract();
  const tx = await contract.bookCourse(courseId, { value: priceWei });
  const receipt = await tx.wait();
  return receipt;
}

Calling the AI Assistant

// src/lib/aiClient.ts
export async function askAiAssistant(prompt: string): Promise<string> {
  const apiKey = import.meta.env.VITE_AI_API_KEY;
  const baseUrl = import.meta.env.VITE_AI_API_BASE_URL;

  const response = await fetch(`${baseUrl}/chat`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${apiKey}`,
    },
    body: JSON.stringify({
      model: "your-model-id",
      messages: [{ role: "user", content: prompt }],
    }),
  });

  if (!response.ok) {
    throw new Error("AI request failed");
  }

  const data = await response.json();
  return data.choices?.[0]?.message?.content ?? "";
}

Testing

If tests are configured, you can run them using:

npm test
# or
yarn test

For TypeScript type checking:

npm run lint
npm run typecheck
# or
yarn lint
yarn typecheck

If you use frameworks like Hardhat or Foundry for smart contracts, typical commands might be:

# Hardhat
npx hardhat test
npx hardhat compile

Update this section to reflect the actual scripts defined in your package.json.


Build & Deployment

Building for Production

npm run build
# or
yarn build

This will create an optimized production build (e.g., in dist/ or .next/, depending on your stack).

Deploying

Common deployment options:

  • Static/SPA Frontend:
    • Deploy the built assets to platforms like:
  • Fullstack / API Backend:
    • Deploy to:
      • A Node.js server (e.g., on a VPS or container)
      • Serverless platforms (e.g., AWS Lambda, Vercel Functions)
      • Platform-as-a-Service (e.g., Render, Railway)

Steps (generic example):

  1. Build the project: npm run build.
  2. Configure environment variables on the hosting platform:
    • RPC URL, contract addresses, AI keys, etc.
  3. Upload or link the repository and follow the provider’s deployment instructions.

Document your exact deployment steps here once your pipeline is finalized.


Contribution Guidelines

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch:
    git checkout -b feature/your-feature-name
  3. Make your changes, following the coding standards below.
  4. Run tests to ensure everything passes.
  5. Commit your changes with a clear message:
    git commit -m "Add feature: brief description"
  6. Push to your fork:
    git push origin feature/your-feature-name
  7. Open a Pull Request against the main branch of this repository.

Issue Reporting

If you encounter a bug or want to request a feature:

  • Open an issue on the GitHub Issues page.
  • Include:
    • A clear and descriptive title.
    • Steps to reproduce (for bugs).
    • Expected vs actual behavior.
    • Environment details (OS, browser, Node.js version, network, etc.).
    • Screenshots or logs if relevant.

Coding Standards

  • Use TypeScript and keep types explicit where it improves clarity.
  • Follow the existing coding style and linting rules.
  • Prefer small, focused functions and components.
  • Keep Web3 and AI logic modular (e.g., in lib/ or services/).
  • Write tests for non-trivial logic when possible.

Roadmap (Optional)

You may maintain a roadmap in this section. Example items:

  • Enhanced analytics for course performance.
  • Multi-chain support (e.g., Polygon, Arbitrum).
  • On-chain reputation system for instructors and learners.
  • Advanced AI features (explanations, quizzes, adaptive learning paths).
  • Mobile-friendly layout and PWA support.

License

No license has been explicitly defined for this project yet.

Until a license is added, all rights are reserved by the repository owner, and reuse or redistribution may require explicit permission.

Once you decide on a license, add a LICENSE file (e.g., MIT, Apache 2.0, GPL-3.0) and update this section to reference it.


Contact

For questions, suggestions, or collaboration:


This README is a structured template tailored to the description of the project. You can refine specific commands, environment variables, and code examples to align with your actual implementation.

About

Decentralized Course booking platform with Ai assistance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages