Skip to content

devbugra/algocredit

Repository files navigation

AlgoCredit - Web3 Security Firewall

License: MIT Algorand TypeScript Python

Enterprise-Grade Security Platform for the Algorand Ecosystem

AlgoCredit is developing a compliance scoring library to help web3 startups fight against fraudulent low-credit users with AI-driven credit risk analysis.

πŸš€ Features

πŸ›‘οΈ Security & Compliance

  • AI-Powered Credit Scoring - 95% accuracy in risk assessment
  • Real-time Threat Detection - MEV protection, flash loan exploit detection
  • Enterprise API Security - SOC 2 compliant with tiered access
  • Smart Contract Scanning - Automated vulnerability detection
  • Compliance Monitoring - Automated regulatory compliance tools

πŸ”§ Developer Tools

  • Easy Integration - Simple APIs for developers
  • Security Dashboard - Real-time monitoring and analytics
  • AI Risk Calculator - Advanced wallet risk assessment
  • Rate Limiting - Adaptive rate limiting and DDoS protection
  • Webhook Notifications - Real-time security alerts

🌐 Algorand Native

  • TestNet Ready - Fully functional on Algorand TestNet
  • Smart Contracts - Native Algorand smart contract integration
  • Wallet Integration - Seamless wallet connection and management
  • Foundation Ready - Built to Algorand Foundation standards

πŸ“‹ Table of Contents

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Python 3.12+
  • Algorand TestNet account
  • Git

1. Clone the Repository

git clone https://github.com/suarksoft/algocredit.git
cd algocredit

2. Start Backend

cd algocredit-backend
source venv/bin/activate
uvicorn main:app --host 0.0.0.0 --port 8001 --reload

3. Start Frontend

cd algocredit-frontend
npm install
npm run dev

4. Access the Platform

πŸ› οΈ Installation

Backend Setup

cd algocredit-backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Frontend Setup

cd algocredit-frontend
npm install

Smart Contracts Setup

cd algo-contract
npm install

βš™οΈ Configuration

Environment Variables

Create .env files in respective directories:

Backend (.env)

AlgoCredit Backend Environment Variables

Algorand Configuration

ALGORAND_NODE_URL=https://testnet-api.algonode.cloud ALGORAND_INDEXER_URL=https://testnet-idx.algonode.cloud ALGORAND_NETWORK=testnet

Admin Wallet (for smart contract deployment)

ADMIN_PRIVATE_KEY=your_algorand_private_key_here ADMIN_ADDRESS=your_algorand_address_here

Smart Contracts

LOAN_POOL_CONTRACT_ID=746537075 CREDIT_TOKEN_ASA_ID=your_token_asa_id

Security

JWT_SECRET_KEY=your_super_secret_jwt_key_here JWT_ALGORITHM=HS256 JWT_EXPIRE_MINUTES=60

External APIs

OPENWEATHER_API_KEY=your_api_key_if_needed COINGECKO_API_KEY=your_api_key_if_needed

Development Settings

DEBUG=true LOG_LEVEL=info

CORS Settings

ALLOWED_ORIGINS=http://localhost:3000,https://algocredit.vercel.app

ALGORAND_NETWORK=testnet
DATABASE_URL=sqlite:///./algocredit.db
REDIS_URL=redis://localhost:6379
API_SECRET_KEY=your-secret-key

Frontend (.env.local)

API Configuration

NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 NEXT_PUBLIC_API_BASE_URL_ALT=http://localhost:8000

Algorand Network Configuration

NEXT_PUBLIC_ALGORAND_NETWORK=testnet NEXT_PUBLIC_ALGORAND_NODE_URL=https://testnet-api.algonode.cloud NEXT_PUBLIC_ALGORAND_INDEXER_URL=https://testnet-idx.algonode.cloud NEXT_PUBLIC_ALGORAND_CHAIN_ID=416002

Pera Wallet Configuration

NEXT_PUBLIC_PERAWALLET_CHAIN_ID=416002

Application Configuration

NEXT_PUBLIC_APP_NAME=AlgoCredit NEXT_PUBLIC_APP_VERSION=1.0.0 NEXT_PUBLIC_APP_ENVIRONMENT=development

Feature Flags

NEXT_PUBLIC_ENABLE_BLOCKCHAIN=true NEXT_PUBLIC_ENABLE_AI_SCORING=true NEXT_PUBLIC_ENABLE_CACHING=true

Performance Configuration

