Skip to content

Louay012/parkchain

Repository files navigation

πŸš— ParkChain - Blockchain Parking Management System

ParkChain is a decentralized application (dApp) for managing parking spots using blockchain technology. It features tokenization of parking spaces, automated reservations, immutable history tracking, and automatic payment processing.

✨ Features

  • 🎫 Smart Contracts (Solidity): ERC721-based parking spot tokenization with reservation and payment management
  • βš™οΈ Backend (Node.js/TypeScript): RESTful API for parking management and QR code generation
  • 🎨 Frontend (React + Tailwind CSS): Modern, responsive UI for booking and managing parking spots
  • πŸ“± QR Code Generator: Generate unique QR codes for parking tokens and reservations
  • πŸ”„ Automated Deployment: GitHub Actions workflow for CI/CD
  • πŸ“œ Immutable History: All transactions recorded on blockchain
  • πŸ’° Automatic Payments: Smart contract-based payment processing

πŸ—οΈ Architecture

parkchain/
β”œβ”€β”€ contracts/              # Solidity smart contracts
β”‚   β”œβ”€β”€ ParkingToken.sol   # ERC721 token for parking spots
β”‚   β”œβ”€β”€ ParkingReservation.sol  # Reservation management
β”‚   └── PaymentProcessor.sol    # Payment handling
β”œβ”€β”€ backend/               # Node.js backend server
β”‚   β”œβ”€β”€ server.ts         # Express server
β”‚   └── routes/           # API routes
β”‚       β”œβ”€β”€ parking.ts    # Parking management endpoints
β”‚       └── qr.ts         # QR code generation
β”œβ”€β”€ frontend/             # React frontend
β”‚   └── src/
β”‚       β”œβ”€β”€ components/   # React components
β”‚       β”œβ”€β”€ pages/        # Page components
β”‚       └── utils/        # Utility functions
β”œβ”€β”€ scripts/              # Deployment scripts
β”‚   └── deploy.ts         # Contract deployment
β”œβ”€β”€ test/                 # Contract tests
└── .github/workflows/    # CI/CD workflows

πŸš€ Getting Started

Prerequisites

  • Node.js (v20 or higher)
  • npm or yarn
  • MetaMask or another Web3 wallet
  • Hardhat

Installation

  1. Clone the repository
git clone https://github.com/Louay012/parkchain.git
cd parkchain
  1. Install root dependencies
npm install --legacy-peer-deps
  1. Install frontend dependencies
cd frontend
npm install

πŸ”§ Configuration

Create a .env file in the root directory:

# Network Configuration
NETWORK=localhost
RPC_URL=http://127.0.0.1:8545

# Contract Addresses (will be populated after deployment)
PARKING_TOKEN_ADDRESS=
PARKING_RESERVATION_ADDRESS=
PAYMENT_PROCESSOR_ADDRESS=

# Backend Configuration
PORT=3001

# Private key for deployment (use test accounts only!)
PRIVATE_KEY=

πŸ“¦ Compile Smart Contracts

npx hardhat compile

πŸ§ͺ Run Tests

npx hardhat test

πŸš€ Deploy Contracts

Start a local Hardhat node:

npx hardhat node

In another terminal, deploy contracts:

npx hardhat run scripts/deploy.ts --network ganache

πŸ–₯️ Start Backend Server

npm run backend

The backend will run on http://localhost:3001

🎨 Start Frontend

cd frontend
npm run dev

The frontend will run on http://localhost:3000

πŸ“ Smart Contracts

ParkingToken.sol

ERC721 token representing parking spot ownership with metadata including:

  • Location
  • Spot number
  • Price per hour
  • Availability status

ParkingReservation.sol

Manages parking reservations with features:

  • Create reservations with time slots
  • Automatic payment processing
  • Reservation cancellation with refunds
  • Immutable reservation history

PaymentProcessor.sol

Handles payments with:

  • Platform fee collection
  • Payment history tracking
  • Automatic fund distribution
  • Secure payment processing

πŸ”Œ API Endpoints

Parking Management

  • GET /api/parking/spots - Get all parking spots
  • GET /api/parking/spots/:tokenId - Get specific parking spot
  • POST /api/parking/reservations - Create a reservation
  • GET /api/parking/reservations/:address - Get user reservations

QR Code Generation

  • POST /api/qr/generate - Generate QR code for parking token
  • POST /api/qr/reservation - Generate QR code for reservation

πŸ§‘β€πŸ’» Development

Project Scripts

# Compile contracts
npm run compile

# Run tests
npm run test

# Deploy contracts
npm run deploy

# Start backend
npm run backend

# Start frontend (in frontend directory)
cd frontend && npm run dev

# Build frontend
cd frontend && npm run build

🌐 Branch Structure

  • main - Production-ready code
  • develop - Development branch
  • feature/* - Feature branches
  • hotfix/* - Hotfix branches

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License.

πŸ‘₯ Authors

  • Louay012

πŸ™ Acknowledgments

  • OpenZeppelin for secure smart contract libraries
  • Hardhat for Ethereum development environment
  • React and Tailwind CSS for the frontend
  • Express.js for the backend API

πŸ“ž Support

For support, please open an issue in the GitHub repository.


Made with ❀️ using Blockchain Technology

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors