A blockchain-integrated social scoring system built with Django (backend), React (frontend), and Ethereum smart contracts deployed on polkadot chains.
- Python 3.11+
- Node.js 18+ and npm
- SQLite (included with Python)
- Git
git clone https://github.com/mirukibs/contradots-hackathon-project.git
cd contradots-hackathon-project# Create and activate a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r infrastructure-requirements.txt
pip install web3# Run migrations to create database tables
python3 manage.py migrate
# Create a superuser (admin account)
python3 manage.py createsuperuserCreate a .env file in the project root:
# Blockchain Configuration
WEB3_PROVIDER=https://testnet-passet-hub-eth-rpc.polkadot.io
CONTRACT_ADDRESS=0x7e50f3D523176C696AEe69A1245b12EBAE0a17dd
PRIVATE_KEY=your_private_key_here
# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=Truepython3 manage.py runserverThe backend API will be available at http://localhost:8000
Open a new terminal window:
cd src/viteReact
# Install dependencies
npm install
# Start development server
npm run devThe frontend will be available at http://localhost:5173
- Frontend: Open
http://localhost:5173in your browser - API Documentation: Visit
http://localhost:8000/api/for API endpoints - Admin Panel: Access
http://localhost:8000/adminwith your superuser credentials
- Activity Management: Create and manage activities (requires LEAD role)
- Action Submission: Submit actions for activities with blockchain proof
- Proof Validation: Validate submitted actions (LEAD only)
- Leaderboard: View reputation scores and rankings
- Blockchain Integration: All activities and actions are recorded on the blockchain
# Backend tests
pytest
# With coverage
pytest --cov=src
# Run specific tests
pytest tests/domain/
pytest tests/application/contradots-hackathon-project/
βββ src/
β βββ application/ # Application layer (use cases, DTOs)
β βββ domain/ # Domain models and business logic
β βββ infrastructure/ # Infrastructure (database, blockchain)
β βββ presentation/ # API views and serializers
β βββ viteReact/ # React frontend
βββ tests/ # Test suite
βββ contracts/ # Solidity smart contracts
βββ manage.py # Django management script
βββ db.sqlite3 # SQLite database
POST /api/v1/auth/register/- Register new userPOST /api/v1/auth/login/- LoginPOST /api/v1/auth/logout/- Logout
GET /api/v1/activity_action/activities/- List active activitiesPOST /api/v1/activity_action/activities/create/- Create activity (LEAD)GET /api/v1/activity_action/activities/{id}/- Get activity detailsPOST /api/v1/activity_action/activities/deactivate/- Deactivate activity (LEAD)
POST /api/v1/activity_action/actions/submit/- Submit actionGET /api/v1/activity_action/actions/my-actions/- Get my actionsGET /api/v1/activity_action/actions/pending/- Get pending validations (LEAD)POST /api/v1/activity_action/actions/validate/- Validate proof (LEAD)
GET /api/v1/leaderboard/- Get leaderboard
The system integrates with an Ethereum-compatible blockchain:
- Smart Contract: ActivityActionTracker
- Network: Polkadot Asset Hub Testnet
- Features:
- Immutable activity records
- Tamper-proof action submissions
- On-chain proof validation
- Blockchain action IDs stored in database
The API supports both UUID and blockchain action ID formats:
// Using UUID
{
"actionId": "550e8400-e29b-41d4-a716-446655440000",
"isValid": true
}
// Using blockchain action ID (integer)
{
"actionId": 123,
"isValid": true
}Database locked error:
# Stop all Django processes and try again
pkill -f runserver
python3 manage.py runserverPort already in use:
# Use a different port
python3 manage.py runserver 8001Port 5173 in use:
# Edit vite.config.js to change port or kill the process
npx kill-port 5173
npm run devModule not found errors:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install- API Documentation - Detailed API reference
- Developer Package README - Architecture details
- Blockchain Configuration
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is part of the Polkadot Hackathon.
- Repository: https://github.com/mirukibs/contradots-hackathon-project
- Issues: https://github.com/mirukibs/contradots-hackathon-project/issues
# Backend
python3 manage.py runserver # Start server
python3 manage.py migrate # Apply migrations
python3 manage.py makemigrations # Create migrations
python3 manage.py createsuperuser # Create admin user
pytest # Run tests
# Frontend
npm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
# Both
# Terminal 1: Backend
python3 manage.py runserver
# Terminal 2: Frontend
cd src/viteReact && npm run devBuilt with β€οΈ for the Polkadot Hackathon