NEXT_PUBLIC_CACHE_TTL=30000 NEXT_PUBLIC_API_TIMEOUT=10000

Demo Configuration

NEXT_PUBLIC_DEMO_MODE=false NEXT_PUBLIC_MOCK_DATA=false

NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_ALGORAND_NETWORK=testnet

πŸ“š API Documentation

Core Endpoints

Security & Risk Analysis

# AI Risk Analysis
POST /api/v1/credit/ai-risk-analysis
{
  "wallet_address": "ALGO123...456"
}

# Threat Detection
POST /api/v1/security/validate-transaction
{
  "wallet_address": "ALGO123...456",
  "transaction_data": {...},
  "security_level": "enterprise"
}

API Key Management

# Generate API Key
POST /api/v1/security/generate-key
{
  "wallet_address": "ALGO123...456",
  "tier": "pro"
}

# Get Wallet API Key
GET /api/v1/security/wallet-key/{wallet_address}

Authentication

All protected endpoints require API key authentication:

Authorization: Bearer ac_live_your_api_key_here

🎨 Frontend Development

Tech Stack

  • Framework: Next.js 15
  • Styling: Tailwind CSS
  • State Management: Zustand
  • Icons: Heroicons
  • Wallet Integration: Algorand WalletConnect

Key Components

  • AIRiskCalculator - AI-powered risk assessment
  • SecurityDashboard - Real-time security monitoring
  • WalletConnect - Algorand wallet integration
  • AnimatedTerminal - Code demonstration component

Development Commands

npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint

πŸ”§ Backend Development

Tech Stack

  • Framework: FastAPI
  • Database: SQLite (with Alembic migrations)
  • AI/ML: scikit-learn, pandas
  • Caching: Redis
  • Security: Custom middleware, rate limiting

Key Services

  • credit_scoring_service - AI credit scoring
  • algorand_service - Blockchain integration
  • api_key_manager - Security key management
  • threat_detector - Real-time threat detection

Development Commands

python main.py                    # Start development server
uvicorn main:app --reload         # Start with auto-reload
alembic upgrade head              # Run database migrations
python -m pytest tests/           # Run tests

πŸ”— Smart Contracts

Algorand Smart Contracts

  • Contract: AlgoCreditPlatformTestNet
  • Language: Puya (Python-like)
  • Network: Algorand TestNet
  • Features: API key management, security validation

Deployment

cd algo-contract/projects/algo-contract
algokit deploy

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Code Style

  • Frontend: ESLint + Prettier
  • Backend: Black + isort
  • TypeScript: Strict mode enabled

πŸ“Š Project Structure

algocredit/
β”œβ”€β”€ algocredit-frontend/          # Next.js frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                  # App router pages
β”‚   β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”‚   β”œβ”€β”€ lib/                  # Utilities and API clients
β”‚   β”‚   └── stores/               # Zustand state management
β”œβ”€β”€ algocredit-backend/           # FastAPI backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/                  # API routes
β”‚   β”‚   β”œβ”€β”€ models/               # Database models
β”‚   β”‚   β”œβ”€β”€ services/             # Business logic
β”‚   β”‚   └── security/             # Security middleware
β”œβ”€β”€ algo-contract/                # Algorand smart contracts
β”‚   └── projects/algo-contract/
β”‚       └── smart_contracts/      # Puya contracts
└── docs/                         # Documentation

πŸš€ Deployment

Production Deployment

  1. Backend: Deploy to cloud provider (AWS, GCP, Azure)
  2. Frontend: Deploy to Vercel, Netlify, or similar
  3. Database: Set up production database
  4. Redis: Configure Redis for caching
  5. Smart Contracts: Deploy to Algorand MainNet

Docker Support

docker-compose up -d

πŸ“ˆ Roadmap

  • MainNet deployment
  • Additional blockchain support
  • Advanced ML models
  • Mobile app
  • Enterprise features
  • API marketplace

πŸ› Troubleshooting

Common Issues

Backend won't start:

# Check Redis connection
redis-cli ping

# Check Python dependencies
pip install -r requirements.txt

Frontend build errors:

# Clear Next.js cache
rm -rf .next
npm run build

Wallet connection issues:

  • Ensure you're on Algorand TestNet
  • Check wallet permissions
  • Verify network configuration

πŸ“ž Support

πŸ“„ License

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

πŸ™ Acknowledgments


Built with ❀️ for the Algorand ecosystem

Website β€’ Documentation β€’ GitHub

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors