-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·127 lines (109 loc) · 3.48 KB
/
setup.sh
File metadata and controls
executable file
·127 lines (109 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# Web3 Student Lab - Quick Start Script
# This script helps you set up and run the full stack application
set -e # Exit on error
echo "🚀 Web3 Student Lab - Quick Start"
echo "=================================="
echo ""
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if we're in the right directory
if [ ! -f "package.json" ] || [ ! -d "frontend" ] || [ ! -d "backend" ]; then
echo "❌ Error: Please run this script from the project root directory"
exit 1
fi
echo -e "${BLUE}Step 1: Setting up Backend${NC}"
echo "-----------------------------------"
cd backend
# Check if .env exists
if [ ! -f ".env" ]; then
echo -e "${YELLOW}Creating backend .env file...${NC}"
cp .env.example .env 2>/dev/null || echo "PORT=8080
DATABASE_URL=\"postgresql://localhost:5432/web3lab?user=postgres&password=postgres\"
JWT_SECRET=your-secret-key-change-in-production
NODE_ENV=development" > .env
echo "✅ Created .env file - Please update DATABASE_URL and JWT_SECRET"
else
echo "✅ Backend .env exists"
fi
# Install backend dependencies
echo -e "${GREEN}Installing backend dependencies...${NC}"
npm install
# Setup database
echo -e "${YELLOW}Setting up database...${NC}"
if command -v npx &> /dev/null; then
npx prisma generate
echo "✅ Prisma client generated"
# Ask user if they want to run migrations
read -p "Do you want to run database migrations? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
npx prisma migrate dev --name init
echo "✅ Database migrations completed"
fi
else
echo "⚠️ npx not found, skipping Prisma setup"
fi
cd ..
echo ""
echo -e "${BLUE}Step 2: Setting up Frontend${NC}"
echo "------------------------------------"
cd frontend
# Check if .env.local exists
if [ ! -f ".env.local" ]; then
echo -e "${YELLOW}Creating frontend .env.local file...${NC}"
cp .env.local.example .env.local 2>/dev/null || echo "NEXT_PUBLIC_API_URL=http://localhost:8080/api
NEXT_PUBLIC_SOROBAN_RPC_URL=https://soroban-test.stellar.org:443
NEXT_PUBLIC_CERTIFICATE_CONTRACT_ID=" > .env.local
echo "✅ Created .env.local file"
else
echo "✅ Frontend .env.local exists"
fi
# Install frontend dependencies
echo -e "${GREEN}Installing frontend dependencies...${NC}"
npm install
cd ..
echo ""
echo -e "${BLUE}Step 3: Build Check${NC}"
echo "-------------------"
# Build frontend
echo -e "${YELLOW}Building frontend...${NC}"
cd frontend
npm run build
echo "✅ Frontend build successful"
cd ..
echo ""
echo -e "${GREEN}✅ Setup Complete!${NC}"
echo ""
echo "=================================="
echo "📋 Next Steps:"
echo "=================================="
echo ""
echo "1. Update environment files:"
echo " - backend/.env: Set DATABASE_URL and JWT_SECRET"
echo " - frontend/.env.local: Verify API URL"
echo ""
echo "2. Start the backend server:"
echo " cd backend"
echo " npm run dev"
echo ""
echo "3. In a new terminal, start the frontend:"
echo " cd frontend"
echo " npm run dev"
echo ""
echo "4. Open your browser:"
echo " - Frontend: http://localhost:3000"
echo " - Backend API: http://localhost:8080"
echo " - API Health: http://localhost:8080/health"
echo ""
echo -e "${YELLOW}💡 Tips:${NC}"
echo "- Make sure PostgreSQL is running before starting the backend"
echo "- Create a test account via /auth/register"
echo "- Browse courses at /courses"
echo "- Verify certificates at /verify"
echo ""
echo "🎉 Happy learning with Web3 Student Lab!"
echo ""