mirror of
https://github.com/th30d4y/OpenLearnX.git
synced 2026-05-26 11:25:49 +00:00
Deploy: Update backend deployment config and frontend environment
This commit is contained in:
@@ -0,0 +1,321 @@
|
||||
# 🚀 OpenLearnX Localhost Deployment - SUCCESS ✅
|
||||
|
||||
**Deployment Date:** 2026-05-12
|
||||
**Status:** All services running and operational
|
||||
|
||||
---
|
||||
|
||||
## 📊 Deployment Overview
|
||||
|
||||
Your OpenLearnX platform is now fully deployed on localhost with all core components running:
|
||||
|
||||
| Component | Status | URL/Port | Details |
|
||||
|-----------|--------|----------|---------|
|
||||
| **MongoDB** | ✅ Running | `localhost:27017` | Database service |
|
||||
| **Anvil** | ✅ Running | `localhost:8545` | Local Ethereum blockchain (Chain ID: 31337) |
|
||||
| **Smart Contract** | ✅ Deployed | Contract Address | `0x5FbDB2315678afecb367f032d93F642f64180aa3` |
|
||||
| **Backend (Flask)** | ✅ Running | `http://localhost:5000` | Python API server |
|
||||
| **Frontend (Next.js)** | ✅ Running | `http://localhost:3000` | React/TypeScript UI |
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Access URLs
|
||||
|
||||
### Frontend Application
|
||||
```
|
||||
http://localhost:3000
|
||||
```
|
||||
- Main web interface
|
||||
- Next.js 16 with TypeScript
|
||||
- TailwindCSS styling
|
||||
- React 19 components
|
||||
|
||||
### Backend API
|
||||
```
|
||||
http://localhost:5000
|
||||
```
|
||||
- Flask API endpoints
|
||||
- Available at `/api/*`
|
||||
- Includes authentication, quizzes, certificates, and more
|
||||
|
||||
### Blockchain (Anvil)
|
||||
```
|
||||
http://127.0.0.1:8545
|
||||
```
|
||||
- JSON-RPC endpoint for web3 interactions
|
||||
- 10 test accounts with 10,000 ETH each
|
||||
- Chain ID: 31337
|
||||
|
||||
### Database
|
||||
```
|
||||
mongodb://localhost:27017/openlearnx
|
||||
```
|
||||
- MongoDB data storage
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Smart Contract Details
|
||||
|
||||
**Contract Type:** ERC-721 NFT (Certificates)
|
||||
**Address:** `0x5FbDB2315678afecb367f032d93F642f64180aa3`
|
||||
**Network:** Anvil Local (Chain ID: 31337)
|
||||
**Language:** Solidity 0.8.33
|
||||
|
||||
### Available Test Accounts (Anvil)
|
||||
|
||||
| Index | Address | Private Key | ETH Balance |
|
||||
|-------|---------|-------------|-------------|
|
||||
| 0 | `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266` | `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` | 10,000 ETH |
|
||||
| 1 | `0x70997970C51812dc3A010C7d01b50e0d17dc79C8` | `0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d` | 10,000 ETH |
|
||||
| 2-9 | ... | ... | 10,000 ETH each |
|
||||
|
||||
**Mnemonic:** `test test test test test test test test test test test junk`
|
||||
|
||||
---
|
||||
|
||||
## 📁 Configuration Files
|
||||
|
||||
### Backend (.env)
|
||||
**Location:** `/home/w4nn4d13/Project/OpenLearnX/backend/.env`
|
||||
|
||||
```env
|
||||
FLASK_ENV=development
|
||||
SECRET_KEY=dev-secret-key-change-in-production
|
||||
MONGODB_URI=mongodb://localhost:27017/openlearnx
|
||||
WEB3_PROVIDER_URL=http://127.0.0.1:8545
|
||||
CONTRACT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
|
||||
DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
||||
JWT_SECRET_KEY=jwt-secret-key
|
||||
```
|
||||
|
||||
### Frontend (.env.local)
|
||||
**Location:** `/home/w4nn4d13/Project/OpenLearnX/frontend/.env.local`
|
||||
|
||||
```env
|
||||
NEXT_PUBLIC_API_URL=http://localhost:5000/api
|
||||
NEXT_PUBLIC_CHAIN_ID=31337
|
||||
NEXT_PUBLIC_CONTRACT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
|
||||
NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 Backend Features Enabled
|
||||
|
||||
✅ **MongoDB Integration** - Connected and operational
|
||||
✅ **Web3/Ethereum** - Anvil blockchain connected
|
||||
✅ **Smart Contracts** - CertificateNFT deployed
|
||||
✅ **JWT Authentication** - Token-based auth configured
|
||||
✅ **Dashboard Analytics** - Comprehensive stats available
|
||||
✅ **Certificate System** - NFT minting ready
|
||||
|
||||
⚠️ **AI Quiz Service** - Requires additional dependencies (numpy)
|
||||
⚠️ **Compiler Service** - Requires Docker integration
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Tech Stack Summary
|
||||
|
||||
| Layer | Technology | Version |
|
||||
|-------|-----------|---------|
|
||||
| **Frontend** | Next.js | 16.1.6 |
|
||||
| **Frontend** | React | 19.x |
|
||||
| **Frontend** | TypeScript | 5.8.3 |
|
||||
| **Frontend** | TailwindCSS | 3.4.17 |
|
||||
| **Backend** | Python | 3.13.12 |
|
||||
| **Backend** | Flask | 3.1.3 |
|
||||
| **Database** | MongoDB | 7.0.14 |
|
||||
| **Cache** | MongoDB | - |
|
||||
| **Blockchain** | Anvil/Foundry | 1.7.1 |
|
||||
| **Smart Contracts** | Solidity | 0.8.33 |
|
||||
| **Web3** | web3.py | Latest |
|
||||
|
||||
---
|
||||
|
||||
## 🎯 API Endpoints (Sample)
|
||||
|
||||
### Authentication
|
||||
- `POST /api/auth/wallet-login` - Web3 wallet login
|
||||
|
||||
### Certificates
|
||||
- `POST /api/certificate/mint` - Mint NFT certificate
|
||||
- `GET /api/certificate/<id>` - Get certificate details
|
||||
- `GET /api/certificate/verify/<code>` - Verify certificate
|
||||
|
||||
### Dashboard
|
||||
- `GET /api/dashboard/comprehensive-stats` - Dashboard analytics
|
||||
- `GET /api/health` - Health check
|
||||
|
||||
### Courses & Quizzes
|
||||
- `GET /api/courses` - List courses
|
||||
- `GET /api/quizzes` - List quizzes
|
||||
- Additional endpoints in routes/
|
||||
|
||||
---
|
||||
|
||||
## 🚀 How to Use
|
||||
|
||||
### Test the Frontend
|
||||
1. Open http://localhost:3000 in your browser
|
||||
2. Connect MetaMask or use a web3 provider
|
||||
3. Use one of the test account private keys to sign in
|
||||
|
||||
### Test the API
|
||||
```bash
|
||||
# Health check
|
||||
curl http://localhost:5000/api/health
|
||||
|
||||
# Dashboard stats
|
||||
curl http://localhost:5000/api/dashboard/comprehensive-stats
|
||||
```
|
||||
|
||||
### Test Smart Contract Interaction
|
||||
```bash
|
||||
# Check contract details
|
||||
curl -X POST http://127.0.0.1:8545 \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc":"2.0","method":"eth_getCode","params":["0x5FbDB2315678afecb367f032d93F642f64180aa3","latest"],"id":1}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛑 Stopping Services
|
||||
|
||||
### Stop All Services Gracefully
|
||||
```bash
|
||||
# Backend (if running in terminal)
|
||||
# Press Ctrl+C
|
||||
|
||||
# Frontend (if running in terminal)
|
||||
# Press Ctrl+C
|
||||
|
||||
# Anvil (if running in terminal)
|
||||
# Press Ctrl+C
|
||||
|
||||
# MongoDB
|
||||
killall mongod
|
||||
|
||||
# Or stop individual processes
|
||||
pkill -f "python3.*main.py"
|
||||
pkill -f "next dev"
|
||||
pkill anvil
|
||||
killall mongod
|
||||
```
|
||||
|
||||
### Restart Services
|
||||
|
||||
#### Terminal 1: MongoDB
|
||||
```bash
|
||||
mongod --dbpath ~/mongodata --logpath /tmp/mongodb.log
|
||||
```
|
||||
|
||||
#### Terminal 2: Anvil
|
||||
```bash
|
||||
export PATH="/home/w4nn4d13/.foundry/bin:$PATH"
|
||||
anvil
|
||||
```
|
||||
|
||||
#### Terminal 3: Backend
|
||||
```bash
|
||||
cd /home/w4nn4d13/Project/OpenLearnX/backend
|
||||
source venv/bin/activate
|
||||
python3 main.py
|
||||
```
|
||||
|
||||
#### Terminal 4: Frontend
|
||||
```bash
|
||||
cd /home/w4nn4d13/Project/OpenLearnX/frontend
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Testing Checklist
|
||||
|
||||
- [ ] Access http://localhost:3000 - Frontend loads
|
||||
- [ ] Backend API responds to requests
|
||||
- [ ] MongoDB stores data properly
|
||||
- [ ] Anvil blockchain accepts transactions
|
||||
- [ ] Smart contract is accessible
|
||||
- [ ] MetaMask can connect to Anvil (Chain ID: 31337)
|
||||
- [ ] Certificate minting works
|
||||
- [ ] Dashboard displays analytics
|
||||
|
||||
---
|
||||
|
||||
## 📝 Troubleshooting
|
||||
|
||||
### Port Already in Use
|
||||
```bash
|
||||
# Find process on port
|
||||
lsof -i :5000 # Backend
|
||||
lsof -i :3000 # Frontend
|
||||
lsof -i :8545 # Anvil
|
||||
lsof -i :27017 # MongoDB
|
||||
|
||||
# Kill process
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
### MongoDB Connection Error
|
||||
```bash
|
||||
# Restart MongoDB
|
||||
pkill mongod
|
||||
rm -rf ~/mongodata/mongod.lock
|
||||
mongod --dbpath ~/mongodata
|
||||
```
|
||||
|
||||
### Frontend Build Issues
|
||||
```bash
|
||||
cd frontend
|
||||
rm -rf .next node_modules pnpm-lock.yaml
|
||||
pnpm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
### Backend Import Errors
|
||||
```bash
|
||||
cd backend
|
||||
source venv/bin/activate
|
||||
pip install -r ../requirements.txt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
- **Project Docs:** See DOCUMENTATION.md
|
||||
- **Architecture:** See ARCHITECTURE.md
|
||||
- **Quick Start:** See QUICK_START.md
|
||||
- **Deployment:** See DEPLOYMENT_COMPLETE.md
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Security Notes
|
||||
|
||||
⚠️ **IMPORTANT FOR PRODUCTION:**
|
||||
- These are development credentials with default secrets
|
||||
- NEVER use these in production environments
|
||||
- Change `SECRET_KEY` and `JWT_SECRET_KEY`
|
||||
- Update MetaMask networks with real RPC endpoints
|
||||
- Configure proper environment variables
|
||||
- Use a real database (not localhost)
|
||||
- Enable HTTPS/SSL
|
||||
|
||||
---
|
||||
|
||||
## ✅ Deployment Complete!
|
||||
|
||||
Your OpenLearnX platform is now running on localhost. You can:
|
||||
- Develop and test features
|
||||
- Make API calls from applications
|
||||
- Deploy smart contracts
|
||||
- Create and manage certificates
|
||||
- Test the full application flow
|
||||
|
||||
**Happy coding! 🎉**
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** 2026-05-12 19:00 UTC+5:30
|
||||
**Deployment Log:** See terminal outputs above
|
||||
Reference in New Issue
Block a user