Skip to content

Commit 72d8d00

Browse files
committed
doc: added full instructions for local deployment
1 parent 2b5e5c3 commit 72d8d00

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

local_setup.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# INSTRUCTIONS FOR DEPLOYING TRANSLATION SERVICES LOCALLY
2+
3+
## Fork Repositories
4+
- Fork llm-experiment-microservice-jack repo: https://github.com/CMU-313/llm-experiment-microservice-jack
5+
- Fork nodebb-fall-2025-jack repo: https://github.com/CMU-313/nodebb-fall-2025-jack
6+
7+
Clone the llm-experiment-microservice-jack repo and open it in a DevContainer.
8+
9+
---
10+
11+
## STEP 1: In llm-experiment-microservice-jack repo
12+
13+
1. Run:
14+
```bash
15+
uv init
16+
uv add -r requirements.txt
17+
```
18+
19+
2. Install Ollama:
20+
```bash
21+
curl -fsSL https://ollama.com/install.sh | sh
22+
```
23+
24+
3. Restart your terminal and verify:
25+
```bash
26+
ollama --version
27+
```
28+
29+
4. Start the Ollama background server (keep this window open):
30+
```bash
31+
ollama serve
32+
```
33+
34+
5. In a new terminal, pull the model and start Flask:
35+
```bash
36+
ollama pull qwen3:0.6b
37+
uv run flask run
38+
```
39+
40+
6. Test your translator service by visiting:
41+
```
42+
http://127.0.0.1:5000/?content=Dies%20ist%20eine%20Nachricht%20auf%20Deutsch
43+
```
44+
45+
Expected output:
46+
```json
47+
{"is_english": false, "translated_content": "This is a German message"}
48+
```
49+
50+
### LEAVE BOTH THE FLASK SERVER AND OLLAMA RUNNING
51+
52+
---
53+
54+
Clone nodebb-fall-2025-jack and open it in a DevContainer.
55+
56+
## STEP 2: In nodebb-fall-2025-jack repo
57+
58+
1. Set the environment variable:
59+
- If **not** inside a DevContainer:
60+
```bash
61+
export TRANSLATOR_API_BASE="http://127.0.0.1:5000"
62+
```
63+
- If **inside** a DevContainer:
64+
```bash
65+
export TRANSLATOR_API_BASE="http://host.docker.internal:5000"
66+
```
67+
68+
2. Build NodeBB:
69+
```bash
70+
./nodebb build
71+
```
72+
73+
3. Start NodeBB:
74+
```bash
75+
./nodebb start
76+
```
77+
78+
---
79+
80+
## Verification Steps
81+
82+
- Create a **new post** (old posts won’t have `isEnglish` fields) with non-English content such as:
83+
```
84+
นี่คือข้อความภาษาไทย
85+
```
86+
87+
- If your microservice is running, you will see a **blue button** labeled:
88+
> “Click here to view the translated message.”
89+
90+
- Clicking the button toggles visibility of the translated text.
91+
92+
93+
94+
### Expected Results
95+
96+
- Posts with `isEnglish: true` → translation button still shows up
97+
- Posts with `isEnglish: false` → button appears and shows the translated message when clicked
98+
99+
<img width="888" height="191" alt="image" src="https://github.com/user-attachments/assets/9d226a1c-8e49-480c-87cd-692f73e552c7" />
100+
<img width="914" height="164" alt="image" src="https://github.com/user-attachments/assets/09216998-bd4b-4eb3-8a09-02ec4be39cbf" />
101+
102+
103+
## Troubleshooting
104+
105+
### Button not showing?
106+
107+
**Check 1: Did you build?**
108+
```bash
109+
./nodebb build
110+
```
111+
112+
**Check 2: Is the post NEW?**
113+
- Delete old test posts
114+
- Create a fresh post after building
115+
116+
**Check 3: Check the database**
117+
```bash
118+
# Redis
119+
redis-cli
120+
HGETALL post:1 # Check if isEnglish and translatedContent exist
121+
```
122+
123+
**Check 4: Check browser console**
124+
- Open DevTools (F12)
125+
- Look for JavaScript errors
126+
- Check if topic.js loaded
127+
128+
**Check 5: Check if translator is being called**
129+
```bash
130+
# Look for translation logs in NodeBB output
131+
tail -f logs/output.log
132+
```
133+
134+
**Check 6: Check if you set the right environment**
135+
```bash
136+
#if not in devcontainer: http://127.0.0.1:5000, else : http://host.docker.internal:5000
137+
echo $TRANSLATOR_API_BASE
138+
```
139+
140+
### Hard refresh
141+
If templates are cached:
142+
```bash
143+
# Clear browser cache or hard refresh
144+
Ctrl+Shift+R (Windows/Linux)
145+
Cmd+Shift+R (Mac)
146+
```
147+
148+
## Expected Flow
149+
150+
1. User creates post with "Hola mundo"
151+
2. `src/posts/create.js` calls `translator.translate()`
152+
3. Translator calls your microservice
153+
4. Stores `isEnglish: false` and `translatedContent: "Hello world"`
154+
5. Template checks `{{{if !posts.isEnglish }}}`
155+
6. Button appears
156+
7. Click → translation shows

0 commit comments

Comments
 (0)