Skip to content

Commit 9a8a929

Browse files
refactor: replace simulator with real Docker terminals
- Remove entire simulator engine (~20k lines) - Add RealTerminal with WebSocket connection to Docker backend - Add keystroke-based lesson validation (expectedKeys) - New stores: keyHistoryStore, lessonProgressStore, userStore - Update /practice and /learn pages for real terminals - Update homepage messaging for real terminal experience - Update DEPLOY.md with production nginx config - Add trust proxy to backend for rate limiting behind nginx Amp-Thread-ID: https://ampcode.com/threads/T-019bbe1a-e59d-7016-994a-677cbbbc8521 Co-authored-by: Amp <amp@ampcode.com>
1 parent 5c47016 commit 9a8a929

65 files changed

Lines changed: 2899 additions & 20897 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Frontend Configuration
2+
# Copy to .env.local and adjust as needed
3+
4+
# WebSocket URL for terminal backend
5+
# For local development: ws://localhost:3001/ws
6+
# For production: wss://api.vimux.dev/ws
7+
NEXT_PUBLIC_WS_URL=wss://api.vimux.dev/ws

DEPLOY.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ npm run build
8888
Create environment file:
8989

9090
```bash
91-
cp .env.example .env
92-
# Edit .env with your domain
91+
cat > .env << 'EOF'
92+
PORT=3001
93+
MAX_SESSIONS=15
94+
SESSION_TIMEOUT=1800000
95+
IDLE_TIMEOUT=300000
96+
ALLOWED_ORIGINS=https://vimux.dev,https://www.vimux.dev
97+
EOF
9398
```
9499

95100
### Nginx Configuration
@@ -98,7 +103,6 @@ As root, create `/etc/nginx/sites-available/vimux`:
98103

99104
```nginx
100105
server {
101-
listen 80;
102106
server_name api.yourdomain.com;
103107
104108
location /ws {
@@ -107,12 +111,36 @@ server {
107111
proxy_set_header Upgrade $http_upgrade;
108112
proxy_set_header Connection "upgrade";
109113
proxy_set_header Host $host;
114+
proxy_set_header X-Real-IP $remote_addr;
115+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
116+
proxy_set_header X-Forwarded-Proto $scheme;
110117
proxy_read_timeout 3600s;
118+
proxy_send_timeout 3600s;
111119
}
112120
113121
location /health {
114122
proxy_pass http://127.0.0.1:3001;
123+
proxy_set_header X-Real-IP $remote_addr;
124+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
115125
}
126+
127+
location /stats {
128+
proxy_pass http://127.0.0.1:3001;
129+
proxy_set_header X-Real-IP $remote_addr;
130+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
131+
}
132+
133+
listen 443 ssl;
134+
ssl_certificate /etc/letsencrypt/live/api.yourdomain.com/fullchain.pem;
135+
ssl_certificate_key /etc/letsencrypt/live/api.yourdomain.com/privkey.pem;
136+
include /etc/letsencrypt/options-ssl-nginx.conf;
137+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
138+
}
139+
140+
server {
141+
listen 80;
142+
server_name api.yourdomain.com;
143+
return 301 https://$host$request_uri;
116144
}
117145
```
118146

@@ -140,11 +168,11 @@ Requires=docker.service
140168
Type=simple
141169
User=termuser
142170
WorkingDirectory=/opt/vimux/backend
171+
EnvironmentFile=/opt/vimux/backend/.env
143172
ExecStart=/usr/bin/node dist/server.js
144173
Restart=always
174+
RestartSec=5
145175
Environment=NODE_ENV=production
146-
Environment=PORT=3001
147-
Environment=ALLOWED_ORIGINS=https://vimux.dev
148176

149177
[Install]
150178
WantedBy=multi-user.target

backend/.env.example

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Terminal Learning Backend Configuration
1+
# Vimux Backend Configuration
22
# Copy to .env and adjust as needed
33

44
# Server port
@@ -7,11 +7,13 @@ PORT=3001
77
# Max concurrent terminal sessions
88
MAX_SESSIONS=15
99

10-
# Session timeout (30 min in ms)
10+
# Session timeout in ms (default: 30 min)
1111
SESSION_TIMEOUT=1800000
1212

13-
# Idle timeout (5 min in ms)
13+
# Idle timeout in ms (default: 5 min)
1414
IDLE_TIMEOUT=300000
1515

1616
# Allowed origins for CORS (comma-separated)
17-
ALLOWED_ORIGINS=https://vimux.dev,https://www.vimux.dev,http://localhost:3000
17+
# Production: https://vimux.dev,https://www.vimux.dev
18+
# Development: http://localhost:3000
19+
ALLOWED_ORIGINS=http://localhost:3000

backend/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
.env
4+
.env.local
5+
*.log

0 commit comments

Comments
 (0)