DasbootU9607 commited on
Commit
0001f12
·
1 Parent(s): 0dcbc18

feat: initial clean commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +18 -0
  2. .env.example +44 -0
  3. .github/workflows/deploy-pages.yml +60 -0
  4. .gitignore +28 -0
  5. COMMERCIAL_WEBSITE_SITEMAP_AND_PAGE_SPEC.md +866 -0
  6. CURRENT_PROJECT_PRD.md +1104 -0
  7. DEPLOY_HUGGINGFACE.md +48 -0
  8. DEPLOY_RENDER.md +82 -0
  9. DEPLOY_RENDER_FREE.md +42 -0
  10. Dockerfile +45 -0
  11. HUGGINGFACE_SPACE_README.md +12 -0
  12. README.md +141 -0
  13. U2INVEST_MASTER_REBUILD_PROMPT.md +869 -0
  14. UI_REDESIGN_AGENT_PROMPT.md +187 -0
  15. USER_GUIDE.md +108 -0
  16. _profile_repo +1 -0
  17. _remote_repo +1 -0
  18. agent_graph.py +92 -0
  19. contact/116668-708909865_medium.mp4 +3 -0
  20. contact/210149_medium.mp4 +3 -0
  21. contact/219046_medium.mp4 +3 -0
  22. contact/262213_medium.mp4 +3 -0
  23. contact/262412_medium.mp4 +3 -0
  24. contact/338978_medium.mp4 +3 -0
  25. contact/85270-590799476_medium.mp4 +3 -0
  26. contact/85271-590799487_medium.mp4 +3 -0
  27. contact/85273-590799512_medium.mp4 +3 -0
  28. contact/85275-590799527_medium.mp4 +3 -0
  29. contact/85277-590799536_medium.mp4 +3 -0
  30. docker-compose.yml +18 -0
  31. knowledge/ssrn-A First Look at Financial Data Analysis Using ChatGPT-4o-4849578.pdf +3 -0
  32. knowledge/ssrn-Defining and Measuring Financial Literacy-1498674.pdf +3 -0
  33. knowledge/ssrn-Financial Machine Learning-4501707.pdf +3 -0
  34. knowledge/ssrn-From the Stockholder to the Stakeholder How Sustainability Can Drive Financial Outperformance-2508281.pdf +3 -0
  35. knowledge/ssrn-In Search of the Origins of Financial Fluctuations The Inelastic Markets Hypothesis-3686935.pdf +3 -0
  36. knowledge/ssrn-International Financial Reporting Standards (IFRS) Pros and Cons for Investors-929561.pdf +3 -0
  37. knowledge/ssrn-Stock Market Charts You Never Saw-3050736.pdf +3 -0
  38. knowledge/ssrn-Study and Analysis of Chat GPT and its Impact on Different Fields of Study4402499.pdf +3 -0
  39. knowledge/ssrn-Taxes, Financing Decisions, and Firm Value-1871.pdf +3 -0
  40. knowledge/ssrn-The Financial Statements Analysis-3794864.pdf +3 -0
  41. knowledge/ssrn-Towards a New Financial Statement Analysis-4845596.pdf +3 -0
  42. main.py +39 -0
  43. market_demo.py +173 -0
  44. render-free.yaml +48 -0
  45. render.yaml +48 -0
  46. requirements.txt +32 -0
  47. runtime_config.py +31 -0
  48. static/images/LOGO_final.png +3 -0
  49. static/images/academy/1.jpg.webp +0 -0
  50. static/images/academy/2.jpg.jpg +3 -0
.dockerignore ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ .env.*
3
+ !.env.example
4
+ .git
5
+ .github
6
+ __pycache__/
7
+ *.pyc
8
+ *.pyo
9
+ *.pyd
10
+ *.sqlite
11
+ chroma_db/
12
+ data/
13
+ node_modules/
14
+ ui improvement/node_modules/
15
+ ui improvement/dist/
16
+ _profile_repo/
17
+ _remote_repo/
18
+ *.log
.env.example ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Core app settings
2
+ FLASK_SECRET_KEY=replace_with_a_long_random_secret
3
+ FLASK_DEBUG=false
4
+ FLASK_HOST=0.0.0.0
5
+ FLASK_PORT=5000
6
+ PORT=5000
7
+ TRUST_PROXY_HEADERS=true
8
+
9
+ # Cookie and browser settings
10
+ # Same-origin deployment (recommended for a single cloud web service):
11
+ SESSION_COOKIE_SAMESITE=Lax
12
+ SESSION_COOKIE_SECURE=false
13
+
14
+ # If you later split frontend and backend across different domains:
15
+ # SESSION_COOKIE_SAMESITE=None
16
+ # SESSION_COOKIE_SECURE=true
17
+ # FRONTEND_ORIGINS=https://your-frontend-domain.com
18
+ FRONTEND_ORIGINS=http://127.0.0.1:5173,http://localhost:5173
19
+
20
+ # LLM provider
21
+ DEEPSEEK_API_KEY=replace_with_your_deepseek_api_key
22
+ DEEPSEEK_BASE_URL=https://api.deepseek.com
23
+ DEEPSEEK_MODEL=deepseek-chat
24
+
25
+ # Persistent runtime paths
26
+ DATA_DIR=./data
27
+ CHECKPOINTS_DB_PATH=./data/checkpoints.sqlite
28
+ CHROMA_DB_DIR=./data/chroma_db
29
+ KNOWLEDGE_BASE_PATH=./knowledge
30
+ HF_HOME=./data/hf-home
31
+ SENTENCE_TRANSFORMERS_HOME=./data/sentence-transformers
32
+
33
+ # Optional media throttling for low-cost cloud deployments
34
+ # BACKGROUND_VIDEO_MAX_MB=8
35
+ # BACKGROUND_VIDEO_MAX_COUNT=4
36
+
37
+ # Gunicorn production server
38
+ GUNICORN_WORKERS=2
39
+ GUNICORN_THREADS=4
40
+ GUNICORN_TIMEOUT=180
41
+
42
+ # Optional tracing
43
+ LANGCHAIN_TRACING_V2=false
44
+ LANGCHAIN_API_KEY=
.github/workflows/deploy-pages.yml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ concurrency:
15
+ group: pages
16
+ cancel-in-progress: true
17
+
18
+ jobs:
19
+ build:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v5
24
+
25
+ - name: Configure Pages
26
+ uses: actions/configure-pages@v5
27
+
28
+ - name: Setup Node
29
+ uses: actions/setup-node@v4
30
+ with:
31
+ node-version: 20
32
+ cache: npm
33
+ cache-dependency-path: ui improvement/package-lock.json
34
+
35
+ - name: Install frontend dependencies
36
+ run: npm ci
37
+ working-directory: ui improvement
38
+
39
+ - name: Build frontend
40
+ run: npm run build
41
+ working-directory: ui improvement
42
+ env:
43
+ VITE_API_BASE: ${{ vars.VITE_API_BASE }}
44
+ VITE_BASE_PATH: /U2INVEST-Your-Stocks-You-To-Invest/
45
+
46
+ - name: Upload Pages artifact
47
+ uses: actions/upload-pages-artifact@v4
48
+ with:
49
+ path: ui improvement/dist
50
+
51
+ deploy:
52
+ environment:
53
+ name: github-pages
54
+ url: ${{ steps.deployment.outputs.page_url }}
55
+ runs-on: ubuntu-latest
56
+ needs: build
57
+ steps:
58
+ - name: Deploy to GitHub Pages
59
+ id: deployment
60
+ uses: actions/deploy-pages@v4
.gitignore ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Environments
2
+ venv/
3
+ env/
4
+ .env
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+ # Databases & State
12
+ *.sqlite
13
+ *.sqlite*
14
+ *.db
15
+ checkpoints.sqlite
16
+ chroma_db/
17
+ instance/
18
+
19
+ # IDEs
20
+ .vscode/
21
+ .idea/
22
+
23
+ # OS Files
24
+ .DS_Store
25
+ Thumbs.db
26
+
27
+ # Logs
28
+ *.log
COMMERCIAL_WEBSITE_SITEMAP_AND_PAGE_SPEC.md ADDED
@@ -0,0 +1,866 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # U2INVEST Commercial Website Sitemap and Page Spec
2
+
3
+ ## 1. Purpose
4
+
5
+ This document defines the public-facing commercial website architecture for U2INVEST.
6
+
7
+ It exists alongside the product application PRD and should be used when designing or building:
8
+
9
+ - the marketing website
10
+ - the business website
11
+ - the lead-generation website
12
+ - the trust/compliance/legal website layer
13
+
14
+ The goal is to ensure U2INVEST works as both:
15
+
16
+ - a serious web product
17
+ - a credible commercial business website
18
+
19
+ ## 2. Recommended Website Model
20
+
21
+ U2INVEST should be split into two clearly different layers:
22
+
23
+ ### A. Public website layer
24
+
25
+ Used for:
26
+
27
+ - discovery
28
+ - brand explanation
29
+ - trust building
30
+ - product explanation
31
+ - sales conversion
32
+ - contact and partnership inquiries
33
+ - legal/compliance visibility
34
+
35
+ ### B. Product application layer
36
+
37
+ Used for:
38
+
39
+ - Academy
40
+ - Trading Lab
41
+ - U2CHAT
42
+ - logged-in or product-entry experiences
43
+
44
+ ### Recommended route separation
45
+
46
+ Use public-site routes for business/marketing pages, and reserve `/app` for the actual product workspace.
47
+
48
+ This avoids mixing:
49
+
50
+ - commercial website navigation
51
+ - internal product navigation
52
+
53
+ ## 3. Recommended Route Architecture
54
+
55
+ ## 3.1 Public marketing and business routes
56
+
57
+ - `/`
58
+ - `/product`
59
+ - `/product/academy`
60
+ - `/product/trading-lab`
61
+ - `/product/u2chat`
62
+ - `/pricing`
63
+ - `/about`
64
+ - `/contact`
65
+ - `/faq`
66
+ - `/resources`
67
+ - `/book-demo`
68
+ - `/get-started`
69
+
70
+ ## 3.2 Legal and policy routes
71
+
72
+ - `/legal/privacy`
73
+ - `/legal/terms`
74
+ - `/legal/cookies`
75
+ - `/legal/disclaimer`
76
+ - `/legal/risk-disclosure`
77
+ - `/legal/accessibility`
78
+
79
+ ## 3.3 Conversion result routes
80
+
81
+ - `/thank-you/contact`
82
+ - `/thank-you/demo`
83
+ - `/thank-you/get-started`
84
+
85
+ ## 3.4 Product application routes
86
+
87
+ - `/app`
88
+ - `/app/academy`
89
+ - `/app/lab`
90
+ - `/app/chat`
91
+
92
+ If the first release remains partially SPA-based, this route model should still be treated as the target information architecture.
93
+
94
+ ## 4. Primary Navigation Model
95
+
96
+ ### Public desktop header
97
+
98
+ - Logo
99
+ - Product
100
+ - Pricing
101
+ - Resources
102
+ - About
103
+ - Contact
104
+ - `Book Demo`
105
+ - `Get Started`
106
+ - `Enter App`
107
+
108
+ ### Public mobile nav
109
+
110
+ - Logo
111
+ - Menu
112
+ - `Get Started`
113
+
114
+ Menu should include:
115
+
116
+ - Product
117
+ - Pricing
118
+ - Resources
119
+ - About
120
+ - Contact
121
+ - Book Demo
122
+ - Enter App
123
+ - Legal links in footer region
124
+
125
+ ### Product-app navigation
126
+
127
+ Once the user enters `/app`, the app should use a separate navigation model oriented around product use:
128
+
129
+ - Academy
130
+ - Trading Lab
131
+ - U2CHAT
132
+ - user/account entry if added
133
+ - help/support access
134
+ - return-to-site entry if appropriate
135
+
136
+ ## 5. Sitemap
137
+
138
+ ## 5.1 MVP sitemap
139
+
140
+ - Home
141
+ - Product
142
+ - Product > Academy
143
+ - Product > Trading Lab
144
+ - Product > U2CHAT
145
+ - Pricing
146
+ - About
147
+ - Contact
148
+ - FAQ
149
+ - Book Demo
150
+ - Get Started
151
+ - Privacy Policy
152
+ - Terms of Service
153
+ - Disclaimer
154
+ - Risk Disclosure
155
+ - Footer
156
+ - App entry
157
+
158
+ ## 5.2 Phase-2 sitemap
159
+
160
+ - Resources
161
+ - Blog/Insights
162
+ - Testimonials / Case Studies
163
+ - Security / Trust page
164
+ - Support / Help page
165
+ - Cookie Policy
166
+ - Accessibility Statement
167
+
168
+ ## 6. Page-by-Page Specification
169
+
170
+ ## 6.1 Home
171
+
172
+ ### Route
173
+
174
+ - `/`
175
+
176
+ ### Primary goal
177
+
178
+ Explain what U2INVEST is, why it matters, and move visitors into either:
179
+
180
+ - product exploration
181
+ - signup/get-started flow
182
+ - demo/contact flow
183
+
184
+ ### Primary audiences
185
+
186
+ - first-time visitors
187
+ - prospective customers
188
+ - recruiters/stakeholders
189
+ - partners
190
+
191
+ ### Required sections
192
+
193
+ - hero with value proposition
194
+ - subheadline that explains the three-pillar model
195
+ - primary CTA row
196
+ - trust strip
197
+ - product overview
198
+ - three-pillar explanation:
199
+ - Academy
200
+ - Trading Lab
201
+ - U2CHAT
202
+ - how-it-works section
203
+ - why-U2INVEST / differentiation section
204
+ - trust/compliance statement for finance education and AI
205
+ - proof section:
206
+ - testimonials
207
+ - logos
208
+ - metrics
209
+ - or placeholders if still pre-commercial
210
+ - FAQ preview
211
+ - final CTA band
212
+ - professional footer
213
+
214
+ ### Primary CTA
215
+
216
+ - `Get Started`
217
+
218
+ ### Secondary CTA
219
+
220
+ - `Book Demo`
221
+
222
+ ### Tertiary CTA
223
+
224
+ - `Explore Product`
225
+
226
+ ### Must communicate
227
+
228
+ - educational + simulation + AI workflow
229
+ - who it is for
230
+ - what is live data vs simulated vs educational
231
+ - that the product is finance-adjacent and trustworthy
232
+
233
+ ## 6.2 Product Overview
234
+
235
+ ### Route
236
+
237
+ - `/product`
238
+
239
+ ### Primary goal
240
+
241
+ Present the integrated product story and help visitors understand how the three pillars work together.
242
+
243
+ ### Required sections
244
+
245
+ - product overview hero
246
+ - product architecture summary
247
+ - workflow:
248
+ - learn
249
+ - practice
250
+ - analyze
251
+ - section for Academy
252
+ - section for Trading Lab
253
+ - section for U2CHAT
254
+ - data and AI explanation
255
+ - trust and disclaimer strip
256
+ - CTA band
257
+
258
+ ### Primary CTA
259
+
260
+ - `Get Started`
261
+
262
+ ### Secondary CTA
263
+
264
+ - `Book Demo`
265
+
266
+ ### Optional CTA
267
+
268
+ - `Enter App`
269
+
270
+ ## 6.3 Product Page: Academy
271
+
272
+ ### Route
273
+
274
+ - `/product/academy`
275
+
276
+ ### Primary goal
277
+
278
+ Sell the Academy as a structured learning environment, not just a video gallery.
279
+
280
+ ### Required sections
281
+
282
+ - hero focused on financial education outcomes
283
+ - what learners get
284
+ - module structure and roadmap explanation
285
+ - outcomes, takeaways, and progression explanation
286
+ - screenshots or product visuals
287
+ - credibility section for educational sources
288
+ - CTA band
289
+
290
+ ### Primary CTA
291
+
292
+ - `Start Learning`
293
+
294
+ ### Secondary CTA
295
+
296
+ - `Explore Product`
297
+
298
+ ## 6.4 Product Page: Trading Lab
299
+
300
+ ### Route
301
+
302
+ - `/product/trading-lab`
303
+
304
+ ### Primary goal
305
+
306
+ Sell the Lab as a safe, educational simulation workspace.
307
+
308
+ ### Required sections
309
+
310
+ - hero focused on safe practice and simulated investing
311
+ - beginner vs advanced workflow explanation
312
+ - charting and trade simulation explanation
313
+ - portfolio and decision-making explanation
314
+ - explicit simulation disclaimer
315
+ - screenshots or workflow visuals
316
+ - CTA band
317
+
318
+ ### Primary CTA
319
+
320
+ - `Try the Lab`
321
+
322
+ ### Secondary CTA
323
+
324
+ - `Book Demo`
325
+
326
+ ## 6.5 Product Page: U2CHAT
327
+
328
+ ### Route
329
+
330
+ - `/product/u2chat`
331
+
332
+ ### Primary goal
333
+
334
+ Position U2CHAT as a research assistant and learning companion.
335
+
336
+ ### Required sections
337
+
338
+ - hero focused on AI-assisted market understanding
339
+ - what the assistant can do
340
+ - tool/data/source explanation
341
+ - chart-in-chat explanation
342
+ - RAG / knowledge-base explanation
343
+ - responsible-use statement
344
+ - CTA band
345
+
346
+ ### Primary CTA
347
+
348
+ - `Try U2CHAT`
349
+
350
+ ### Secondary CTA
351
+
352
+ - `Explore Product`
353
+
354
+ ## 6.6 Pricing
355
+
356
+ ### Route
357
+
358
+ - `/pricing`
359
+
360
+ ### Primary goal
361
+
362
+ Help prospects understand commercial packaging and move them toward:
363
+
364
+ - self-serve signup
365
+ - demo request
366
+ - pricing inquiry
367
+
368
+ ### Required sections
369
+
370
+ - pricing hero
371
+ - pricing model explanation
372
+ - plan cards or pricing inquiry model
373
+ - feature comparison
374
+ - who each plan is for
375
+ - FAQ on pricing and access
376
+ - CTA band
377
+
378
+ ### Primary CTA
379
+
380
+ - `Get Started`
381
+
382
+ ### Secondary CTA
383
+
384
+ - `Contact Sales`
385
+
386
+ ### If pricing is not ready
387
+
388
+ Use:
389
+
390
+ - `Request Pricing`
391
+ - `Book Demo`
392
+
393
+ Instead of fake numbers.
394
+
395
+ ## 6.7 About
396
+
397
+ ### Route
398
+
399
+ - `/about`
400
+
401
+ ### Primary goal
402
+
403
+ Build trust in the company, product mission, and people behind it.
404
+
405
+ ### Required sections
406
+
407
+ - mission and vision
408
+ - company story
409
+ - product philosophy
410
+ - founder/team section
411
+ - product values
412
+ - finance/AI responsibility statement
413
+ - CTA band
414
+
415
+ ### Primary CTA
416
+
417
+ - `Contact Us`
418
+
419
+ ### Secondary CTA
420
+
421
+ - `Book Demo`
422
+
423
+ ## 6.8 Contact
424
+
425
+ ### Route
426
+
427
+ - `/contact`
428
+
429
+ ### Primary goal
430
+
431
+ Provide a clear and low-friction business contact path.
432
+
433
+ ### Required sections
434
+
435
+ - contact hero
436
+ - general contact form
437
+ - business email
438
+ - optional phone number
439
+ - optional business address or region
440
+ - inquiry routing options:
441
+ - sales
442
+ - support
443
+ - partnership
444
+ - press/media
445
+ - other
446
+ - social links
447
+ - expected response-time note
448
+
449
+ ### Contact form fields
450
+
451
+ - full name
452
+ - work email
453
+ - company name
454
+ - role/title
455
+ - inquiry type
456
+ - message
457
+ - consent checkbox
458
+
459
+ ### Primary CTA
460
+
461
+ - `Send Inquiry`
462
+
463
+ ### Secondary CTA
464
+
465
+ - `Email Us`
466
+
467
+ ## 6.9 FAQ
468
+
469
+ ### Route
470
+
471
+ - `/faq`
472
+
473
+ ### Primary goal
474
+
475
+ Reduce friction for prospects and answer trust, product, and pricing questions.
476
+
477
+ ### Required FAQ groups
478
+
479
+ - product overview
480
+ - Academy
481
+ - Trading Lab
482
+ - U2CHAT
483
+ - pricing/access
484
+ - privacy/security
485
+ - finance disclaimers
486
+ - support/contact
487
+
488
+ ### Primary CTA
489
+
490
+ - `Get Started`
491
+
492
+ ### Secondary CTA
493
+
494
+ - `Contact Us`
495
+
496
+ ## 6.10 Resources
497
+
498
+ ### Route
499
+
500
+ - `/resources`
501
+
502
+ ### Primary goal
503
+
504
+ Support SEO, thought leadership, onboarding, and top-of-funnel education.
505
+
506
+ ### Required sections
507
+
508
+ - featured resources
509
+ - guides/articles/insights
510
+ - education content categories
511
+ - optional newsletter capture
512
+ - CTA band
513
+
514
+ ### Primary CTA
515
+
516
+ - `Explore Resources`
517
+
518
+ ### Secondary CTA
519
+
520
+ - `Join Newsletter`
521
+
522
+ ## 6.11 Book Demo
523
+
524
+ ### Route
525
+
526
+ - `/book-demo`
527
+
528
+ ### Primary goal
529
+
530
+ Convert qualified prospects into sales conversations.
531
+
532
+ ### Required sections
533
+
534
+ - demo value proposition
535
+ - who demo is for
536
+ - short expectations note
537
+ - demo request form
538
+ - optional embedded calendar
539
+
540
+ ### Demo request form fields
541
+
542
+ - full name
543
+ - work email
544
+ - company
545
+ - role
546
+ - team size
547
+ - primary use case
548
+ - timeline
549
+ - message
550
+ - consent checkbox
551
+
552
+ ### Primary CTA
553
+
554
+ - `Request Demo`
555
+
556
+ ### Secondary CTA
557
+
558
+ - `Contact Sales`
559
+
560
+ ## 6.12 Get Started
561
+
562
+ ### Route
563
+
564
+ - `/get-started`
565
+
566
+ ### Primary goal
567
+
568
+ Move the visitor toward the right next step based on intent.
569
+
570
+ ### Required options
571
+
572
+ - self-serve start
573
+ - explore product first
574
+ - book a demo
575
+ - contact sales
576
+
577
+ ### Required behavior
578
+
579
+ This page should segment users quickly:
580
+
581
+ - individual learner/investor
582
+ - business/institutional buyer
583
+ - partner/media inquiry
584
+
585
+ ## 6.13 Thank-You Pages
586
+
587
+ ### Routes
588
+
589
+ - `/thank-you/contact`
590
+ - `/thank-you/demo`
591
+ - `/thank-you/get-started`
592
+
593
+ ### Primary goal
594
+
595
+ Confirm success, reduce uncertainty, and route the next action.
596
+
597
+ ### Required elements
598
+
599
+ - success confirmation
600
+ - expected response time
601
+ - next-step suggestions
602
+ - fallback contact info
603
+ - return-to-site/product CTA
604
+
605
+ ## 6.14 Legal Pages
606
+
607
+ ### Required routes
608
+
609
+ - `/legal/privacy`
610
+ - `/legal/terms`
611
+ - `/legal/cookies`
612
+ - `/legal/disclaimer`
613
+ - `/legal/risk-disclosure`
614
+ - `/legal/accessibility`
615
+
616
+ ### Legal page requirements
617
+
618
+ - clear ownership/company identity
619
+ - last updated date
620
+ - readable structure
621
+ - contact for legal/privacy requests where relevant
622
+ - finance-specific disclaimers where relevant
623
+
624
+ ## 6.15 Product App Entry
625
+
626
+ ### Route
627
+
628
+ - `/app`
629
+
630
+ ### Primary goal
631
+
632
+ Create a clean transition from public website mode into product-use mode.
633
+
634
+ ### Required elements
635
+
636
+ - app overview or immediate workspace
637
+ - wayfinding to:
638
+ - Academy
639
+ - Lab
640
+ - U2CHAT
641
+ - return-to-site path
642
+ - help/support path
643
+
644
+ ## 7. Footer Specification
645
+
646
+ The footer should exist on every public-facing page.
647
+
648
+ ### Required footer groups
649
+
650
+ - Product
651
+ - Company
652
+ - Resources
653
+ - Legal
654
+ - Contact
655
+ - Social
656
+
657
+ ### Recommended footer links
658
+
659
+ ### Product
660
+
661
+ - Product
662
+ - Academy
663
+ - Trading Lab
664
+ - U2CHAT
665
+ - Pricing
666
+
667
+ ### Company
668
+
669
+ - About
670
+ - Contact
671
+ - Book Demo
672
+
673
+ ### Resources
674
+
675
+ - FAQ
676
+ - Resources
677
+ - Support
678
+
679
+ ### Legal
680
+
681
+ - Privacy Policy
682
+ - Terms of Service
683
+ - Disclaimer
684
+ - Risk Disclosure
685
+ - Cookie Policy
686
+ - Accessibility
687
+
688
+ ### Contact
689
+
690
+ - business email
691
+ - optional phone
692
+ - location
693
+
694
+ ### Social
695
+
696
+ - LinkedIn
697
+ - X/Twitter
698
+ - GitHub if relevant
699
+ - YouTube if relevant
700
+
701
+ ### Footer utility row
702
+
703
+ - copyright
704
+ - company name
705
+ - year
706
+ - rights statement
707
+
708
+ ## 8. CTA Architecture
709
+
710
+ ## 8.1 Global CTA hierarchy
711
+
712
+ ### Primary CTA
713
+
714
+ - `Get Started`
715
+
716
+ ### Secondary CTA
717
+
718
+ - `Book Demo`
719
+
720
+ ### Tertiary CTA set
721
+
722
+ - `Explore Product`
723
+ - `Contact Us`
724
+ - `Enter App`
725
+ - `View Pricing`
726
+
727
+ ## 8.2 CTA placement rules
728
+
729
+ - hero section always includes a primary CTA
730
+ - key product sections include at least one CTA
731
+ - proof and FAQ sections should lead to a next step
732
+ - footer should include at least one conversion CTA
733
+ - contact/demo/pricing pages should have no ambiguous next step
734
+
735
+ ## 9. Lead Funnel and Conversion Flows
736
+
737
+ ## 9.1 Self-serve individual funnel
738
+
739
+ - Home
740
+ - Product or pillar page
741
+ - Pricing or Get Started
742
+ - Enter App / onboarding
743
+
744
+ ## 9.2 Business buyer funnel
745
+
746
+ - Home
747
+ - Product
748
+ - Trust/proof/pricing/FAQ
749
+ - Book Demo
750
+ - Thank-you page
751
+ - CRM follow-up
752
+
753
+ ## 9.3 Partnership / press funnel
754
+
755
+ - Home
756
+ - About or Resources
757
+ - Contact
758
+ - inquiry routing
759
+
760
+ ## 9.4 Support funnel
761
+
762
+ - Footer / Contact / Help link
763
+ - support path
764
+ - email or help center
765
+
766
+ ## 9.5 Required post-conversion behavior
767
+
768
+ - confirmation state
769
+ - response-time expectation
770
+ - lead capture storage
771
+ - email notification or CRM creation
772
+
773
+ ## 10. Forms and Integrations
774
+
775
+ ## 10.1 Contact form requirements
776
+
777
+ - client-side validation
778
+ - server-side validation
779
+ - spam protection
780
+ - success state
781
+ - error state
782
+ - inbox or CRM routing
783
+
784
+ ## 10.2 Demo form requirements
785
+
786
+ - client-side validation
787
+ - server-side validation
788
+ - optional calendar integration
789
+ - sales inbox or CRM routing
790
+ - success page
791
+
792
+ ## 10.3 Newsletter / lead capture requirements
793
+
794
+ - email field
795
+ - consent
796
+ - mailing integration
797
+ - success state
798
+
799
+ ## 10.4 Analytics requirements
800
+
801
+ - page-view tracking
802
+ - CTA click tracking
803
+ - form conversion tracking
804
+ - referral / attribution tracking
805
+ - outbound link tracking
806
+
807
+ ## 10.5 SEO requirements
808
+
809
+ - unique titles and meta descriptions per page
810
+ - Open Graph metadata
811
+ - semantic heading structure
812
+ - sitemap generation
813
+ - robots rules
814
+ - internal linking plan
815
+
816
+ ## 10.6 Finance-trust requirements
817
+
818
+ - educational-use language
819
+ - not-financial-advice disclaimer
820
+ - AI limitation disclosure
821
+ - live-data vs simulated-data disclosure
822
+ - risk disclosure for Trading Lab
823
+
824
+ ## 11. Launch Priorities
825
+
826
+ ## 11.1 Must-launch pages
827
+
828
+ - Home
829
+ - Product
830
+ - Product Academy
831
+ - Product Trading Lab
832
+ - Product U2CHAT
833
+ - Pricing or pricing inquiry
834
+ - About
835
+ - Contact
836
+ - FAQ
837
+ - legal pages
838
+ - Book Demo
839
+ - Get Started
840
+ - professional footer
841
+
842
+ ## 11.2 Should-launch pages
843
+
844
+ - Resources
845
+ - thank-you pages
846
+ - support/help page
847
+ - testimonials/proof section
848
+
849
+ ## 11.3 Can-launch-later pages
850
+
851
+ - blog
852
+ - case studies
853
+ - security page
854
+ - newsroom/media page
855
+
856
+ ## 12. Success Criteria
857
+
858
+ The commercial website is successful if a new visitor can:
859
+
860
+ - understand what U2INVEST is in under 10 seconds
861
+ - understand the three product pillars clearly
862
+ - trust the company enough to continue exploring
863
+ - find contact and legal information easily
864
+ - submit a contact or demo request without friction
865
+ - identify a clear next step on every key page
866
+ - move cleanly from public website mode into product mode
CURRENT_PROJECT_PRD.md ADDED
@@ -0,0 +1,1104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # U2INVEST Current Product PRD
2
+
3
+ ## 1. Executive Summary
4
+
5
+ U2INVEST is a three-pillar financial product that combines:
6
+
7
+ 1. Knowledge Academy
8
+ 2. Trading Lab
9
+ 3. U2CHAT AI assistant
10
+
11
+ The current implementation is a Flask-served single-page web app with:
12
+
13
+ - one primary frontend file: `templates/index.html`
14
+ - one primary backend/API file: `web_app.py`
15
+ - a LangGraph agent workflow: `agent_graph.py`
16
+ - stock/RAG tools: `tools.py`
17
+ - a Chroma-backed PDF knowledge pipeline: `vector_store.py`
18
+ - a CLI-style agent test entrypoint: `main.py`
19
+
20
+ This PRD is not a concept document. It is a product-truth document for the current repository. It extracts the actual functions, features, states, gaps, and upgrade paths so the whole UI can be rebuilt without losing product scope.
21
+
22
+ ## 2. Product Vision
23
+
24
+ Help beginner and intermediate investors learn investing, practice safely, and ask an AI assistant for analysis inside one integrated product.
25
+
26
+ ## 2.1 Commercial Website Vision
27
+
28
+ U2INVEST should not behave only like an internal demo app or portfolio prototype. As a commercial web product, it should also present itself like a credible business:
29
+
30
+ - discoverable
31
+ - trustworthy
32
+ - contactable
33
+ - explainable
34
+ - legally defensible
35
+ - conversion-oriented
36
+
37
+ That means the final product should include both:
38
+
39
+ - the product application layer
40
+ - the public business/marketing/sales website layer
41
+
42
+ ## 3. Rebuild Objective
43
+
44
+ Rebuild the entire UI while preserving the full current functional scope, making the product:
45
+
46
+ - simpler
47
+ - calmer
48
+ - more premium
49
+ - more structurally consistent
50
+ - more maintainable
51
+ - more trustworthy as a product
52
+
53
+ The rebuild should not accidentally reduce scope. It should preserve the current breadth of Academy, Lab, and U2CHAT while fixing partial features and surfacing hidden capabilities.
54
+
55
+ The rebuild should also expand the current landing shell into a proper commercial website experience with public-facing business, sales, trust, and contact functionality.
56
+
57
+ ## 4. Target Users and Core Jobs
58
+
59
+ ### Primary users
60
+
61
+ - Beginner investors who want structured financial education
62
+ - Early-stage self-directed investors who want a safe trading simulator
63
+ - Users who want an AI assistant to explain stocks, market concepts, and strategies
64
+
65
+ ### Secondary users
66
+
67
+ - Recruiters or reviewers evaluating product thinking and technical execution
68
+ - Users who want a local finance-learning demo with AI and charts
69
+ - Prospective customers evaluating whether to trust or buy the product
70
+ - Business partners, media contacts, and inbound collaborators
71
+ - Prospective hires or stakeholders evaluating the company and product credibility
72
+
73
+ ### Core jobs to be done
74
+
75
+ - "Teach me the fundamentals of investing."
76
+ - "Let me practice trading without risking money."
77
+ - "Help me analyze a stock with live data and research context."
78
+ - "Give me a workspace where learning, simulation, and AI analysis connect."
79
+ - "Help me understand what this company/product is and whether I should trust it."
80
+ - "Give me a clear way to contact the business, book a demo, or start using the product."
81
+ - "Show me enough credibility, legal clarity, and product value to convert me into a lead or customer."
82
+
83
+ ## 5. Current System Map
84
+
85
+ ### Product shell
86
+
87
+ - Flask serves a single-page frontend shell
88
+ - SPA-like view switching happens in the browser through `showView()`
89
+ - A browser session receives a generated `user_id`
90
+
91
+ ### Core product surfaces
92
+
93
+ - Landing page
94
+ - Knowledge Academy
95
+ - Trading Lab
96
+ - U2CHAT
97
+ - Public business/marketing website layer, currently only minimally represented by the landing page
98
+
99
+ ### AI and data layer
100
+
101
+ - LLM access is configured through `ChatOpenAI` using a DeepSeek-style OpenAI-compatible API
102
+ - LangGraph manages reasoning plus tool routing
103
+ - SQLite persists LangGraph checkpoints
104
+ - AkShare provides live stock data when available
105
+ - Chroma stores local knowledge-base embeddings
106
+ - PDFs in `knowledge/` power retrieval
107
+
108
+ ### Deployment layer
109
+
110
+ - Local Python execution
111
+ - Dockerfile
112
+ - `docker-compose.yml`
113
+ - `.env` configuration
114
+
115
+ ## 6. Detailed Current Feature Inventory
116
+
117
+ ## 6.1 Landing and Global Navigation
118
+
119
+ ### User-facing features
120
+
121
+ - Fixed top navigation with logo and links to Academy, Lab, and U2CHAT
122
+ - Branded landing hero with product tagline
123
+ - Three large entry cards for the three product pillars
124
+ - In-browser view switching without page reload
125
+
126
+ ### Supporting frontend functions
127
+
128
+ - `showView(v)`
129
+
130
+ ### Supporting backend functions
131
+
132
+ - `index()`
133
+
134
+ ### Current status
135
+
136
+ - Implemented
137
+
138
+ ### Current gaps
139
+
140
+ - No deep links for major product surfaces
141
+ - No browser-history-aware routing
142
+ - No route-level loading state
143
+ - No persistent "last visited workspace" behavior
144
+ - No commercial footer
145
+ - No contact information surface
146
+ - No social links
147
+ - No company/about section
148
+ - No trust or proof section
149
+ - No demo, signup, or lead-capture CTA flow
150
+ - No legal links or disclosures in the public shell
151
+
152
+ ## 6.2 Knowledge Academy
153
+
154
+ ### Current content model
155
+
156
+ The Academy currently includes 50 hardcoded modules in `ACADEMY_DATA`. Each module includes:
157
+
158
+ - `id`
159
+ - `parent`
160
+ - `cat`
161
+ - `difficulty`
162
+ - `name`
163
+ - `video`
164
+ - `source`
165
+ - `views`
166
+ - `completed`
167
+ - `ratings`
168
+ - `video_intro`
169
+ - `outcomes`
170
+ - `takeaways`
171
+
172
+ ### User-facing features currently implemented
173
+
174
+ - Academy landing view
175
+ - Grid view of all modules
176
+ - Category label on module cards
177
+ - Module view counts on cards
178
+ - Completion badge on cards
179
+ - Lesson overlay panel
180
+ - Embedded YouTube lesson video
181
+ - Lesson intro copy
182
+ - Outcomes list
183
+ - Takeaways list
184
+ - Completion state CTA
185
+ - Comments thread
186
+ - Comment replies
187
+ - Comment sorting: Top / Newest
188
+ - Share modal
189
+ - Share actions for WhatsApp, Facebook, X, LinkedIn, email, copy link
190
+ - Visual roadmap mode
191
+ - Curated roadmap mode: "Designed By U2INVEST"
192
+ - Custom roadmap mode: "You to Design"
193
+ - Custom roadmap actions:
194
+ - add node
195
+ - drag node
196
+ - connect nodes
197
+ - break link
198
+ - delete node
199
+ - Toast notifications
200
+ - Confirmation modal for roadmap destructive actions
201
+
202
+ ### Frontend functions powering Academy
203
+
204
+ - `loadData()`
205
+ - `openModule(id)`
206
+ - `openShare()`
207
+ - `closeShare()`
208
+ - `copyLink()`
209
+ - `renderComments(list)`
210
+ - `replyAt(user, commentId)`
211
+ - `replyToReply(user, parentCommentId)`
212
+ - `cancelReply()`
213
+ - `postComment()`
214
+ - `setRoadmapMode(mode)`
215
+ - `initRoadmap()`
216
+ - `dragstarted(event, d)`
217
+ - `dragged(event, d)`
218
+ - `dragended(event, d)`
219
+ - `renderCustomRoadmap(g, svg)`
220
+ - `resetPorts()`
221
+ - `openConfirm(title, desc, onOk, onCancel)`
222
+ - `openNodeModal()`
223
+ - `closeNodeModal()`
224
+ - `addCustomNode()`
225
+ - `switchAcademy(tab)`
226
+ - `closeModule()`
227
+ - `renderStatusBox(isDone)`
228
+ - `toggleStatus(isDone)`
229
+ - `sortComments(type)`
230
+ - `showToast(msg)`
231
+
232
+ ### Backend/API functions powering Academy
233
+
234
+ - `get_academy()`
235
+ - `get_course(cid)`
236
+ - `post_comment()`
237
+ - `like_comment_main()`
238
+ - `like_reply_unique()`
239
+ - `toggle_complete()`
240
+ - `rate_course()`
241
+
242
+ ### What is fully implemented
243
+
244
+ - Module browsing
245
+ - Module overlay experience
246
+ - Comment posting and replies
247
+ - Completion toggle
248
+ - Average rating display
249
+ - Curated roadmap rendering
250
+ - Custom roadmap editing in current browser session
251
+
252
+ ### What is partial or latent
253
+
254
+ - `parent` exists in the data model but is not used as the real prerequisite structure in the UI
255
+ - `source` exists in the data model but is not surfaced in the UI
256
+ - `difficulty` is used in roadmap coloring but not clearly surfaced elsewhere
257
+ - `rate_course()` exists in the backend, but there is no visible rating submission UI in the current frontend
258
+ - `like_comment_main()` and `like_reply_unique()` exist in the backend, but the frontend references `toggleLike()` and `toggleReplyLike()` handlers that do not exist
259
+ - Comment dislike icons are visual only and do not trigger anything
260
+ - Share URLs point to `/module/<id>`, but that route is not implemented in Flask
261
+
262
+ ### Known Academy issues to carry into the rebuild plan
263
+
264
+ - Comment like buttons are visible but broken because the JS handlers are missing
265
+ - Rating is display-only in the current UI
266
+ - Shared module URLs are not truly deep-linkable
267
+ - Comment timestamps are rendered as hardcoded "2 hours ago" / "1 hour ago" strings, not real relative times
268
+ - Academy progress, comments, and ratings are stored in runtime memory only
269
+ - Academy progress is not per-user durable data
270
+ - Academy state is globally mutable on the server
271
+ - `get_course(cid)` does not guard missing IDs cleanly before `.copy()`
272
+ - Custom roadmap state is not persisted to local storage or backend
273
+ - The auto roadmap is a generated visualization, not a precise prerequisite map
274
+
275
+ ### Academy advancement opportunities
276
+
277
+ - Make progress, comments, ratings, and custom roadmap persistent
278
+ - Convert `parent` into a true learning dependency graph
279
+ - Add search, filter, and sorting across modules
280
+ - Add difficulty badges and progress percentages
281
+ - Surface lesson `source` and instructor credibility more clearly
282
+ - Add note-taking, bookmarks, and study highlights
283
+ - Add quizzes, checkpoints, and completion scoring
284
+ - Add user-specific learning plans and recommended next lessons
285
+ - Add proper rating submission UI and review aggregation
286
+ - Add moderation, abuse control, and comment reporting if community features stay
287
+ - Add actual shareable deep links and direct-open module routes
288
+
289
+ ## 6.3 Trading Lab
290
+
291
+ ### Current product concept
292
+
293
+ The Lab is a paper-trading workspace for A-share-style stock simulation, with a separate beginner guide path.
294
+
295
+ ### User-facing features currently implemented
296
+
297
+ - Lab gateway with two paths:
298
+ - advanced dashboard
299
+ - beginner guide
300
+ - Beginner guide step flow with 3 educational steps
301
+ - Stock pool grouped by sectors:
302
+ - Popular
303
+ - Tech
304
+ - Energy
305
+ - Finance
306
+ - Quote cards for stocks in the selected sector
307
+ - Stock selection for chart/trade context
308
+ - K-line chart area
309
+ - Trade ticket with symbol, price, shares, and total
310
+ - Buy action
311
+ - Sell action
312
+ - Holdings panel
313
+ - History panel container
314
+ - Portfolio stats:
315
+ - Total Assets
316
+ - Cash
317
+ - Profit
318
+ - Return
319
+ - Reset portfolio
320
+ - Refresh dashboard
321
+
322
+ ### Data model and business rules
323
+
324
+ - Starting cash: $100,000
325
+ - Holdings are tracked per symbol
326
+ - Trade history is stored on buy/sell
327
+ - Buy checks available cash
328
+ - Sell checks whether holdings exist and whether the user has enough shares
329
+ - Frontend requires minimum `100` shares
330
+
331
+ ### Frontend functions powering Trading Lab
332
+
333
+ - `loadLabData()`
334
+ - `loadSectorStocks()`
335
+ - `selectStock(stock)`
336
+ - `initKlineChart()`
337
+ - `loadKlineData(symbol, days = 60)`
338
+ - `calculateTotal()`
339
+ - `executeTrade(action)`
340
+ - `updatePortfolioUI()`
341
+ - `resetPortfolio()`
342
+ - `refreshLab()`
343
+ - `updateGuideUI()`
344
+ - `nextGuideStep()`
345
+ - `prevGuideStep()`
346
+ - `setLabView(view)`
347
+
348
+ ### Backend/API functions powering Trading Lab
349
+
350
+ - `get_stock_pool()`
351
+ - `get_real_quote()`
352
+ - `get_kline_data()`
353
+ - `get_portfolio()`
354
+ - `execute_trade()`
355
+ - `reset_portfolio()`
356
+ - `get_market_data()`
357
+
358
+ ### What is fully implemented
359
+
360
+ - Gateway flow between beginner and advanced entry
361
+ - Beginner guide progression
362
+ - Sector-based stock list loading
363
+ - Quote retrieval with live-data fallback behavior
364
+ - K-line retrieval with live-data fallback behavior
365
+ - Paper buy/sell execution
366
+ - Cash/holdings update logic
367
+ - Portfolio reset
368
+
369
+ ### What is partial or latent
370
+
371
+ - Trade history is stored in backend state but not rendered into the visible `history-list`
372
+ - Return stat exists in the UI but is not updated in `updatePortfolioUI()`
373
+ - Time-range buttons `60D`, `120D`, `250D` are visible, but `changeTimeRange()` does not exist
374
+ - `get_market_data()` exists as a synthetic endpoint but is not used by the current main UI
375
+ - `user_portfolio.json` exists in the repo but is not used by the current app
376
+
377
+ ### Known Trading Lab issues to carry into the rebuild plan
378
+
379
+ - Stock selection uses `event.currentTarget` without passing `event`, so the behavior is fragile
380
+ - Portfolio value is calculated from average cost basis, not live mark-to-market pricing
381
+ - Profit shown is therefore not true unrealized P&L
382
+ - Return shown is currently a placeholder
383
+ - History panel is currently a placeholder
384
+ - Backend trusts the client-supplied execution price in `/api/lab/trade`
385
+ - No watchlist, compare view, or market context around a selected stock
386
+ - No order types beyond instant buy/sell
387
+ - No slippage, fees, order status, or risk feedback
388
+ - Lab state is per-session in memory only and resets on server restart
389
+
390
+ ### Trading Lab advancement opportunities
391
+
392
+ - Implement live mark-to-market portfolio valuation
393
+ - Render complete transaction history with timestamps and realized/unrealized P&L
394
+ - Implement `changeTimeRange()` and persist selected chart interval
395
+ - Add watchlists and favorite symbols
396
+ - Add news and fundamentals side panels for the selected stock
397
+ - Add comparison mode across multiple stocks
398
+ - Add educational hints tied to user actions
399
+ - Add more order types: market, limit, stop, stop-limit
400
+ - Add simulated fees, taxes, and slippage
401
+ - Add portfolio allocation visualization and performance analytics
402
+ - Add saved paper accounts and multiple portfolios
403
+ - Make the server authoritative for pricing instead of trusting client price input
404
+
405
+ ## 6.4 U2CHAT
406
+
407
+ ### Current product concept
408
+
409
+ U2CHAT is a financial assistant that combines:
410
+
411
+ - LLM reasoning
412
+ - tool calling
413
+ - local knowledge retrieval
414
+ - stock-related quick context selection
415
+ - inline chart rendering in chat
416
+
417
+ ### User-facing features currently implemented
418
+
419
+ - Dedicated chat workspace
420
+ - Sidebar with recent sessions
421
+ - New chat action
422
+ - Session reload from sidebar
423
+ - Clear current chat
424
+ - Quick stock-select chips by sector
425
+ - Selected-stock chip strip
426
+ - Prompt input with auto-resize
427
+ - Enter to send
428
+ - Shift+Enter for newline
429
+ - Stop button state during generation
430
+ - Assistant/user message bubbles
431
+ - Simple markdown-like rendering for headings and bullets
432
+ - Inline chart rendering from `json-chart` blocks
433
+ - Empty state for no conversation
434
+
435
+ ### Frontend functions powering U2CHAT
436
+
437
+ - `loadAgentData()`
438
+ - `loadAgentStocks()`
439
+ - `addStockToChat(stock)`
440
+ - `updateSelectedStocks()`
441
+ - `removeStock(i)`
442
+ - `sendMessage()`
443
+ - `updateSendButtonState()`
444
+ - `addMessageToUI(role, content, tools = [])`
445
+ - `renderChart(containerId, data)`
446
+ - `loadChatSessions()`
447
+ - `loadChatSession(sessionId)`
448
+ - `clearChat()`
449
+ - `newChat()`
450
+ - `handleAgentKey(e)`
451
+ - `autoResize(t)`
452
+
453
+ ### Backend/API functions powering U2CHAT
454
+
455
+ - `agent_chat()`
456
+ - `get_chat_sessions()`
457
+ - `get_chat_history()`
458
+ - `clear_chat_history()`
459
+
460
+ ### Agent workflow functions
461
+
462
+ - `AgentState`
463
+ - `call_model(state)`
464
+ - `route_logic(state)`
465
+
466
+ ### Agent tools
467
+
468
+ - `get_realtime_quote(symbol)`
469
+ - `get_stock_news(symbol)`
470
+ - `get_historical_kline(symbol)`
471
+ - `get_fundamental_data(symbol)`
472
+ - `query_knowledge_base(query)`
473
+
474
+ ### What is fully implemented
475
+
476
+ - Chat session creation
477
+ - Session title generation from the first message
478
+ - Session history retrieval while the server is running
479
+ - LangGraph-based tool routing
480
+ - LLM response generation
481
+ - Inline chart rendering from model-generated JSON blocks
482
+ - Sector-based quick stock selection
483
+ - PDF-based retrieval tool availability
484
+
485
+ ### What is partial or latent
486
+
487
+ - `agent_chat()` internally iterates `stock_agent_app.stream(...)`, but the frontend does not receive true streaming output; it waits for the final JSON response
488
+ - Tool call metadata is collected as `tools_used`, but the frontend does not surface it
489
+ - The "stop" button aborts the browser request, but there is no backend cancellation mechanism
490
+ - Chat persistence is split:
491
+ - visible session metadata and messages are in memory
492
+ - LangGraph checkpoints are in SQLite
493
+ - Quick stock selection adds stock text into the prompt, but does not create structured chat context objects
494
+
495
+ ### Known U2CHAT issues to carry into the rebuild plan
496
+
497
+ - If the server restarts, the sidebar session list and visible session history are lost
498
+ - SQLite checkpoints survive, but the current UI model does not reconnect to them cleanly
499
+ - `renderChart()` supports simple line/bar assumptions only
500
+ - The system prompt mandates structured English responses, but the UI does not visibly explain the assistant's answer format
501
+ - The app stores tool call names and args, not a clear user-facing execution trace
502
+ - No citation/source cards are shown for RAG output
503
+ - No streaming token UI or stepwise reasoning trace is exposed
504
+ - `addMessageToUI()` injects rendered HTML directly, which should be treated carefully in a full rebuild
505
+
506
+ ### U2CHAT advancement opportunities
507
+
508
+ - Add true streaming responses to the UI
509
+ - Add server-side cancellation or job interruption support
510
+ - Surface tool usage, tool results, and sources visibly
511
+ - Show retrieval sources with document titles and snippets
512
+ - Add follow-up suggestions and prompt shortcuts
513
+ - Add chart cards, ticker cards, and fundamentals cards as structured UI blocks
514
+ - Add conversation search, pinning, renaming, and grouping
515
+ - Add better state recovery after refresh and restart
516
+ - Add a dedicated research mode, beginner mode, and fast quote mode
517
+ - Add file upload and portfolio-aware chat once persistence exists
518
+
519
+ ## 6.5 Shared and Platform Features
520
+
521
+ ### Current shared UX/system features
522
+
523
+ - Toast notification surface
524
+ - Confirmation modal
525
+ - Custom-node modal
526
+ - Session-based `user_id`
527
+ - Environment-variable-based secret key
528
+ - Broad CORS enablement
529
+ - Dockerfile
530
+ - Docker Compose mounts for:
531
+ - `chroma_db`
532
+ - `checkpoints.sqlite`
533
+
534
+ ### AI/knowledge infrastructure features
535
+
536
+ - PDF discovery across `knowledge/` recursively
537
+ - Empty retriever fallback if no PDFs exist
538
+ - PDF loading with `PyPDFLoader`
539
+ - Content deduplication by MD5 hash
540
+ - Metadata enrichment for source tracking
541
+ - Chunking with overlap
542
+ - Persistent Chroma vector store
543
+ - Incremental addition when new files appear
544
+ - Retriever configured with `k=5`
545
+
546
+ ### Developer and demo features
547
+
548
+ - CLI interactive session in `main.py`
549
+ - Synthetic market endpoint `get_market_data()`
550
+
551
+ ### Current platform gaps
552
+
553
+ - No authentication layer
554
+ - No persistent database for Academy or Lab user state
555
+ - No test suite in the current repo
556
+ - No analytics or product instrumentation
557
+ - Frontend is monolithic and globally stateful
558
+ - Vector-store refresh logic detects new files, but not modified/deleted files robustly
559
+
560
+ ## 6.6 Commercial Website and Business Layer
561
+
562
+ ### Current product reality
563
+
564
+ The current repo has a landing page, branding, and product-entry navigation, but it does not yet function like a complete commercial business website.
565
+
566
+ ### Current business-site features actually present
567
+
568
+ - logo and brand mark
569
+ - positioning tagline
570
+ - top navigation
571
+ - high-level entry points into the three product pillars
572
+
573
+ ### Commercial website features required for a professional business product
574
+
575
+ This section defines the required public-facing website layer that should exist alongside the product application.
576
+
577
+ ### A. Global brand and navigation requirements
578
+
579
+ - public homepage
580
+ - consistent header navigation
581
+ - clear primary CTA
582
+ - secondary CTA for contact/demo/learn more
583
+ - professional footer
584
+ - company identity and copyright area
585
+ - social links
586
+ - legal links
587
+ - contact links
588
+ - app entry / sign in / get started entry points
589
+
590
+ ### B. Marketing and sales page requirements
591
+
592
+ - homepage with clear value proposition
593
+ - product overview page
594
+ - feature overview sections for Academy, Lab, and U2CHAT
595
+ - use-case or solution sections
596
+ - pricing page or pricing inquiry flow
597
+ - demo-request flow
598
+ - FAQ page or FAQ section
599
+ - about/company page
600
+ - contact page
601
+ - resources/blog/news section
602
+ - optional case studies/testimonials page
603
+
604
+ ### C. Trust and credibility requirements
605
+
606
+ - social proof or customer logos
607
+ - testimonials or endorsements
608
+ - team/founder credibility
609
+ - explanation of product methodology
610
+ - explanation of data sources
611
+ - privacy and security positioning
612
+ - financial education / not-financial-advice disclaimers where relevant
613
+ - risk disclosure for finance-related content and simulation features
614
+ - transparent explanation of what is live data vs simulated vs educational
615
+
616
+ ### D. Lead generation and conversion requirements
617
+
618
+ - contact form
619
+ - demo-booking form
620
+ - newsletter/signup capture
621
+ - waitlist or get-started capture
622
+ - strong CTA system across the site
623
+ - success / thank-you states after form submission
624
+ - lead routing to email/CRM
625
+ - downloadable asset or resource capture if content marketing is used
626
+
627
+ ### E. Social and communication requirements
628
+
629
+ - LinkedIn link
630
+ - X/Twitter link if used
631
+ - GitHub link if relevant to brand/company presence
632
+ - YouTube or media channel link if educational content is part of go-to-market
633
+ - business email contact
634
+ - optional phone number
635
+ - optional business address or registered business location
636
+ - press / partnership contact path
637
+
638
+ ### F. Legal, compliance, and policy requirements
639
+
640
+ - privacy policy
641
+ - terms of service
642
+ - cookie policy
643
+ - disclaimer
644
+ - risk disclosure
645
+ - acceptable-use policy if user-generated content or AI chat remains public-facing
646
+ - accessibility statement
647
+ - data and AI usage disclosure
648
+
649
+ ### G. SEO, discoverability, and content requirements
650
+
651
+ - page titles and meta descriptions
652
+ - Open Graph / social preview metadata
653
+ - sitemap
654
+ - robots configuration
655
+ - structured data where useful
656
+ - clean semantic headings
657
+ - internal linking strategy
658
+ - indexable product explainer content
659
+ - resource/blog structure if SEO is part of acquisition
660
+
661
+ ### H. Analytics, sales operations, and support requirements
662
+
663
+ - page analytics
664
+ - CTA click tracking
665
+ - form conversion tracking
666
+ - attribution tracking
667
+ - CRM or inbox integration for inbound leads
668
+ - contact management flow
669
+ - support/help contact path
670
+ - error/success instrumentation for forms and CTAs
671
+
672
+ ### I. Finance-product-specific commercial requirements
673
+
674
+ - clear statement of educational vs advisory scope
675
+ - data freshness / source disclaimers
676
+ - simulation disclaimers for the Trading Lab
677
+ - AI-answer limitations and responsible-use language
678
+ - clear explanation of whether the platform gives education, research assistance, or actionable advice
679
+
680
+ ### Current status
681
+
682
+ - mostly missing
683
+
684
+ ### Known commercial website gaps in the current repo
685
+
686
+ - no footer with business information
687
+ - no contact page or contact form
688
+ - no social links
689
+ - no about/company page
690
+ - no pricing or demo request flow
691
+ - no lead-capture forms
692
+ - no testimonials, customer proof, or trust content
693
+ - no legal pages
694
+ - no cookie/privacy consent flow
695
+ - no support/help path
696
+ - no SEO-oriented public content structure
697
+ - no analytics or conversion tracking
698
+ - no finance-specific commercial disclaimers in the public website shell
699
+
700
+ ### Commercial website advancement opportunities
701
+
702
+ - turn the landing page into a true commercial homepage
703
+ - create a full footer and public information architecture
704
+ - add contact, demo, and get-started flows
705
+ - add proof, trust, and authority sections
706
+ - add legal/compliance surface suitable for a finance-related product
707
+ - add SEO and content marketing structure
708
+ - add analytics and CRM integration
709
+ - add conversion-focused CTA system across the entire public experience
710
+
711
+ See `COMMERCIAL_WEBSITE_SITEMAP_AND_PAGE_SPEC.md` for the concrete sitemap, page-by-page public website specification, CTA architecture, footer requirements, form requirements, and lead funnel design.
712
+
713
+ ## 7. Complete Engineering Function Inventory
714
+
715
+ This section is the full code-level function inventory for rebuild planning.
716
+
717
+ ## 7.1 `web_app.py`
718
+
719
+ - `index()`: serve the main SPA and initialize `session['user_id']`
720
+ - `get_academy()`: return the full Academy module list
721
+ - `get_course(cid)`: return a specific course plus computed average rating and comments
722
+ - `post_comment()`: create top-level comments or replies
723
+ - `like_comment_main()`: increment/decrement comment like count
724
+ - `like_reply_unique()`: increment/decrement reply like count
725
+ - `toggle_complete()`: set lesson completion state
726
+ - `rate_course()`: append a rating and return the updated average
727
+ - `get_market_data()`: return synthetic OHLCV-style market data
728
+ - `get_stock_pool()`: return grouped stock symbol lists
729
+ - `get_real_quote()`: return live or simulated quote data for one or more symbols
730
+ - `get_kline_data()`: return live or simulated historical daily K-line data
731
+ - `get_portfolio()`: return current user's simulated portfolio
732
+ - `execute_trade()`: execute a paper buy or sell
733
+ - `reset_portfolio()`: restore paper portfolio to default starting cash
734
+ - `agent_chat()`: create/load a chat session, invoke the agent, save the assistant response
735
+ - `get_chat_sessions()`: return chat-session list sorted by timestamp
736
+ - `get_chat_history()`: return messages for one chat session
737
+ - `clear_chat_history()`: clear one session or all sessions for the current user
738
+
739
+ ## 7.2 `agent_graph.py`
740
+
741
+ - `AgentState`: typed graph state definition for message history
742
+ - `call_model(state)`: run the LLM with the system prompt plus tools
743
+ - `route_logic(state)`: send the flow either to tool execution or to `END`
744
+
745
+ ### Agent graph behavior
746
+
747
+ - LLM model: `deepseek-chat`
748
+ - Temperature: `0`
749
+ - System prompt rules:
750
+ - English only
751
+ - concise headings and bullets
752
+ - no `**bold**` emphasis inside prose
753
+ - emit `json-chart` blocks for stock analysis visuals
754
+ - respond with a structured market-analysis template
755
+
756
+ ## 7.3 `tools.py`
757
+
758
+ - `get_realtime_quote(symbol)`: fetch latest price, change, high, low
759
+ - `get_stock_news(symbol)`: fetch latest headlines
760
+ - `get_historical_kline(symbol)`: fetch last 60 daily data points and return JSON string
761
+ - `get_fundamental_data(symbol)`: fetch PE, PB, and ROE-style metrics
762
+ - `query_knowledge_base(query)`: retrieve relevant PDF text snippets
763
+
764
+ ## 7.4 `vector_store.py`
765
+
766
+ - `build_vector_db(persist_directory, knowledge_base_path)`: build or load the vector store and return a retriever
767
+
768
+ ### Internal behavior inside `build_vector_db()`
769
+
770
+ - create empty knowledge directory if missing
771
+ - return empty retriever if no PDFs exist
772
+ - recursively discover PDFs
773
+ - load PDFs
774
+ - deduplicate by content hash
775
+ - attach source metadata
776
+ - split text into chunks
777
+ - build or load persistent Chroma DB
778
+ - incrementally add documents if new files are detected
779
+ - return retriever configured with `k=5`
780
+
781
+ ## 7.5 `main.py`
782
+
783
+ - `start_interactive_session()`: run a CLI chat session against the LangGraph app
784
+
785
+ ## 7.6 `templates/index.html` frontend functions
786
+
787
+ ### Global shell
788
+
789
+ - `showView(v)`
790
+
791
+ ### Academy
792
+
793
+ - `loadData()`
794
+ - `openModule(id)`
795
+ - `openShare()`
796
+ - `closeShare()`
797
+ - `copyLink()`
798
+ - `renderComments(list)`
799
+ - `replyAt(user, commentId)`
800
+ - `replyToReply(user, parentCommentId)`
801
+ - `cancelReply()`
802
+ - `postComment()`
803
+ - `setRoadmapMode(mode)`
804
+ - `initRoadmap()`
805
+ - `dragstarted(event, d)`
806
+ - `dragged(event, d)`
807
+ - `dragended(event, d)`
808
+ - `renderCustomRoadmap(g, svg)`
809
+ - `resetPorts()`
810
+ - `openConfirm(title, desc, onOk, onCancel)`
811
+ - `openNodeModal()`
812
+ - `closeNodeModal()`
813
+ - `addCustomNode()`
814
+ - `switchAcademy(tab)`
815
+ - `closeModule()`
816
+ - `renderStatusBox(isDone)`
817
+ - `toggleStatus(isDone)`
818
+ - `sortComments(type)`
819
+ - `showToast(msg)`
820
+
821
+ ### Trading Lab
822
+
823
+ - `loadLabData()`
824
+ - `loadSectorStocks()`
825
+ - `selectStock(stock)`
826
+ - `initKlineChart()`
827
+ - `loadKlineData(symbol, days = 60)`
828
+ - `calculateTotal()`
829
+ - `executeTrade(action)`
830
+ - `updatePortfolioUI()`
831
+ - `resetPortfolio()`
832
+ - `refreshLab()`
833
+ - `updateGuideUI()`
834
+ - `nextGuideStep()`
835
+ - `prevGuideStep()`
836
+ - `setLabView(view)`
837
+
838
+ ### U2CHAT
839
+
840
+ - `loadAgentData()`
841
+ - `loadAgentStocks()`
842
+ - `addStockToChat(stock)`
843
+ - `updateSelectedStocks()`
844
+ - `removeStock(i)`
845
+ - `sendMessage()`
846
+ - `updateSendButtonState()`
847
+ - `addMessageToUI(role, content, tools = [])`
848
+ - `renderChart(containerId, data)`
849
+ - `loadChatSessions()`
850
+ - `loadChatSession(sessionId)`
851
+ - `clearChat()`
852
+ - `newChat()`
853
+ - `handleAgentKey(e)`
854
+ - `autoResize(t)`
855
+
856
+ ## 7.7 UI handlers currently referenced but missing
857
+
858
+ - `toggleLike(...)`
859
+ - `toggleReplyLike(...)`
860
+ - `changeTimeRange(...)`
861
+
862
+ These missing handlers are currently important product gaps because visible UI controls already depend on them.
863
+
864
+ ## 8. Current Data, Persistence, and State Boundaries
865
+
866
+ ### Browser/session state
867
+
868
+ - Flask session stores `user_id`
869
+
870
+ ### Academy state
871
+
872
+ - Module catalog is hardcoded in memory
873
+ - Completion flags mutate in server memory
874
+ - Ratings mutate in server memory
875
+ - Comments mutate in server memory
876
+ - Academy state is shared globally in the process, not persisted per user
877
+
878
+ ### Trading Lab state
879
+
880
+ - Portfolio is stored in a `defaultdict`
881
+ - State is keyed by `user_id`
882
+ - State is not persisted across server restarts
883
+
884
+ ### Chat state
885
+
886
+ - Visible session list and session messages are stored in `CHAT_SESSIONS`
887
+ - LangGraph thread memory is stored in `checkpoints.sqlite`
888
+ - These two sources of truth are not unified
889
+
890
+ ### Knowledge base state
891
+
892
+ - Vector DB persists in `chroma_db`
893
+ - Knowledge documents live in `knowledge/`
894
+ - Retriever creation currently happens at import/startup time
895
+
896
+ ### Important persistence implications
897
+
898
+ - Academy feels persistent only while the process is running
899
+ - Lab feels persistent only while the process is running
900
+ - U2CHAT appears partially persistent because LangGraph checkpoints survive, but the visible session list does not
901
+
902
+ ## 9. UI Rebuild Product Requirements
903
+
904
+ The UI rebuild should preserve current scope while correcting the current architecture and interaction quality.
905
+
906
+ ### Preserve these product surfaces
907
+
908
+ - Landing page
909
+ - Public commercial website layer
910
+ - Knowledge Academy
911
+ - Trading Lab
912
+ - U2CHAT
913
+ - Lesson overlay
914
+ - Share modal
915
+ - Roadmap modes
916
+ - Beginner guide
917
+ - Chat session sidebar
918
+
919
+ ### Preserve these interaction capabilities
920
+
921
+ - Module browsing
922
+ - Lesson detail opening
923
+ - Comment/reply posting
924
+ - Completion toggling
925
+ - Custom roadmap editing
926
+ - Stock browsing by sector
927
+ - Quote and chart loading
928
+ - Paper trade execution
929
+ - Chat session creation and reopening
930
+ - AI chart rendering in chat
931
+ - clear contact and conversion entry paths once added
932
+
933
+ ### Rebuild requirements
934
+
935
+ - Move away from the current single-file frontend architecture
936
+ - Introduce a clean design system with reusable tokens and components
937
+ - Make navigation, overlays, and workspaces consistent across the three pillars
938
+ - Add a real public business-site information architecture, not only an app shell
939
+ - Add proper loading, empty, error, success, and disabled states
940
+ - Make the app fully responsive on desktop and mobile
941
+ - Add visible keyboard focus states
942
+ - Reduce reliance on global mutable frontend state
943
+ - Add proper deep-linking strategy for major views and modules
944
+ - Preserve D3 and ECharts capabilities while improving presentation
945
+ - Keep the UI minimalist, but not scope-reductive
946
+
947
+ ### Commercial website requirements
948
+
949
+ - Add a professional homepage that can sell the product clearly
950
+ - Add a full footer with contact, social, legal, and business links
951
+ - Add contact and demo-request flows
952
+ - Add visible trust and credibility sections
953
+ - Add public-facing about/company context
954
+ - Add legal/policy/disclaimer surfaces
955
+ - Add conversion-focused CTA hierarchy
956
+ - Add SEO-ready page structure and metadata strategy
957
+ - Add support/help and business inquiry pathways
958
+ - Make the site feel commercially credible, not only visually polished
959
+
960
+ ### Rebuild-specific UX requirements
961
+
962
+ - The Academy should feel like a premium reading and learning workspace
963
+ - The Lab should feel like a calm, trustworthy simulation workspace
964
+ - U2CHAT should feel like a premium research assistant workspace
965
+ - Shared visual language should be coherent across all three
966
+ - The public-facing business website should feel credible enough for sales, partnerships, and commercial trust-building
967
+
968
+ ## 10. Feature and Function Advancement Roadmap
969
+
970
+ ## 10.1 Academy advancements
971
+
972
+ - Use the existing `parent` field to model real lesson progression
973
+ - Add saved user progress and user-specific completion history
974
+ - Add rating submission UI and actual review summaries
975
+ - Add comment likes, reply likes, and moderation tooling
976
+ - Add search, category filters, difficulty filters, and completion filters
977
+ - Surface lesson source, instructor, and credibility context
978
+ - Add note-taking, bookmarks, highlights, and exportable study plans
979
+ - Add quizzes and assessments after lessons
980
+ - Add progress dashboards and learning streaks
981
+ - Make custom roadmap saveable and shareable
982
+
983
+ ## 10.2 Trading Lab advancements
984
+
985
+ - Implement fully working chart time ranges
986
+ - Render transaction history in the dashboard
987
+ - Calculate live portfolio value from current quotes
988
+ - Show realized and unrealized P&L separately
989
+ - Add watchlists, alerts, and favorite stocks
990
+ - Add order types beyond immediate buy/sell
991
+ - Add slippage, fees, and tax simulation options
992
+ - Add risk metrics and portfolio allocation visuals
993
+ - Add contextual educational guidance during trading actions
994
+ - Add saved paper accounts and multiple simulation profiles
995
+ - Support richer data panels such as news, fundamentals, and peer comparison
996
+
997
+ ## 10.3 U2CHAT advancements
998
+
999
+ - Stream responses progressively instead of returning one final blob
1000
+ - Add backend-supported cancellation
1001
+ - Surface tool execution trace and tool outputs
1002
+ - Add citations and source cards for knowledge-base answers
1003
+ - Add structured cards for quotes, fundamentals, and charts
1004
+ - Add pinned conversations, search, rename, and foldering
1005
+ - Add suggested prompts and follow-up actions
1006
+ - Make recent sessions and history durable
1007
+ - Add beginner/expert assistant modes
1008
+ - Add portfolio-aware or watchlist-aware analysis once persistence exists
1009
+
1010
+ ## 10.4 Data and platform advancements
1011
+
1012
+ - Unify Academy, Lab, and Chat persistence in one durable store
1013
+ - Add proper user accounts and auth if the product goes beyond demo use
1014
+ - Make vector-store refresh detect modified and deleted PDFs
1015
+ - Move vector initialization away from blocking import-time startup where appropriate
1016
+ - Add analytics and product telemetry
1017
+ - Add a test suite for backend logic and core frontend flows
1018
+ - Add config separation for dev/staging/prod
1019
+ - Harden secret management and deployment defaults
1020
+
1021
+ ## 10.5 Frontend architecture advancements
1022
+
1023
+ - Break the current monolith into reusable components or modular views
1024
+ - Move styles and scripts into versioned static assets
1025
+ - Introduce design tokens and a consistent component library
1026
+ - Introduce cleaner state boundaries between Academy, Lab, and U2CHAT
1027
+ - Add proper routing and deep links
1028
+ - Add safer message rendering and sanitization strategy
1029
+ - Add better chart wrappers and reusable data cards
1030
+
1031
+ ## 10.6 Commercial website advancements
1032
+
1033
+ - Build a proper homepage with commercial messaging and conversion hierarchy
1034
+ - Add product overview, about, contact, FAQ, and pricing/demo surfaces
1035
+ - Add a professional footer with contact, social, legal, and support links
1036
+ - Add lead capture forms with CRM or email routing
1037
+ - Add testimonials, credibility markers, and product-proof sections
1038
+ - Add resource/content marketing structure for SEO and inbound acquisition
1039
+ - Add business-grade analytics and conversion tracking
1040
+ - Add finance-specific public disclaimers and risk disclosures
1041
+ - Add newsletter, waitlist, or demo-booking flows depending on go-to-market model
1042
+ - Add support/help center and business inquiry routing
1043
+
1044
+ ## 11. Recommended Rebuild Phases
1045
+
1046
+ ### Phase 0: Truth-preserving inventory
1047
+
1048
+ - Freeze current scope
1049
+ - Preserve all current product surfaces
1050
+ - Map implemented, partial, latent, and broken features
1051
+
1052
+ ### Phase 1: Design system and app shell
1053
+
1054
+ - Rebuild the global shell, navigation, typography, surfaces, and spacing system
1055
+ - Rebuild both the commercial website shell and the product app shell
1056
+ - Rebuild page layout structure for Academy, Lab, and U2CHAT
1057
+ - Preserve current backend API contracts
1058
+
1059
+ ### Phase 2: Feature completion
1060
+
1061
+ - Finish missing handlers
1062
+ - Finish partial Lab panels
1063
+ - Finish comment likes and ratings UI
1064
+ - Finish deep links and route behavior
1065
+ - Add public commercial pages and CTA flows
1066
+
1067
+ ### Phase 3: Persistence and intelligence
1068
+
1069
+ - Unify persistence
1070
+ - Add true streaming and tool/source display
1071
+ - Make roadmap, chat, and paper portfolios durable
1072
+
1073
+ ### Phase 4: Product maturity
1074
+
1075
+ - Add richer analysis features
1076
+ - Add personalization
1077
+ - Add moderation, analytics, and operational hardening
1078
+ - Add business analytics, CRM integration, SEO content, and commercial operations support
1079
+
1080
+ ## 12. Success Criteria for the Rebuild
1081
+
1082
+ The rebuild is successful if a user can:
1083
+
1084
+ - understand what U2INVEST is as a company/product before entering the app
1085
+ - understand the three product pillars immediately
1086
+ - move between Academy, Lab, and U2CHAT without cognitive friction
1087
+ - use every currently visible control without hitting dead or partial functionality
1088
+ - complete Academy learning flows and see trustworthy progress
1089
+ - use the Lab as a coherent paper-trading workspace
1090
+ - use U2CHAT as a believable research assistant with visible evidence and structure
1091
+ - find contact, social, legal, and trust information easily
1092
+ - submit a business inquiry, contact request, or demo request cleanly
1093
+ - recover state more reliably across refreshes and restarts
1094
+
1095
+ The rebuild is especially successful if it preserves scope while making the product feel more premium, more coherent, and more maintainable than the current single-file implementation.
1096
+
1097
+ ## 13. Highest-Priority Truths To Preserve
1098
+
1099
+ - U2INVEST is not only an AI chat app
1100
+ - U2INVEST is not only an in-app product; it also needs a public commercial website layer
1101
+ - The product is intentionally a three-part system: learn, practice, analyze
1102
+ - The Academy, Lab, and U2CHAT should remain connected but distinct
1103
+ - The rebuild should increase clarity and quality, not reduce functionality
1104
+ - The current code already contains more product scope than the current UI communicates
DEPLOY_HUGGINGFACE.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploy U2INVEST To Hugging Face Spaces
2
+
3
+ Use this if you want a second free demo deployment outside Render.
4
+
5
+ ## What This Path Is Good For
6
+
7
+ - quick public demo
8
+ - Docker-based deployment
9
+ - simple secret management in the Space settings
10
+
11
+ ## What This Path Does Not Fix By Itself
12
+
13
+ - free Spaces can still sleep when idle
14
+ - storage is still ephemeral on free hardware
15
+ - large background videos still need filtering or compression
16
+
17
+ ## Files Prepared For This
18
+
19
+ - `Dockerfile`
20
+ - `HUGGINGFACE_SPACE_README.md`
21
+
22
+ ## Steps
23
+
24
+ 1. Create a new Hugging Face Space.
25
+ 2. Choose `Docker` as the SDK.
26
+ 3. Create the Space repo.
27
+ 4. Copy the contents of `HUGGINGFACE_SPACE_README.md` into the root `README.md` of the Space repo.
28
+ 5. Push this project into that Space repo.
29
+ 6. In the Space settings, add these secrets:
30
+ - `DEEPSEEK_API_KEY`
31
+ - `FLASK_SECRET_KEY`
32
+ 7. In the Space settings, add these variables:
33
+ - `PORT=7860`
34
+ - `TRUST_PROXY_HEADERS=true`
35
+ - `SESSION_COOKIE_SECURE=true`
36
+ - `SESSION_COOKIE_SAMESITE=Lax`
37
+ - `BACKGROUND_VIDEO_MAX_MB=8`
38
+ - `BACKGROUND_VIDEO_MAX_COUNT=4`
39
+ 8. Wait for the build to finish.
40
+ 9. Test:
41
+ - `/api/health`
42
+ - `/`
43
+ - `/app/chat`
44
+
45
+ ## Notes
46
+
47
+ - The current Dockerfile now defaults to port `7860`, which matches a standard Docker Space setup.
48
+ - Render still works because Render explicitly sets `PORT=10000`.
DEPLOY_RENDER.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploy U2INVEST To Render
2
+
3
+ This repo is now prepared to run as a single Render web service:
4
+
5
+ - Flask API
6
+ - Built React frontend
7
+ - Video assets
8
+ - Persistent storage for SQLite, Chroma, and model cache
9
+
10
+ ## What Is Already Prepared
11
+
12
+ - `Dockerfile` builds the React frontend and serves the full app with Flask + Gunicorn.
13
+ - `render.yaml` defines a Render web service with a persistent disk and health check.
14
+ - Runtime paths are configurable through environment variables.
15
+ - The knowledge base retriever now initializes lazily so the app starts faster.
16
+
17
+ ## What You Need To Do
18
+
19
+ 1. Push the latest repo state to GitHub.
20
+ 2. Create a Render account and connect your GitHub account.
21
+ 3. In Render, create a new Blueprint or Web Service from this repository.
22
+ 4. If you use the Blueprint flow, Render will read `render.yaml` automatically.
23
+ 5. When prompted for secrets, set:
24
+ - `DEEPSEEK_API_KEY`
25
+ - optionally replace `FLASK_SECRET_KEY` if you do not want the generated value
26
+ 6. Confirm the persistent disk mount path is `/app/data`.
27
+ 7. Deploy.
28
+ 8. After deploy finishes, open:
29
+ - `/api/health`
30
+ - `/`
31
+ - `/app/chat`
32
+
33
+ ## If Render Asks For A Payment Method
34
+
35
+ Use `render-free.yaml` instead of `render.yaml`.
36
+
37
+ That free option removes the persistent disk and changes the service to a free instance so you can test the full app without adding a card. See `DEPLOY_RENDER_FREE.md` for the exact steps.
38
+
39
+ ## Recommended First Production Check
40
+
41
+ Verify these items before changing the agent implementation:
42
+
43
+ - The home page loads from the Render URL.
44
+ - `GET /api/health` returns `"status": "ok"`.
45
+ - The contact page works.
46
+ - The Trading Lab loads.
47
+ - U2CHAT returns a response when `DEEPSEEK_API_KEY` is set.
48
+
49
+ ## Local Docker Test
50
+
51
+ 1. Copy `.env.example` to `.env`.
52
+ 2. Fill in `FLASK_SECRET_KEY` and `DEEPSEEK_API_KEY`.
53
+ 3. Run:
54
+
55
+ ```bash
56
+ docker compose up --build
57
+ ```
58
+
59
+ 4. Open:
60
+
61
+ ```text
62
+ http://localhost:5000
63
+ http://localhost:5000/api/health
64
+ ```
65
+
66
+ ## After The Site Is Live
67
+
68
+ Do this next:
69
+
70
+ 1. Add your custom domain in Render.
71
+ 2. Verify DNS and HTTPS.
72
+ 3. Test the app again on the custom domain.
73
+ 4. Only after the current backend is stable, start replacing the current agent with TradingAgents behind the existing `/api/agent/*` routes.
74
+
75
+ ## TradingAgents Migration Strategy
76
+
77
+ Keep the public API stable and swap the backend implementation in phases:
78
+
79
+ 1. Keep the current frontend unchanged.
80
+ 2. Keep `/api/agent/chat`, `/api/agent/sessions`, and `/api/agent/history`.
81
+ 3. Replace the internals of `agent_graph.py` with a TradingAgents-backed adapter.
82
+ 4. Compare latency, token cost, and output quality before fully switching.
DEPLOY_RENDER_FREE.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploy U2INVEST To Render Without A Card
2
+
3
+ Use this path if Render asks you for a payment method when creating the paid Blueprint.
4
+
5
+ This free setup is for demo use only:
6
+
7
+ - The service can sleep after inactivity.
8
+ - Local files are not persistent.
9
+ - Session data, SQLite checkpoints, vector cache, and model cache can be lost on restart or redeploy.
10
+
11
+ ## Files
12
+
13
+ - `render.yaml`: paid, production-oriented Render setup with a persistent disk.
14
+ - `render-free.yaml`: free Render setup without a persistent disk.
15
+
16
+ ## What To Use In Render
17
+
18
+ 1. Open Render Dashboard.
19
+ 2. Click `New` -> `Blueprint`.
20
+ 3. Connect this GitHub repository.
21
+ 4. In `Blueprint Path`, enter `render-free.yaml`.
22
+ 5. Set the branch to `main`.
23
+ 6. Set `DEEPSEEK_API_KEY`.
24
+ 7. Keep the generated `FLASK_SECRET_KEY` unless you want to override it.
25
+ 8. Deploy.
26
+
27
+ ## What To Expect
28
+
29
+ - `/api/health` should return `status: ok`.
30
+ - `/` should load the marketing site.
31
+ - `/app/chat` should load the chat app.
32
+ - This free config already limits background playback to the smallest video files to reduce stalls on low-cost hosting.
33
+ - If the service has been idle for a while, the first request can be slow because the free instance may need to wake up.
34
+
35
+ ## When To Switch Back
36
+
37
+ Move back to `render.yaml` when you want:
38
+
39
+ - persistent storage
40
+ - a backend that stays warm
41
+ - more reliable response times
42
+ - safer migration to TradingAgents
Dockerfile ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:20-alpine AS frontend-builder
2
+
3
+ WORKDIR /frontend
4
+ COPY ["ui improvement/package.json", "ui improvement/package-lock.json", "./"]
5
+ RUN npm ci
6
+
7
+ COPY ["ui improvement", "/frontend"]
8
+ COPY ["video", "/video"]
9
+ COPY ["contact", "/contact"]
10
+
11
+ ENV VITE_BASE_PATH=/
12
+ RUN npm run build
13
+
14
+
15
+ FROM python:3.11-slim AS runtime
16
+
17
+ ENV PYTHONDONTWRITEBYTECODE=1 \
18
+ PYTHONUNBUFFERED=1 \
19
+ PIP_NO_CACHE_DIR=1 \
20
+ PORT=7860 \
21
+ FLASK_DEBUG=false \
22
+ DATA_DIR=/app/data \
23
+ CHECKPOINTS_DB_PATH=/app/data/checkpoints.sqlite \
24
+ CHROMA_DB_DIR=/app/data/chroma_db \
25
+ HF_HOME=/app/data/hf-home \
26
+ SENTENCE_TRANSFORMERS_HOME=/app/data/sentence-transformers
27
+
28
+ WORKDIR /app
29
+
30
+ RUN useradd -m -u 1000 appuser
31
+
32
+ COPY requirements.txt ./
33
+ RUN pip install --upgrade pip && pip install -r requirements.txt
34
+
35
+ COPY . .
36
+ COPY --from=frontend-builder ["/frontend/dist", "/app/ui improvement/dist"]
37
+
38
+ RUN mkdir -p /app/data /app/knowledge /app/video /app/contact && \
39
+ chown -R appuser:appuser /app
40
+
41
+ USER appuser
42
+
43
+ EXPOSE 7860
44
+
45
+ CMD ["sh", "-c", "gunicorn --bind 0.0.0.0:${PORT:-7860} --workers ${GUNICORN_WORKERS:-2} --threads ${GUNICORN_THREADS:-4} --timeout ${GUNICORN_TIMEOUT:-180} web_app:app"]
HUGGINGFACE_SPACE_README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: U2INVEST
3
+ emoji: 📈
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
9
+
10
+ # U2INVEST
11
+
12
+ Full-stack Flask + React deployment for the U2INVEST demo site and agent experience.
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # U2INVEST
2
+
3
+ **Your path, Your Choice, Your Future, You to Invest.**
4
+
5
+ **Financial intelligence platform featuring a RAG-enabled AI Agent (DeepSeek-V3 + LangGraph), interactive Trading Lab, and Knowledge Academy. Orchestrated with Flask, LangChain 1.1, and AkShare.**
6
+
7
+ [![Open User Guide](https://img.shields.io/badge/User_Guide-Open-blue?style=for-the-badge)](./USER_GUIDE.md)
8
+
9
+ <img src="static/images/LOGO_final.png" width="280" alt="U2INVEST Logo">
10
+
11
+ ## Key Features
12
+
13
+ ### U2CHAT (AI Agent)
14
+ * **Powered by DeepSeek-V3:** Utilizes state-of-the-art LLM reasoning for financial queries.
15
+ * **LangGraph & RAG Architecture:** Orchestrates complex workflows and retrieves knowledge from local investment guides (PDFs).
16
+ * **Real-time Data:** Integrated with **AkShare** to fetch live market data.
17
+ * **Visual Analysis:** Generates interactive ECharts for price trends and K-line data.
18
+ * **Session Management:** Supports multiple chat sessions with persistent history (SQLite).
19
+
20
+ ### Trading Lab
21
+ * **Real-time Simulation:** Trade popular stocks (Moutai, CATL, BYD) with virtual cash ($100k starting balance).
22
+ * **Professional Dashboard:** Includes K-line charts (60/120/250 days), portfolio tracking, and trade history.
23
+ * **Beginner Guide:** A step-by-step interactive tutorial on ownership and risk.
24
+
25
+ ### Knowledge Academy
26
+ * **50+ Modules:** Covers everything from "Time Value of Money" to "Options Trading".
27
+ * **Interactive Learning:** Video lessons, key takeaways, and outcomes.
28
+ * **Learning Roadmap:** Visual d3.js roadmap to track progress (Foundation → Advanced → Professional).
29
+
30
+ ## Tech Stack
31
+
32
+ * **Backend:** Python 3.13+, Flask
33
+ * **AI & Logic:** LangChain 1.1, LangGraph, ChromaDB (Vector Store)
34
+ * **Data:** AkShare (Financial Data), SQLite (Persistence)
35
+ * **Frontend:** HTML5, TailwindCSS, ECharts, D3.js
36
+
37
+ ## Architecture
38
+
39
+ The system uses a **LangGraph** workflow to manage state and tool execution.
40
+
41
+ * **State Management:** `AgentState` tracks conversation history and tool outputs.
42
+ * **Persistence:** SQLite checkpoints ensure chat sessions persist across restarts.
43
+ * **RAG Pipeline:** ChromaDB indexes financial PDFs for semantic retrieval.
44
+
45
+ ![Architecture Diagram](static/images/stock_agent_arch.png)
46
+
47
+ ## Getting Started
48
+
49
+ ### Prerequisites
50
+ * Python 3.10+
51
+ * An API Key for DeepSeek (or compatible OpenAI-format provider).
52
+
53
+ ### Installation
54
+
55
+ 1. **Clone the repository**
56
+ ```bash
57
+ git clone https://github.com/yourusername/u2invest-portfolio.git
58
+ cd u2invest-portfolio
59
+ ```
60
+
61
+ 2. **Create and activate a virtual environment**
62
+ ```bash
63
+ python -m venv venv
64
+ # Windows
65
+ venv\Scripts\activate
66
+ # Mac/Linux
67
+ source venv/bin/activate
68
+ ```
69
+
70
+ 3. **Install dependencies**
71
+ ```bash
72
+ pip install -r requirements.txt
73
+ ```
74
+
75
+ 4. **Configure Environment**
76
+ Copy the example environment file and add your API keys.
77
+ ```bash
78
+ cp .env.example .env
79
+ ```
80
+ Open `.env` and set your `DEEPSEEK_API_KEY`.
81
+
82
+ 5. **Initialize Knowledge Base (Optional)**
83
+ Place your financial PDF documents in the `knowledge/` folder. The system will automatically vectorize them on the first run.
84
+
85
+ ### Docker Deployment (Recommended)
86
+
87
+ To run the application in a containerized environment:
88
+
89
+ 1. **Build the Image**
90
+ ```bash
91
+ docker build -t u2invest .
92
+ ```
93
+
94
+ 2. **Run the Container**
95
+ ```bash
96
+ docker run -p 5000:5000 --env-file .env u2invest
97
+ ```
98
+ Access the app at `http://localhost:5000`.
99
+
100
+ ### Running the Application
101
+
102
+ Start the Flask server:
103
+ ```bash
104
+ python web_app.py
105
+ ```
106
+
107
+ Visit `http://localhost:5000` in your browser.
108
+
109
+ ## Project Structure
110
+
111
+ * `web_app.py`: Main Flask application entry point & API routes.
112
+ * `agent_graph.py`: LangGraph definition for the AI agent's logic.
113
+ * `tools.py`: Custom tools for stock data (AkShare) and RAG.
114
+ * `vector_store.py`: Logic for parsing PDFs and building the ChromaDB index.
115
+ * `templates/`: HTML frontend files.
116
+ * `static/`: CSS, Images, and JS assets.
117
+
118
+ ## Introduction & Acknowledgements
119
+
120
+ This platform was **independently developed over the course of one month** as a comprehensive full-stack engineering project. It represents a deep dive into modern AI agent architectures and financial data visualization.
121
+
122
+ **Development Highlights:**
123
+ * **Solo Full-Stack Engineering:** Handled the entire lifecycle from backend Flask logic and LangGraph orchestration to the frontend D3.js visualization and UI design.
124
+ * **AI-Augmented Workflow:** Leveraged **Gemini CLI** (integrated directly into VSCode) and **Claude** to accelerate coding, debug complex logic, and refine architectural decisions.
125
+ * **APIs & Data:** Integrated multiple financial data sources, including **AkShare** for real-time market data.
126
+
127
+
128
+ **Future Outlook:**
129
+ I am actively looking forward to further cooperation to refine this project, optimize the architecture, and evolve it into a robust, enterprise-ready solution suitable for production purposes.
130
+
131
+ **Special Thanks:**
132
+ To the open-source communities behind LangChain, DeepSeek, and AkShare for providing the robust tools that made this agentic workflow possible.
133
+
134
+ ## Portfolio & License
135
+
136
+ **Copyright © 2026 U2INVEST. All Rights Reserved.**
137
+
138
+ This project is a **Portfolio Showcase** designed to demonstrate full-stack engineering, AI agent architecture, and financial data analysis capabilities.
139
+
140
+ * **For Recruiters:** You are welcome to review the code structure, architecture patterns, and implementation details.
141
+ * **For Others:** This code is proprietary. Copying, distributing, or using this codebase for commercial purposes is strictly prohibited without explicit permission.
U2INVEST_MASTER_REBUILD_PROMPT.md ADDED
@@ -0,0 +1,869 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Improve and rebuild the UI/UX of this repo as a serious commercial web product.
2
+
3
+ This prompt is intentionally self-contained. Do not depend on any other planning docs to understand the job. You may still inspect the repo directly, but this file should be treated as the complete handoff brief.
4
+
5
+ ## 0. Context assumption
6
+
7
+ Assume you are entering this project cold.
8
+
9
+ Assume:
10
+
11
+ - you have never worked on this project before
12
+ - you have never seen this repo before
13
+ - you have no prior knowledge of the codebase
14
+ - you have no prior knowledge of the product architecture
15
+ - you have no prior knowledge of the current implementation details
16
+
17
+ Do not behave as if you already know the repo.
18
+
19
+ Before making architectural decisions or writing code, you must inspect the codebase directly and verify the current implementation yourself.
20
+
21
+ ## 1. Your role
22
+
23
+ You are the design + frontend rebuild agent for U2INVEST.
24
+
25
+ Your goal is to redesign and improve the user interface, information architecture, and frontend UX so the product feels:
26
+
27
+ - premium
28
+ - commercially credible
29
+ - minimalist
30
+ - calm
31
+ - trustworthy
32
+ - conversion-ready
33
+ - easier to use
34
+ - easier to maintain
35
+
36
+ This is not only an app UI task. U2INVEST must work as both:
37
+
38
+ - a public commercial business website
39
+ - a product application
40
+
41
+ You are expected to:
42
+
43
+ - audit the repo from scratch
44
+ - build your understanding from the code, not assumptions
45
+ - identify what is implemented, partial, broken, or missing
46
+ - choose a stronger frontend architecture
47
+ - rebuild the UI so it is commercially credible and interaction-rich
48
+
49
+ ## 2. Design direction
50
+
51
+ Target a visual/product language inspired by:
52
+
53
+ - Notion: clarity, restraint, content-first hierarchy, excellent spacing
54
+ - Manus: focused workspace feel, structured productivity surfaces
55
+ - Apple: polish, hierarchy, premium simplicity, motion discipline
56
+
57
+ Avoid:
58
+
59
+ - generic AI SaaS templates
60
+ - flashy fintech visuals
61
+ - purple-heavy gradients
62
+ - noisy dashboards
63
+ - neon accents
64
+ - shallow landing-page aesthetics
65
+ - "AI slop" styling
66
+
67
+ The final result should feel like a thoughtful finance product for serious users, not a demo site.
68
+
69
+ ## 3. What U2INVEST is
70
+
71
+ U2INVEST is a three-pillar financial web product:
72
+
73
+ 1. Knowledge Academy
74
+ 2. Trading Lab
75
+ 3. U2CHAT
76
+
77
+ Product thesis:
78
+
79
+ - learn
80
+ - practice
81
+ - analyze
82
+
83
+ It is meant to help beginner and intermediate investors:
84
+
85
+ - learn investing concepts
86
+ - practice in a simulated trading environment
87
+ - ask an AI assistant for market analysis and educational guidance
88
+
89
+ ## 4. Current tech stack
90
+
91
+ - Backend: Flask
92
+ - Frontend: HTML + inline CSS/JS in one primary template
93
+ - Styling: Tailwind via CDN
94
+ - Charts/visuals: ECharts + D3.js
95
+ - AI: LangGraph + OpenAI-compatible DeepSeek-style model
96
+ - Market data: AkShare
97
+ - Knowledge retrieval: Chroma + local PDFs
98
+ - Persistence:
99
+ - chat checkpoints in SQLite
100
+ - most visible product state is currently in memory
101
+
102
+ ## 4.1 Required rebuild stack direction
103
+
104
+ The current Flask-template-based frontend is too limited for the interaction quality we want.
105
+
106
+ For the rebuild:
107
+
108
+ - the frontend should be implemented in JavaScript or TypeScript
109
+ - TypeScript is preferred
110
+ - the frontend should use a modern framework suitable for rich interaction design
111
+
112
+ Preferred choices:
113
+
114
+ 1. React + TypeScript
115
+ 2. Next.js + TypeScript
116
+ 3. Vite + React + TypeScript
117
+
118
+ Alternative modern frontend stacks are acceptable only if they are clearly justified as better for this product.
119
+
120
+ Important rules:
121
+
122
+ - do not continue the primary UI architecture as one large Flask template
123
+ - do not treat Flask templating as the long-term frontend solution
124
+ - Flask may remain as a backend/API layer if useful
125
+ - the public website and product app should ideally be rebuilt in a modern JS/TS frontend architecture
126
+
127
+ Default preference:
128
+
129
+ - TypeScript + React-based architecture
130
+
131
+ ## 5. Current code structure
132
+
133
+ Key files:
134
+
135
+ - `templates/index.html`: primary frontend shell and almost all current UI logic
136
+ - `web_app.py`: Flask app, routes, in-memory product state
137
+ - `agent_graph.py`: LangGraph workflow
138
+ - `tools.py`: stock data and retrieval tools
139
+ - `vector_store.py`: PDF ingestion and vector DB build/load
140
+ - `main.py`: CLI agent test session
141
+
142
+ You should inspect these files directly before making changes.
143
+
144
+ ## 5.1 Mandatory discovery step
145
+
146
+ Before implementing the rebuild, do this:
147
+
148
+ 1. inspect the repo structure
149
+ 2. inspect the current Flask routes
150
+ 3. inspect the current frontend file
151
+ 4. inspect the agent/data/tool files
152
+ 5. identify which current features must be preserved
153
+ 6. identify which visible UI controls are partial or broken
154
+ 7. decide on the frontend rebuild architecture in JavaScript/TypeScript
155
+
156
+ Do not skip this audit.
157
+
158
+ ## 6. Core product truth you must preserve
159
+
160
+ - U2INVEST is not just an AI chat app
161
+ - It is intentionally a three-part product system
162
+ - The Academy, Lab, and U2CHAT should remain distinct but connected
163
+ - The redesign must not reduce scope
164
+ - The redesign must not collapse everything into one generic homepage
165
+ - The redesign must preserve the breadth of the current product while improving clarity
166
+
167
+ ## 7. Current implemented product features
168
+
169
+ ## 7.1 Landing / shell
170
+
171
+ Currently implemented:
172
+
173
+ - fixed top navigation
174
+ - brand/logo
175
+ - landing hero
176
+ - three entry cards for:
177
+ - Academy
178
+ - Lab
179
+ - U2CHAT
180
+ - in-browser view switching without page reload
181
+
182
+ Current issues:
183
+
184
+ - no real commercial homepage structure
185
+ - no professional footer
186
+ - no business/contact/social/legal layer
187
+ - no deep links
188
+ - no public marketing information architecture
189
+
190
+ ## 7.2 Knowledge Academy
191
+
192
+ Current implementation:
193
+
194
+ - 50 hardcoded learning modules
195
+ - module fields include:
196
+ - id
197
+ - parent
198
+ - category
199
+ - difficulty
200
+ - name
201
+ - video
202
+ - source
203
+ - views
204
+ - completed
205
+ - ratings
206
+ - intro
207
+ - outcomes
208
+ - takeaways
209
+ - course grid
210
+ - lesson overlay
211
+ - embedded YouTube lesson
212
+ - outcomes and takeaways panels
213
+ - completion toggle
214
+ - comment thread
215
+ - replies
216
+ - share modal
217
+ - roadmap mode
218
+ - custom roadmap mode
219
+ - add/delete/link custom nodes
220
+
221
+ Academy backend capabilities:
222
+
223
+ - get all courses
224
+ - get one course
225
+ - post comment
226
+ - like comment
227
+ - like reply
228
+ - toggle completion
229
+ - rate course
230
+
231
+ Academy frontend gaps and partials:
232
+
233
+ - comment like buttons are visible but broken because JS handlers are missing
234
+ - reply like buttons are visible but broken because JS handlers are missing
235
+ - rating average is shown but rating submission UI is missing
236
+ - share links point to `/module/:id` but the route does not exist
237
+ - comment timestamps are fake/static strings
238
+ - progress/comments/ratings are runtime-only
239
+ - custom roadmap is not persisted
240
+ - `source` exists in data but is not surfaced in the UI
241
+ - `parent` exists in data but is not used as a true learning dependency model
242
+
243
+ ## 7.3 Trading Lab
244
+
245
+ Current implementation:
246
+
247
+ - entry gateway with:
248
+ - advanced dashboard
249
+ - beginner guide
250
+ - 3-step beginner guide
251
+ - grouped stock pools:
252
+ - Popular
253
+ - Tech
254
+ - Energy
255
+ - Finance
256
+ - stock quote retrieval
257
+ - K-line chart area
258
+ - trade panel:
259
+ - symbol
260
+ - price
261
+ - shares
262
+ - total
263
+ - buy
264
+ - sell
265
+ - holdings panel
266
+ - history panel container
267
+ - portfolio stats:
268
+ - total assets
269
+ - cash
270
+ - profit
271
+ - return
272
+ - reset portfolio
273
+ - refresh dashboard
274
+
275
+ Trading Lab backend capabilities:
276
+
277
+ - get stock pool
278
+ - get quotes
279
+ - get K-line data
280
+ - get portfolio
281
+ - execute trade
282
+ - reset portfolio
283
+ - get synthetic market data
284
+
285
+ Trading Lab rules:
286
+
287
+ - starts with $100,000
288
+ - buy checks cash
289
+ - sell checks holdings
290
+ - frontend requires minimum 100 shares
291
+
292
+ Trading Lab frontend gaps and partials:
293
+
294
+ - `changeTimeRange()` buttons exist but the handler is missing
295
+ - trade history exists in backend state but is not rendered into `history-list`
296
+ - return stat exists in UI but is not updated
297
+ - portfolio profit is not mark-to-market
298
+ - stock selection uses `event.currentTarget` without passing event, so it is fragile
299
+ - backend trusts client-supplied price when executing trades
300
+ - state is in memory only
301
+
302
+ ## 7.4 U2CHAT
303
+
304
+ Current implementation:
305
+
306
+ - chat workspace
307
+ - sidebar with recent sessions
308
+ - new chat
309
+ - load chat history
310
+ - clear current chat
311
+ - quick stock selection chips by sector
312
+ - selected-stock chip strip
313
+ - auto-resizing textarea
314
+ - enter to send
315
+ - shift+enter for newline
316
+ - stop button state during generation
317
+ - assistant/user messages
318
+ - simple markdown-ish rendering
319
+ - chart rendering from `json-chart` code blocks
320
+
321
+ U2CHAT backend capabilities:
322
+
323
+ - create/load session
324
+ - invoke LangGraph agent
325
+ - persist visible session messages in memory
326
+ - store LangGraph checkpoints in SQLite
327
+ - list sessions
328
+ - get history
329
+ - clear one or all sessions
330
+
331
+ Agent capabilities:
332
+
333
+ - model reasoning
334
+ - tool routing
335
+ - real-time quote tool
336
+ - stock news tool
337
+ - historical K-line tool
338
+ - fundamentals tool
339
+ - knowledge-base retrieval tool
340
+
341
+ U2CHAT frontend gaps and partials:
342
+
343
+ - frontend does not receive true streaming output
344
+ - stop button aborts browser request only, not true backend cancellation
345
+ - `tools_used` is returned but not displayed
346
+ - visible chat state and persisted LangGraph memory are not unified
347
+ - session list disappears on server restart
348
+ - chart rendering is basic
349
+ - no source cards/citations UI
350
+ - no visible tool execution trace
351
+ - HTML rendering should be treated carefully in rebuild
352
+
353
+ ## 8. Full engineering function inventory
354
+
355
+ Use this as a feature-surface checklist.
356
+
357
+ ## 8.1 `web_app.py`
358
+
359
+ - `index()`
360
+ - `get_academy()`
361
+ - `get_course(cid)`
362
+ - `post_comment()`
363
+ - `like_comment_main()`
364
+ - `like_reply_unique()`
365
+ - `toggle_complete()`
366
+ - `rate_course()`
367
+ - `get_market_data()`
368
+ - `get_stock_pool()`
369
+ - `get_real_quote()`
370
+ - `get_kline_data()`
371
+ - `get_portfolio()`
372
+ - `execute_trade()`
373
+ - `reset_portfolio()`
374
+ - `agent_chat()`
375
+ - `get_chat_sessions()`
376
+ - `get_chat_history()`
377
+ - `clear_chat_history()`
378
+
379
+ ## 8.2 `agent_graph.py`
380
+
381
+ - `AgentState`
382
+ - `call_model(state)`
383
+ - `route_logic(state)`
384
+
385
+ ## 8.3 `tools.py`
386
+
387
+ - `get_realtime_quote(symbol)`
388
+ - `get_stock_news(symbol)`
389
+ - `get_historical_kline(symbol)`
390
+ - `get_fundamental_data(symbol)`
391
+ - `query_knowledge_base(query)`
392
+
393
+ ## 8.4 `vector_store.py`
394
+
395
+ - `build_vector_db(...)`
396
+
397
+ ## 8.5 `main.py`
398
+
399
+ - `start_interactive_session()`
400
+
401
+ ## 8.6 Frontend functions in `templates/index.html`
402
+
403
+ Global:
404
+
405
+ - `showView(v)`
406
+
407
+ Academy:
408
+
409
+ - `loadData()`
410
+ - `openModule(id)`
411
+ - `openShare()`
412
+ - `closeShare()`
413
+ - `copyLink()`
414
+ - `renderComments(list)`
415
+ - `replyAt(user, commentId)`
416
+ - `replyToReply(user, parentCommentId)`
417
+ - `cancelReply()`
418
+ - `postComment()`
419
+ - `setRoadmapMode(mode)`
420
+ - `initRoadmap()`
421
+ - `dragstarted(event, d)`
422
+ - `dragged(event, d)`
423
+ - `dragended(event, d)`
424
+ - `renderCustomRoadmap(g, svg)`
425
+ - `resetPorts()`
426
+ - `openConfirm(title, desc, onOk, onCancel)`
427
+ - `openNodeModal()`
428
+ - `closeNodeModal()`
429
+ - `addCustomNode()`
430
+ - `switchAcademy(tab)`
431
+ - `closeModule()`
432
+ - `renderStatusBox(isDone)`
433
+ - `toggleStatus(isDone)`
434
+ - `sortComments(type)`
435
+ - `showToast(msg)`
436
+
437
+ Trading Lab:
438
+
439
+ - `loadLabData()`
440
+ - `loadSectorStocks()`
441
+ - `selectStock(stock)`
442
+ - `initKlineChart()`
443
+ - `loadKlineData(symbol, days = 60)`
444
+ - `calculateTotal()`
445
+ - `executeTrade(action)`
446
+ - `updatePortfolioUI()`
447
+ - `resetPortfolio()`
448
+ - `refreshLab()`
449
+ - `updateGuideUI()`
450
+ - `nextGuideStep()`
451
+ - `prevGuideStep()`
452
+ - `setLabView(view)`
453
+
454
+ U2CHAT:
455
+
456
+ - `loadAgentData()`
457
+ - `loadAgentStocks()`
458
+ - `addStockToChat(stock)`
459
+ - `updateSelectedStocks()`
460
+ - `removeStock(i)`
461
+ - `sendMessage()`
462
+ - `updateSendButtonState()`
463
+ - `addMessageToUI(role, content, tools = [])`
464
+ - `renderChart(containerId, data)`
465
+ - `loadChatSessions()`
466
+ - `loadChatSession(sessionId)`
467
+ - `clearChat()`
468
+ - `newChat()`
469
+ - `handleAgentKey(e)`
470
+ - `autoResize(t)`
471
+
472
+ Currently referenced in UI but missing:
473
+
474
+ - `toggleLike(...)`
475
+ - `toggleReplyLike(...)`
476
+ - `changeTimeRange(...)`
477
+
478
+ ## 9. Commercial website requirement
479
+
480
+ This product must also function as a professional business and sales website.
481
+
482
+ That means the rebuild must include:
483
+
484
+ - homepage
485
+ - product overview
486
+ - pillar-specific product pages
487
+ - pricing or pricing inquiry
488
+ - about/company page
489
+ - contact page
490
+ - FAQ
491
+ - footer
492
+ - legal pages
493
+ - trust/proof sections
494
+ - contact/social/legal links
495
+ - demo/get-started flows
496
+
497
+ Do not leave U2INVEST as just an app shell with a hero.
498
+
499
+ ## 10. Commercial website information architecture
500
+
501
+ Recommended public-site routes:
502
+
503
+ - `/`
504
+ - `/product`
505
+ - `/product/academy`
506
+ - `/product/trading-lab`
507
+ - `/product/u2chat`
508
+ - `/pricing`
509
+ - `/about`
510
+ - `/contact`
511
+ - `/faq`
512
+ - `/resources`
513
+ - `/book-demo`
514
+ - `/get-started`
515
+
516
+ Legal routes:
517
+
518
+ - `/legal/privacy`
519
+ - `/legal/terms`
520
+ - `/legal/cookies`
521
+ - `/legal/disclaimer`
522
+ - `/legal/risk-disclosure`
523
+ - `/legal/accessibility`
524
+
525
+ Product app routes:
526
+
527
+ - `/app`
528
+ - `/app/academy`
529
+ - `/app/lab`
530
+ - `/app/chat`
531
+
532
+ If you cannot fully implement all routes in one pass, at least structure the design and code so this route model is the clear direction.
533
+
534
+ ## 11. Required public-site pages
535
+
536
+ ## 11.1 Home
537
+
538
+ Must include:
539
+
540
+ - strong value proposition
541
+ - explanation of the three pillars
542
+ - trust strip
543
+ - product overview
544
+ - why U2INVEST
545
+ - proof/testimonial placeholder area
546
+ - FAQ preview
547
+ - CTA band
548
+ - professional footer
549
+
550
+ ## 11.2 Product overview
551
+
552
+ Must explain:
553
+
554
+ - learn
555
+ - practice
556
+ - analyze
557
+
558
+ And how Academy, Lab, and U2CHAT work together.
559
+
560
+ ## 11.3 Academy page
561
+
562
+ Must sell the learning experience clearly.
563
+
564
+ ## 11.4 Trading Lab page
565
+
566
+ Must explain the simulation environment and include a clear simulation disclaimer.
567
+
568
+ ## 11.5 U2CHAT page
569
+
570
+ Must explain the AI assistant, data usage, and responsible-use framing.
571
+
572
+ ## 11.6 Pricing page
573
+
574
+ Use real pricing if available. If not, build:
575
+
576
+ - plan placeholders
577
+ - pricing inquiry
578
+ - contact sales / book demo CTA
579
+
580
+ ## 11.7 About page
581
+
582
+ Must build company and product trust.
583
+
584
+ ## 11.8 Contact page
585
+
586
+ Must include:
587
+
588
+ - contact form
589
+ - business email
590
+ - inquiry routing
591
+ - social links
592
+ - expected response note
593
+
594
+ ## 11.9 FAQ page
595
+
596
+ Must answer:
597
+
598
+ - what the product is
599
+ - who it is for
600
+ - what is simulated vs live
601
+ - what the AI can and cannot do
602
+ - pricing/access questions
603
+ - support questions
604
+
605
+ ## 11.10 Legal pages
606
+
607
+ Must include at minimum:
608
+
609
+ - privacy policy
610
+ - terms of service
611
+ - disclaimer
612
+ - risk disclosure
613
+
614
+ ## 12. Footer specification
615
+
616
+ The footer should exist across all public pages and include:
617
+
618
+ Product:
619
+
620
+ - Product
621
+ - Academy
622
+ - Trading Lab
623
+ - U2CHAT
624
+ - Pricing
625
+
626
+ Company:
627
+
628
+ - About
629
+ - Contact
630
+ - Book Demo
631
+
632
+ Resources:
633
+
634
+ - FAQ
635
+ - Resources
636
+ - Support
637
+
638
+ Legal:
639
+
640
+ - Privacy Policy
641
+ - Terms of Service
642
+ - Disclaimer
643
+ - Risk Disclosure
644
+ - Cookie Policy
645
+ - Accessibility
646
+
647
+ Contact:
648
+
649
+ - business email
650
+ - optional phone
651
+ - optional location
652
+
653
+ Social:
654
+
655
+ - LinkedIn
656
+ - X/Twitter if used
657
+ - GitHub if relevant
658
+ - YouTube if relevant
659
+
660
+ Utility:
661
+
662
+ - copyright
663
+ - company name
664
+ - year
665
+
666
+ ## 13. CTA architecture
667
+
668
+ Global primary CTA:
669
+
670
+ - `Get Started`
671
+
672
+ Global secondary CTA:
673
+
674
+ - `Book Demo`
675
+
676
+ Additional CTAs where appropriate:
677
+
678
+ - `Explore Product`
679
+ - `Contact Us`
680
+ - `Enter App`
681
+ - `View Pricing`
682
+ - `Start Learning`
683
+ - `Try the Lab`
684
+ - `Try U2CHAT`
685
+
686
+ Rules:
687
+
688
+ - every major page needs a clear next action
689
+ - homepage hero must have primary and secondary CTA
690
+ - footer should include conversion pathways
691
+ - product pages should route to either product exploration or conversion
692
+
693
+ ## 14. Lead generation and forms
694
+
695
+ The commercial website should support:
696
+
697
+ - contact form
698
+ - demo request form
699
+ - get-started / lead capture
700
+ - optional newsletter capture
701
+
702
+ Required form behavior:
703
+
704
+ - client-side validation
705
+ - server-side validation if implemented
706
+ - success state
707
+ - error state
708
+ - routing to email/CRM/inbox
709
+
710
+ Recommended contact/demo fields:
711
+
712
+ - name
713
+ - email
714
+ - company
715
+ - role
716
+ - inquiry type
717
+ - message
718
+ - consent checkbox
719
+
720
+ ## 15. Trust, legal, and finance-specific requirements
721
+
722
+ Because this is a finance-related product, the public website and app must clearly communicate:
723
+
724
+ - educational vs advisory scope
725
+ - what is live data vs simulated data
726
+ - Trading Lab is simulated
727
+ - AI outputs have limitations
728
+ - responsible-use framing
729
+ - risk disclosure where appropriate
730
+
731
+ The website should include:
732
+
733
+ - trust/proof section
734
+ - methodology explanation
735
+ - source/data explanation
736
+ - privacy/security positioning
737
+ - legal/disclaimer visibility
738
+
739
+ ## 16. SEO and analytics requirements
740
+
741
+ The rebuild should support:
742
+
743
+ - semantic headings
744
+ - page titles and meta descriptions
745
+ - Open Graph metadata
746
+ - sitemap/robots strategy
747
+ - internal linking
748
+ - analytics
749
+ - CTA click tracking
750
+ - form conversion tracking
751
+
752
+ ## 17. UX gaps you should fix if safe
753
+
754
+ Fix obvious front-end-only issues while redesigning.
755
+
756
+ Highest-priority known gaps:
757
+
758
+ - missing `toggleLike()`
759
+ - missing `toggleReplyLike()`
760
+ - missing `changeTimeRange()`
761
+ - unrendered `history-list`
762
+ - unupdated `return-rate`
763
+ - fragile stock selection event handling
764
+ - rating UI missing even though backend endpoint exists
765
+ - share links point to a route not currently implemented
766
+ - visible tool metadata not surfaced in chat
767
+
768
+ Keep fixes coherent and production-minded.
769
+
770
+ ## 18. Rebuild expectations
771
+
772
+ You may refactor heavily.
773
+
774
+ Preferred direction:
775
+
776
+ - replace the current Flask-template-centric frontend architecture with a modern JS/TS frontend architecture
777
+ - reduce the single-file frontend burden
778
+ - move styles/scripts to maintainable frontend modules
779
+ - introduce design tokens
780
+ - introduce reusable components
781
+ - create clearer separation between:
782
+ - public business website
783
+ - product application
784
+ - backend/API responsibilities
785
+
786
+ Strong recommendation:
787
+
788
+ - use TypeScript for the frontend
789
+ - use a component-based UI architecture
790
+ - create route-based separation between public website pages and product-app pages
791
+
792
+ Flask can remain if useful for:
793
+
794
+ - API endpoints
795
+ - legacy compatibility
796
+ - transitional backend support
797
+
798
+ But the UI itself should not continue to be built primarily inside Flask templates.
799
+
800
+ You must preserve existing working flows while improving:
801
+
802
+ - clarity
803
+ - hierarchy
804
+ - maintainability
805
+ - responsiveness
806
+ - accessibility
807
+ - conversion quality
808
+
809
+ ## 19. Accessibility and responsiveness
810
+
811
+ Ensure:
812
+
813
+ - visible keyboard focus states
814
+ - readable contrast
815
+ - intentional mobile layouts
816
+ - usable modals/overlays on small screens
817
+ - touch-friendly CTA sizing
818
+ - good form usability
819
+
820
+ ## 20. Deliverables
821
+
822
+ Provide:
823
+
824
+ - updated UI implementation
825
+ - updated frontend architecture using JavaScript/TypeScript or another clearly justified modern frontend stack
826
+ - public commercial website improvements
827
+ - improved app workspace UI
828
+ - a short design-system summary
829
+ - a short list of UX bugs fixed
830
+ - a short note on any commercial pages/flows you added or scaffolded
831
+ - a short note on the frontend architecture choice and migration approach
832
+
833
+ ## 21. Outcome standard
834
+
835
+ The final result should feel like:
836
+
837
+ - a polished minimalist finance product
838
+ - a credible commercial business website
839
+ - a trustworthy research/education platform
840
+
841
+ It should be:
842
+
843
+ - commercially presentable
844
+ - aesthetically restrained
845
+ - easier to use
846
+ - easier to navigate
847
+ - clearer in scope
848
+ - stronger in trust and conversion
849
+
850
+ It must not feel like:
851
+
852
+ - a demo page
853
+ - a single unfinished landing page
854
+ - a generic AI template
855
+ - a noisy trading dashboard
856
+
857
+ ## 22. Before coding
858
+
859
+ Inspect at minimum:
860
+
861
+ - `templates/index.html`
862
+ - `web_app.py`
863
+ - `agent_graph.py`
864
+ - `tools.py`
865
+ - `vector_store.py`
866
+
867
+ Treat this prompt as the full handoff brief.
868
+
869
+ You should assume zero prior knowledge and build your understanding from the codebase itself.
UI_REDESIGN_AGENT_PROMPT.md ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Improve the UI of this repo while preserving the current product scope and functionality.
2
+
3
+ Assume you have never seen this project before and have no prior knowledge of the repo, source code, or implementation details. Inspect the codebase first and verify the current state before making decisions.
4
+
5
+ Project context:
6
+
7
+ - This is `U2INVEST`, a Flask-based single-page web app with three pillars:
8
+ - Knowledge Academy
9
+ - Trading Lab
10
+ - U2CHAT
11
+ - This should also be treated as a commercial business website, not only an in-app product UI
12
+ - Main backend routes are in `web_app.py`
13
+ - The current frontend is mostly in `templates/index.html`
14
+ - The app already uses Tailwind via CDN, D3.js, ECharts, Bootstrap Icons, and custom inline CSS/JS
15
+ - The product already has working interactions for:
16
+ - academy modules and lesson overlay
17
+ - comments/replies
18
+ - roadmap view and custom roadmap editing
19
+ - lab stock pool, chart, and trading actions
20
+ - AI chat, sessions, and inline chart rendering
21
+
22
+ Frontend architecture requirement:
23
+
24
+ - Do not continue the main UI as a large Flask-template frontend
25
+ - Rebuild the frontend in JavaScript or TypeScript
26
+ - TypeScript is preferred
27
+ - Preferred stack is React + TypeScript, Next.js + TypeScript, or Vite + React + TypeScript
28
+ - Flask may remain as backend/API infrastructure if useful, but should not remain the primary frontend UI architecture
29
+
30
+ Primary design objective:
31
+
32
+ Redesign the UI into a calm, premium, minimalist product language influenced by Notion, Manus, and Apple:
33
+
34
+ - Notion: clarity, restraint, content-first layout, excellent spacing
35
+ - Manus: focused workspace feel, structured productivity surfaces
36
+ - Apple: polish, hierarchy, motion discipline, premium simplicity
37
+
38
+ Do not make it look like a generic AI template or a flashy fintech dashboard. It should feel intentional, editorial, and highly usable.
39
+
40
+ What I want from the redesign:
41
+
42
+ - Cleaner information hierarchy
43
+ - Stronger spacing rhythm and typography
44
+ - More premium visual consistency across all three product areas
45
+ - A public-facing business website layer that feels commercially credible
46
+ - Better desktop and mobile responsiveness
47
+ - Better empty, loading, hover, focus, and success states
48
+ - Better visual transitions without over-animation
49
+ - A simpler and more elegant experience while keeping the app feature-rich
50
+
51
+ Hard constraints:
52
+
53
+ - Preserve all current product areas and flows
54
+ - Do not remove Academy, Trading Lab, U2CHAT, roadmap mode, comments, beginner guide, or chat sessions
55
+ - Add commercial website capabilities without flattening the product into a generic landing page
56
+ - Keep the existing Flask routes and API contracts unless a very small frontend-safe improvement is required
57
+ - Preserve D3 roadmap and ECharts chart functionality
58
+ - Preserve the existing logo/brand identity, but refine how the brand is used
59
+ - Use CSS variables for color, spacing, radii, and shadow system
60
+ - Avoid purple-heavy gradients, overuse of glassmorphism, neon fintech visuals, and "AI slop" aesthetics
61
+ - Keep the UI minimal, but not empty or sterile
62
+
63
+ Stylistic direction:
64
+
65
+ - Base palette: warm white / soft paper / graphite / muted gray
66
+ - Accent palette: disciplined use of the existing blue brand color, softened and modernized
67
+ - Typography: more intentional than the current default; choose a refined font pairing if appropriate
68
+ - Surfaces: layered but subtle, with soft borders and almost no heavy contrast blocks
69
+ - Motion: gentle page transitions, overlay transitions, chart panel reveals, hover elevation only where useful
70
+ - Components: rounded, but not cartoonish; closer to Apple/Notion restraint than startup landing-page style
71
+
72
+ Product-specific goals:
73
+
74
+ 1. Landing page
75
+ - Make the first screen feel premium and immediately understandable
76
+ - Present the three pillars as elegant product choices, not oversized marketing cards
77
+ - Make the landing experience work as a real commercial homepage
78
+ - Improve the top nav and hero composition
79
+ - Add a proper footer, business contact area, social links, and legal link area
80
+ - Add trust-building and conversion sections such as product overview, proof, FAQ, and CTA structure
81
+
82
+ 2. Knowledge Academy
83
+ - Make the course grid feel more curated and less visually noisy
84
+ - Improve the lesson overlay so it feels like a polished reading + video workspace
85
+ - Improve comments UI to feel cleaner and more credible
86
+ - Redesign the roadmap controls and roadmap container to feel more like a premium knowledge canvas
87
+ - Keep both "Designed By U2INVEST" and "You to Design" modes
88
+
89
+ 3. Trading Lab
90
+ - Move away from a cramped dashboard look
91
+ - Make the lab feel like a calm professional workspace
92
+ - Improve stock list readability, chart prominence, and order ticket clarity
93
+ - Improve the beginner guide so it feels educational and beautifully paced
94
+ - Make stats, holdings, and history feel coherent rather than bolted on
95
+
96
+ 4. U2CHAT
97
+ - Make the chat area feel like a premium research assistant workspace
98
+ - Improve the sidebar, session list, input area, quick stock selection, and message presentation
99
+ - Improve embedded chart presentation inside messages
100
+ - Make assistant responses easier to scan
101
+
102
+ 5. Commercial website layer
103
+ - Add or redesign the public-facing business website components needed for a professional commercial product
104
+ - Include at minimum:
105
+ - contact pathway
106
+ - social links
107
+ - about/company presence
108
+ - trust/proof sections
109
+ - CTA hierarchy
110
+ - support/help or inquiry path
111
+ - legal/footer structure
112
+ - If full multi-page implementation is too large for one pass, create a strong homepage + footer + contact/demo structure that clearly scaffolds the commercial experience
113
+
114
+ Commercial website expectations:
115
+
116
+ - Homepage should sell the product clearly
117
+ - Add visible CTAs such as `Get Started`, `Book Demo`, `Contact`, or `Explore Product`
118
+ - Add a professional footer with:
119
+ - email/contact
120
+ - social links
121
+ - legal links
122
+ - copyright/company info
123
+ - Add trust sections such as:
124
+ - product explanation
125
+ - why U2INVEST
126
+ - proof/testimonial/case-study placeholder areas
127
+ - finance/disclaimer trust language where appropriate
128
+ - Add public information surfaces for:
129
+ - About
130
+ - Contact
131
+ - FAQ
132
+ - Pricing or pricing inquiry
133
+ - Legal/disclaimer links
134
+ - The result should feel like a product a real customer could discover, evaluate, and contact
135
+
136
+ UX improvements that should be included if they can be done safely:
137
+
138
+ - Implement or repair any obviously broken front-end-only UX gaps you encounter
139
+ - In particular, check the Trading Lab for:
140
+ - missing `changeTimeRange()` behavior
141
+ - unrendered `history-list`
142
+ - unupdated `return-rate`
143
+ - any fragile event handling in stock selection
144
+ - Keep those fixes small and directly related to the user experience
145
+
146
+ Implementation expectations:
147
+
148
+ - You may refactor `templates/index.html` heavily if needed
149
+ - If it improves maintainability, extract styles and scripts into `static/` assets
150
+ - Keep the implementation coherent and production-minded
151
+ - Preserve existing behaviors while improving visual structure
152
+ - Add concise comments only where the logic is genuinely hard to follow
153
+
154
+ Accessibility and responsiveness:
155
+
156
+ - Ensure good contrast and readable type sizes
157
+ - Ensure keyboard-focus states are visible
158
+ - Ensure mobile layouts are deliberate, not just squashed desktop layouts
159
+ - Ensure major overlays, controls, and charts remain usable on smaller screens
160
+
161
+ Deliverables:
162
+
163
+ - Updated UI implementation
164
+ - A short summary of the design system you introduced
165
+ - A short list of any UX bugs you fixed while redesigning
166
+ - No unnecessary backend rewrites
167
+
168
+ Before coding, inspect:
169
+
170
+ - `templates/index.html`
171
+ - `web_app.py`
172
+ - `CURRENT_PROJECT_PRD.md`
173
+ - `COMMERCIAL_WEBSITE_SITEMAP_AND_PAGE_SPEC.md`
174
+
175
+ Use `CURRENT_PROJECT_PRD.md` as the source of truth for:
176
+
177
+ - full current feature inventory
178
+ - full function inventory
179
+ - visible-but-partial or broken UI controls
180
+ - UI rebuild requirements
181
+ - advancement opportunities that can influence the redesign structure
182
+ - commercial website requirements and trust/conversion expectations
183
+ - sitemap, page-by-page website structure, CTA rules, footer requirements, and lead funnel design
184
+
185
+ Outcome standard:
186
+
187
+ The final UI should feel like a polished minimalist product for thoughtful investors and a credible commercial business website, not a demo page. It should be simpler, calmer, more premium, easier to use, and more trustworthy, while preserving the breadth of the current product.
USER_GUIDE.md ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # U2INVEST User Guide
2
+
3
+ **Your path, Your Choice, Your Future, You to Invest.**
4
+
5
+ Welcome to the complete walkthrough of the U2INVEST platform. This guide demonstrates every feature of our comprehensive financial education and analysis system.
6
+
7
+ ---
8
+
9
+ ## 1. Landing Page & Navigation
10
+ Your gateway to financial literacy. The clean interface allows you to jump straight into one of our three core pillars.
11
+
12
+ ![Front Page](static/screenshots/Front%20Page.png)
13
+
14
+ * **Academy:** For structured learning.
15
+ * **Lab:** For risk-free practice.
16
+ * **U2CHAT:** For AI-assisted analysis.
17
+
18
+ ---
19
+
20
+ ## 2. Knowledge Academy
21
+ The Academy is designed to take you from novice to pro through structured coursework.
22
+
23
+ ![Knowledge Academy](static/screenshots/Knowledge%20Academy.png)
24
+
25
+ ### 2.1 Core Features
26
+ The main dashboard offers two views: **Course Modules** (Grid View) and **Learning Roadmap** (Tree View). You can track your progress and difficulty levels at a glance.
27
+
28
+ ![Show Module](static/screenshots/Show%20Module.png)
29
+
30
+ ### 2.2 Learning Roadmap (Visual Progression)
31
+ We use a D3.js interactive tree to visualize your learning path.
32
+ * **Standard Mode:** Follow our curated path from "Foundations" (Blue) to "Advanced" (Dark Blue) to "Professional" (Purple).
33
+ ![Learning Roadmap](static/screenshots/Learning%20Roadmap.png)
34
+
35
+ * **Design By Yourself Mode:** Switch to "You to Design" to create your own mental map.
36
+ ![Design By Yourself Roadmap](static/screenshots/Design%20By%20Yourself%20Roadmap.png)
37
+ * **Add Concepts:** Create custom nodes for topics you want to study.
38
+ ![Add Concept](static/screenshots/Add%20Concept.png)
39
+ * **Link Nodes:** Connect ideas to build your own knowledge graph.
40
+ ![Link Node](static/screenshots/Link%20Node.png)
41
+
42
+ ### 2.3 Module Interface
43
+ Clicking any topic opens the learning module.
44
+ * **Video Lessons:** High-quality content curated from top financial educators.
45
+ ![Module Video](static/screenshots/Module%20Video.png)
46
+ * **Community:** Discuss topics with other learners.
47
+ ![Comments](static/screenshots/comments.png)
48
+ * **Progress Tracking:** Mark lessons as complete to earn your badge.
49
+ ![After Completed Module](static/screenshots/After%20Completed%20Module.png)
50
+ * **Share:** Share your progress on social media.
51
+ ![Share Progress](static/screenshots/Share%20Progress.png)
52
+
53
+ ---
54
+
55
+ ## 3. Trading Lab
56
+ Before risking real money, master the market here with **$100,000 virtual cash**.
57
+
58
+ ![Lab Options](static/screenshots/Lab%20Options.png)
59
+
60
+ ### 3.1 Beginner Guide (Investment 101)
61
+ New to stocks? Our interactive guide walks you through the basics before you trade.
62
+ * **Step 1: Ownership:** Understand what a stock actually is.
63
+ ![Step 1](static/screenshots/Step%201.png)
64
+ * **Step 2: Risk:** Learn about diversification.
65
+ ![Step 2](static/screenshots/Step%202.png)
66
+ * **Step 3: Execution:** How to read the dashboard.
67
+ ![Step 3](static/screenshots/Step%203.png)
68
+ * **Buy/Sell Guide:** Clear instructions on placing orders.
69
+ ![Buy and Sell Guide](static/screenshots/Buy%20and%20Sell%20Guide.png)
70
+
71
+ ### 3.2 Professional Dashboard (The Lab)
72
+ For advanced users, the Lab offers a professional trading interface.
73
+ * **Real-time Data:** Live prices for A-share stocks (Moutai, CATL, etc.).
74
+ * **Interactive Charts:** Zoomable K-Line charts (60/120/250 days).
75
+ * **Order Entry:** Buy and Sell instantly.
76
+ * **Portfolio Tracking:** Monitor your Cash, Holdings, and Returns in real-time.
77
+
78
+ ![Trading Lab](static/screenshots/Trading%20Lab.png)
79
+
80
+ ---
81
+
82
+ ## 4. U2CHAT (AI Agent)
83
+ Your 24/7 Financial Analyst, powered by **DeepSeek-V3** and **LangGraph**.
84
+
85
+ ![U2Chat](static/screenshots/U2Chat.png)
86
+
87
+ ### 4.1 Advanced Reasoning
88
+ Unlike basic bots, U2CHAT "thinks" before it answers. It breaks down complex queries into logical steps.
89
+ ![U2Chat Think](static/screenshots/U2Chat%20Think.png)
90
+
91
+ ### 4.2 Market Analysis
92
+ Ask about any stock (e.g., "Analyze Moutai"). The agent fetches real-time data and provides a professional breakdown.
93
+ ![U2Chat Analysis](static/screenshots/U2Chat%20Analysis.png)
94
+
95
+ ### 4.3 Data Visualization
96
+ The agent doesn't just talk; it draws. It generates interactive price charts right in the chat window.
97
+ ![U2Chat Data Visualization](static/screenshots/U2Chat%20Data%20Visualization.png)
98
+
99
+ ### 4.4 Strategic Suggestions
100
+ It can combine real-time data with its internal knowledge base (RAG) to offer investment strategies.
101
+ ![U2Chat Suggestion](static/screenshots/U2Chat%20Suggestion.png)
102
+
103
+ ---
104
+
105
+ ## Architecture
106
+ For the tech-savvy, here is how U2INVEST works under the hood:
107
+
108
+ ![Architecture](static/images/stock_agent_arch.png)
_profile_repo ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 8648f49f063078217c7cf0b3e450a8628e342e94
_remote_repo ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit e0e39e339549c7cd8f647aab91009a7df6c709bb
agent_graph.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sqlite3
3
+ from typing import Annotated, TypedDict
4
+ from dotenv import load_dotenv
5
+ from langchain_openai import ChatOpenAI
6
+ from langchain_core.messages import SystemMessage # Added for persona
7
+ from langgraph.graph import StateGraph, END
8
+ from langgraph.graph.message import add_messages
9
+ from langgraph.prebuilt import ToolNode
10
+ from langgraph.checkpoint.sqlite import SqliteSaver
11
+ from tools import tools
12
+ from runtime_config import CHECKPOINTS_DB_PATH
13
+
14
+ load_dotenv()
15
+
16
+ DEEPSEEK_MODEL = os.getenv("DEEPSEEK_MODEL", "deepseek-chat")
17
+ DEEPSEEK_BASE_URL = os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com")
18
+
19
+ # 1. Define State
20
+ class AgentState(TypedDict):
21
+ messages: Annotated[list, add_messages]
22
+
23
+ # 2. Setup LLM & Tools
24
+ llm = ChatOpenAI(
25
+ model=DEEPSEEK_MODEL,
26
+ openai_api_key=os.getenv("DEEPSEEK_API_KEY"),
27
+ openai_api_base=DEEPSEEK_BASE_URL,
28
+ temperature=0
29
+ )
30
+ llm_with_tools = llm.bind_tools(tools)
31
+
32
+ # 3. Define Nodes
33
+ def call_model(state: AgentState):
34
+ """
35
+ Node for LLM reasoning with a professional persona and structured logic.
36
+ """
37
+ # Define the core instructions for the AI
38
+ # 在 call_model 函数中修改 SystemMessage
39
+ system_message = SystemMessage(content="""You are the 'U2CHAT bot', a professional stock analysis assistant.
40
+ Your goal is to provide objective and analytical financial guidance.
41
+
42
+ Core Directives:
43
+ 1. Language: Respond exclusively in English.
44
+ 2. Brevity & Structure: Be concise. Use clear headings (###), bullet points, and short paragraphs. Avoid "walls of text".
45
+ 3. Clean Formatting: Strictly DO NOT use double asterisks (**) for emphasis within sentences or around single words. Use standard Markdown headers for organization only.
46
+ 4. Data Visualization: Whenever analyzing a stock (e.g., K-line trends, price history), you MUST provide the data in a structured JSON block wrapped in ```json-chart``` tags.
47
+ Format:
48
+ ```json-chart
49
+ {
50
+ "type": "line",
51
+ "title": "Title of the Chart",
52
+ "labels": ["Jan", "Feb", "Mar"],
53
+ "data": [100, 120, 110]
54
+ }
55
+ ```
56
+ Supported types: "line", "bar". Ensure 'labels' and 'data' arrays have the same length.
57
+
58
+ Response Template:
59
+ ### Market Overview: (1-2 sentences on current status)
60
+ ### Key Data: (Include the json-chart block here if applicable, or a Markdown Table)
61
+ ### Technical Analysis: (Brief bullet points on trends/indicators)
62
+ ### Visual Trend: (A simple ASCII-based visual or directional emoji chart)
63
+
64
+ Tone: Professional, objective, and analytical.""")
65
+
66
+ # Inject the system message at the start of the conversation
67
+ messages = [system_message] + state["messages"]
68
+ response = llm_with_tools.invoke(messages)
69
+ return {"messages": [response]}
70
+
71
+ def route_logic(state: AgentState):
72
+ """Router to decide if tools are needed."""
73
+ last_msg = state["messages"][-1]
74
+ return "tools_executor" if last_msg.tool_calls else END
75
+
76
+ # 4. Persistence Setup
77
+ # Connection remains open for the lifecycle of the app
78
+ conn = sqlite3.connect(str(CHECKPOINTS_DB_PATH), check_same_thread=False)
79
+ memory = SqliteSaver(conn)
80
+
81
+ # 5. Build Graph
82
+ workflow = StateGraph(AgentState)
83
+
84
+ workflow.add_node("llm_reasoning", call_model)
85
+ workflow.add_node("tools_executor", ToolNode(tools))
86
+
87
+ workflow.set_entry_point("llm_reasoning")
88
+ workflow.add_conditional_edges("llm_reasoning", route_logic)
89
+ workflow.add_edge("tools_executor", "llm_reasoning")
90
+
91
+ # 6. Compile with Checkpointer
92
+ stock_agent_app = workflow.compile(checkpointer=memory)
contact/116668-708909865_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34b985c5246140e3a08a606f17e6131803a9d5d88ac2aaa35b3663f07fa6ea28
3
+ size 3384285
contact/210149_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c86ddc517ebba3643be01bff73fac05222eddf3f3a27c27399cb57a64e788c50
3
+ size 8184856
contact/219046_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a8483eb08d98c694b63324377d67f4d479c21bcb7fcc0c5a9740f53c70ea02a
3
+ size 12589087
contact/262213_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:589deff48fddb9c3a0b6191210df904f4e7311c41d1ad6ba9b94178d9eee3393
3
+ size 32218404
contact/262412_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:046052aaef66852892f7023b464a2111d9ff0176f58a6167416f25358cc192ba
3
+ size 50511541
contact/338978_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:394f97048829cd572f63d003b936a159bb4fb9ecbb99e68ea947557fe9243ee1
3
+ size 41512897
contact/85270-590799476_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22ce139e32758d7cf2dc489d070fdc6d5ac7b35e8703d319577df1a564d53ffd
3
+ size 13159516
contact/85271-590799487_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39c2192663ceb19a5beb6fe6a9cfc3364f2e06726b0b8927368cfd326663efc7
3
+ size 15138021
contact/85273-590799512_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:990c202d0a485758f81e93b994eec17f64ea13c8d89341ee3f65743a9f6c1a69
3
+ size 8662396
contact/85275-590799527_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:66634404c23788f77628e4659eb43ea5236eda5d42f048fbe9f28b5c755d5ec0
3
+ size 9090415
contact/85277-590799536_medium.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbd7ba6f94df9184920e38a66608132657411d7450ff2051268a13d1e9ff4a81
3
+ size 10847312
docker-compose.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ u2invest:
3
+ build: .
4
+ ports:
5
+ - "5000:10000"
6
+ env_file:
7
+ - .env
8
+ environment:
9
+ PORT: 10000
10
+ FLASK_DEBUG: "false"
11
+ DATA_DIR: /app/data
12
+ CHECKPOINTS_DB_PATH: /app/data/checkpoints.sqlite
13
+ CHROMA_DB_DIR: /app/data/chroma_db
14
+ HF_HOME: /app/data/hf-home
15
+ SENTENCE_TRANSFORMERS_HOME: /app/data/sentence-transformers
16
+ volumes:
17
+ - ./data:/app/data
18
+ restart: unless-stopped
knowledge/ssrn-A First Look at Financial Data Analysis Using ChatGPT-4o-4849578.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74a12f656413f7643cb6feb0b1c38c27427b5f370729c538d7a25b767bb5ba36
3
+ size 1884484
knowledge/ssrn-Defining and Measuring Financial Literacy-1498674.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de362f2e020adddd4a903db7a7afaedc44beeb15e609d7a2023f9ef5e8e8d96e
3
+ size 163773
knowledge/ssrn-Financial Machine Learning-4501707.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2068d89c2a7bfe38de36f695186991a16b6e5c87724751083d351993f119cce
3
+ size 4923283
knowledge/ssrn-From the Stockholder to the Stakeholder How Sustainability Can Drive Financial Outperformance-2508281.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39e3b4268068f5324e180a6dae0f12a557aeb8bd3dcd0fd0ce0a9800ec2e09fa
3
+ size 7240491
knowledge/ssrn-In Search of the Origins of Financial Fluctuations The Inelastic Markets Hypothesis-3686935.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d95861a4a06f9a2efff89f47b7f782df365c83bb82b90a4ffbcfb953bb771eb2
3
+ size 4043994
knowledge/ssrn-International Financial Reporting Standards (IFRS) Pros and Cons for Investors-929561.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e293e3413967f394f09123020ae13832e2e0b59311252332356cdbb0db8d628
3
+ size 279399
knowledge/ssrn-Stock Market Charts You Never Saw-3050736.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64fe96a9e0263b965e93a5710ede9f2f7075c032d47c8f85e44f1c8b3ba9343c
3
+ size 1273819
knowledge/ssrn-Study and Analysis of Chat GPT and its Impact on Different Fields of Study4402499.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e97d01b82f1272b62fc2f6cb627abe08d143e82c785dcc487ebef405f84eb415
3
+ size 561644
knowledge/ssrn-Taxes, Financing Decisions, and Firm Value-1871.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9bb1cd800eaceee113c970acb9786374321826fdb9b843628de38aecce90b3c2
3
+ size 131359
knowledge/ssrn-The Financial Statements Analysis-3794864.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a10fa23ded8b0dc93d52c0d1ab6ceccfb7156e551b9d91337c97610bc7d4beb
3
+ size 622380
knowledge/ssrn-Towards a New Financial Statement Analysis-4845596.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:861b6955f5ba039a3d3a96c6df1fff46065ee1b2cf174af2347f0f5d815780bd
3
+ size 1368037
main.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+ from agent_graph import stock_agent_app
3
+
4
+ def start_interactive_session():
5
+ print("=== Stock AI Agent Ready ===")
6
+ print("Type 'exit' to quit.\n")
7
+
8
+ # Generate a unique session ID for this run
9
+ # This allows the SQLite database to track this specific conversation
10
+ session_id = str(uuid.uuid4())
11
+ config = {"configurable": {"thread_id": session_id}}
12
+
13
+ print(f"Session started with ID: {session_id}\n")
14
+
15
+ while True:
16
+ user_input = input("User: ")
17
+ if user_input.lower() in ['exit', 'quit', 'q']:
18
+ print("Closing session...")
19
+ break
20
+
21
+ # The 'messages' list is appended in the graph state
22
+ initial_state = {"messages": [("user", user_input)]}
23
+
24
+ # IMPORTANT: Pass the 'config' variable as the second argument
25
+ # This triggers the SqliteSaver to save/load memory for this thread_id
26
+ for event in stock_agent_app.stream(initial_state, config):
27
+ for node_name, output in event.items():
28
+ print(f"\n[Executing Node: {node_name}]")
29
+
30
+ # Retrieve the last message produced by this node
31
+ if "messages" in output:
32
+ last_msg = output["messages"][-1]
33
+
34
+ # Only print if there is text content (ignore tool-call metadata)
35
+ if hasattr(last_msg, 'content') and last_msg.content:
36
+ print(f"AI: {last_msg.content}")
37
+
38
+ if __name__ == "__main__":
39
+ start_interactive_session()
market_demo.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ from datetime import datetime, timedelta
3
+
4
+ MARKET_POOL = {
5
+ "Mega Cap": ["AAPL", "MSFT", "NVDA", "AMZN", "META"],
6
+ "Growth": ["TSLA", "AMD", "PLTR", "COIN"],
7
+ "ETFs": ["SPY", "QQQ", "IWM", "GLD"],
8
+ "Crypto": ["BTC-USD", "ETH-USD", "SOL-USD"],
9
+ }
10
+
11
+ MARKET_META = {
12
+ "AAPL": {"name": "Apple", "base_price": 212.0, "sector": "Mega Cap", "asset_type": "equity"},
13
+ "MSFT": {"name": "Microsoft", "base_price": 428.0, "sector": "Mega Cap", "asset_type": "equity"},
14
+ "NVDA": {"name": "NVIDIA", "base_price": 134.0, "sector": "Mega Cap", "asset_type": "equity"},
15
+ "AMZN": {"name": "Amazon", "base_price": 186.0, "sector": "Mega Cap", "asset_type": "equity"},
16
+ "META": {"name": "Meta", "base_price": 498.0, "sector": "Mega Cap", "asset_type": "equity"},
17
+ "TSLA": {"name": "Tesla", "base_price": 196.0, "sector": "Growth", "asset_type": "equity"},
18
+ "AMD": {"name": "AMD", "base_price": 168.0, "sector": "Growth", "asset_type": "equity"},
19
+ "PLTR": {"name": "Palantir", "base_price": 28.0, "sector": "Growth", "asset_type": "equity"},
20
+ "COIN": {"name": "Coinbase", "base_price": 238.0, "sector": "Growth", "asset_type": "equity"},
21
+ "SPY": {"name": "SPDR S&P 500 ETF", "base_price": 518.0, "sector": "ETFs", "asset_type": "etf"},
22
+ "QQQ": {"name": "Invesco QQQ", "base_price": 443.0, "sector": "ETFs", "asset_type": "etf"},
23
+ "IWM": {"name": "iShares Russell 2000 ETF", "base_price": 204.0, "sector": "ETFs", "asset_type": "etf"},
24
+ "GLD": {"name": "SPDR Gold Shares", "base_price": 216.0, "sector": "ETFs", "asset_type": "etf"},
25
+ "BTC-USD": {"name": "Bitcoin", "base_price": 84200.0, "sector": "Crypto", "asset_type": "crypto"},
26
+ "ETH-USD": {"name": "Ethereum", "base_price": 3980.0, "sector": "Crypto", "asset_type": "crypto"},
27
+ "SOL-USD": {"name": "Solana", "base_price": 176.0, "sector": "Crypto", "asset_type": "crypto"},
28
+ }
29
+
30
+ MARKET_NAMES = {symbol: meta["name"] for symbol, meta in MARKET_META.items()}
31
+
32
+
33
+ def normalize_symbol(symbol):
34
+ return str(symbol or "").strip().upper()
35
+
36
+
37
+ def get_market_meta(symbol):
38
+ normalized = normalize_symbol(symbol)
39
+ fallback = {
40
+ "name": normalized or "Unknown Asset",
41
+ "base_price": 100.0,
42
+ "sector": "General",
43
+ "asset_type": "equity",
44
+ }
45
+ return normalized, MARKET_META.get(normalized, fallback)
46
+
47
+
48
+ def symbol_seed(symbol):
49
+ return sum(ord(char) for char in str(symbol))
50
+
51
+
52
+ def generate_kline(symbol, days=60):
53
+ normalized, meta = get_market_meta(symbol)
54
+ seed = symbol_seed(normalized)
55
+ total_days = max(5, int(days))
56
+ today = datetime.utcnow()
57
+ close = meta["base_price"] + (seed % 11) * 1.25
58
+ crypto = meta["asset_type"] == "crypto"
59
+ points = []
60
+
61
+ for index in range(total_days):
62
+ day_index = total_days - index
63
+ date = today - timedelta(days=day_index)
64
+ trend = math.sin((index + seed) / 6.0) * 1.6 + math.cos((index + seed) / 13.0) * 0.9
65
+ drift = ((seed % 7) - 3) * 0.08
66
+ if crypto:
67
+ trend *= 2.2
68
+ drift *= 1.5
69
+
70
+ open_price = close + math.sin((index + seed) / 4.0) * (1.2 if crypto else 0.8)
71
+ next_close = max(meta["base_price"] * 0.25, open_price + trend * 0.45 + drift)
72
+ wick = 1.5 if crypto else 0.6
73
+ high = max(open_price, next_close) + wick + ((seed + index) % 5) * 0.12
74
+ low = min(open_price, next_close) - wick - ((seed + index) % 4) * 0.1
75
+ volume_base = 900000000 if crypto else 3000000
76
+ volume_span = 800000000 if crypto else 5000000
77
+ volume = volume_base + ((seed * 113) + (index * 9173)) % volume_span
78
+
79
+ points.append({
80
+ "date": date.strftime("%Y-%m-%d"),
81
+ "open": round(open_price, 2),
82
+ "close": round(next_close, 2),
83
+ "high": round(high, 2),
84
+ "low": round(low, 2),
85
+ "volume": int(volume),
86
+ })
87
+ close = next_close
88
+
89
+ return points
90
+
91
+
92
+ def generate_quote(symbol):
93
+ normalized, meta = get_market_meta(symbol)
94
+ history = generate_kline(normalized, 61)
95
+ latest = history[-1]
96
+ previous = history[-2]
97
+ change = round(latest["close"] - previous["close"], 2)
98
+ change_pct = round((change / previous["close"]) * 100, 2) if previous["close"] else 0.0
99
+
100
+ return {
101
+ "symbol": normalized,
102
+ "name": meta["name"],
103
+ "price": latest["close"],
104
+ "change": change,
105
+ "change_pct": change_pct,
106
+ "high": latest["high"],
107
+ "low": latest["low"],
108
+ "open": latest["open"],
109
+ "volume": latest["volume"],
110
+ "turnover": round(latest["volume"] * latest["close"], 2),
111
+ }
112
+
113
+
114
+ def generate_quotes(symbols):
115
+ return [generate_quote(symbol) for symbol in symbols if normalize_symbol(symbol)]
116
+
117
+
118
+ def generate_news(symbol):
119
+ normalized, meta = get_market_meta(symbol)
120
+ now = datetime.utcnow()
121
+ templates = [
122
+ (
123
+ f"{meta['name']} stays on the U2INVEST watchlist as traders track {meta['sector'].lower()} leadership",
124
+ "U2INVEST Feed",
125
+ "This preview uses deterministic demo headlines so the app stays stable without a live market-data backend.",
126
+ ),
127
+ (
128
+ f"{meta['name']} highlights the difference between momentum and long-term fundamentals",
129
+ "Market Note",
130
+ "Use the Trading Lab chart alongside U2CHAT to compare price action with valuation and risk context.",
131
+ ),
132
+ (
133
+ f"What to review before analysing {meta['name']} in depth",
134
+ "Learning Desk",
135
+ "Start with trend, concentration risk, and whether the thesis depends on optimistic assumptions.",
136
+ ),
137
+ ]
138
+
139
+ return [
140
+ {
141
+ "title": title,
142
+ "source": source,
143
+ "time": (now - timedelta(hours=index * 3)).strftime("%Y-%m-%d %H:%M"),
144
+ "summary": summary,
145
+ }
146
+ for index, (title, source, summary) in enumerate(templates)
147
+ ]
148
+
149
+
150
+ def generate_fundamentals(symbol):
151
+ normalized, meta = get_market_meta(symbol)
152
+ seed = symbol_seed(normalized)
153
+
154
+ if meta["asset_type"] == "crypto":
155
+ return {
156
+ "asset_type": "Crypto",
157
+ "PE_ratio": "N/A",
158
+ "PB_ratio": "N/A",
159
+ "ROE": "N/A",
160
+ "network_growth": f"{18 + (seed % 21)}%",
161
+ "volatility_profile": "High",
162
+ }
163
+
164
+ pe_ratio = round(18 + (seed % 20) + ((seed % 5) * 0.4), 1)
165
+ pb_ratio = round(3.2 + ((seed % 9) * 0.45), 1)
166
+ roe = 10 + (seed % 18)
167
+
168
+ return {
169
+ "asset_type": meta["asset_type"].title(),
170
+ "PE_ratio": pe_ratio,
171
+ "PB_ratio": pb_ratio,
172
+ "ROE": f"{roe}%",
173
+ }
render-free.yaml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ - type: web
3
+ name: u2invest-free
4
+ runtime: docker
5
+ plan: free
6
+ region: oregon
7
+ autoDeployTrigger: commit
8
+ dockerfilePath: ./Dockerfile
9
+ healthCheckPath: /api/health
10
+ envVars:
11
+ - key: PORT
12
+ value: "10000"
13
+ - key: FLASK_DEBUG
14
+ value: "false"
15
+ - key: TRUST_PROXY_HEADERS
16
+ value: "true"
17
+ - key: SESSION_COOKIE_SAMESITE
18
+ value: "Lax"
19
+ - key: SESSION_COOKIE_SECURE
20
+ value: "true"
21
+ - key: DATA_DIR
22
+ value: /tmp/u2invest-data
23
+ - key: CHECKPOINTS_DB_PATH
24
+ value: /tmp/u2invest-data/checkpoints.sqlite
25
+ - key: CHROMA_DB_DIR
26
+ value: /tmp/u2invest-data/chroma_db
27
+ - key: BACKGROUND_VIDEO_MAX_MB
28
+ value: "8"
29
+ - key: BACKGROUND_VIDEO_MAX_COUNT
30
+ value: "4"
31
+ - key: KNOWLEDGE_BASE_PATH
32
+ value: /app/knowledge
33
+ - key: HF_HOME
34
+ value: /tmp/u2invest-data/hf-home
35
+ - key: SENTENCE_TRANSFORMERS_HOME
36
+ value: /tmp/u2invest-data/sentence-transformers
37
+ - key: GUNICORN_WORKERS
38
+ value: "1"
39
+ - key: GUNICORN_THREADS
40
+ value: "2"
41
+ - key: GUNICORN_TIMEOUT
42
+ value: "180"
43
+ - key: DEEPSEEK_BASE_URL
44
+ value: https://api.deepseek.com
45
+ - key: FLASK_SECRET_KEY
46
+ generateValue: true
47
+ - key: DEEPSEEK_API_KEY
48
+ sync: false
render.yaml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ - type: web
3
+ name: u2invest
4
+ runtime: docker
5
+ plan: starter
6
+ region: oregon
7
+ autoDeployTrigger: commit
8
+ dockerfilePath: ./Dockerfile
9
+ healthCheckPath: /api/health
10
+ disk:
11
+ name: u2invest-data
12
+ mountPath: /app/data
13
+ sizeGB: 5
14
+ envVars:
15
+ - key: PORT
16
+ value: "10000"
17
+ - key: FLASK_DEBUG
18
+ value: "false"
19
+ - key: TRUST_PROXY_HEADERS
20
+ value: "true"
21
+ - key: SESSION_COOKIE_SAMESITE
22
+ value: "Lax"
23
+ - key: SESSION_COOKIE_SECURE
24
+ value: "true"
25
+ - key: DATA_DIR
26
+ value: /app/data
27
+ - key: CHECKPOINTS_DB_PATH
28
+ value: /app/data/checkpoints.sqlite
29
+ - key: CHROMA_DB_DIR
30
+ value: /app/data/chroma_db
31
+ - key: KNOWLEDGE_BASE_PATH
32
+ value: /app/knowledge
33
+ - key: HF_HOME
34
+ value: /app/data/hf-home
35
+ - key: SENTENCE_TRANSFORMERS_HOME
36
+ value: /app/data/sentence-transformers
37
+ - key: GUNICORN_WORKERS
38
+ value: "2"
39
+ - key: GUNICORN_THREADS
40
+ value: "4"
41
+ - key: GUNICORN_TIMEOUT
42
+ value: "180"
43
+ - key: DEEPSEEK_BASE_URL
44
+ value: https://api.deepseek.com
45
+ - key: FLASK_SECRET_KEY
46
+ generateValue: true
47
+ - key: DEEPSEEK_API_KEY
48
+ sync: false
requirements.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # U2INVEST Requirements - 适配 Python 3.13 优化版
2
+ Flask>=3.0.0
3
+ flask-cors>=4.0.0
4
+
5
+ # 数据处理
6
+ pandas>=2.2.3
7
+ numpy>=2.1.0
8
+
9
+ # 股票数据
10
+ akshare>=1.18.25
11
+
12
+ # AI Agent相关 - 允许使用你刚才已经装好的最新版
13
+ langchain>=1.1.0
14
+ langchain-openai>=0.1.0
15
+ langchain-core>=1.1.0
16
+ langchain-community>=0.1.0
17
+ langgraph>=0.1.0
18
+
19
+ # 向量数据库
20
+ chromadb>=0.5.0
21
+ sentence-transformers>=2.3.1
22
+
23
+ # 文档处理
24
+ pypdf>=4.0.0
25
+ langchain-huggingface>=0.1.0
26
+
27
+ # 环境变量与工具
28
+ python-dotenv>=1.0.0
29
+ requests>=2.31.0
30
+ beautifulsoup4>=4.12.2
31
+ langgraph-checkpoint-sqlite
32
+ gunicorn>=21.2.0
runtime_config.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+
4
+ ROOT_DIR = Path(__file__).resolve().parent
5
+ DATA_DIR = Path(os.getenv("DATA_DIR", ROOT_DIR / "data")).resolve()
6
+ CHECKPOINTS_DB_PATH = Path(
7
+ os.getenv("CHECKPOINTS_DB_PATH", DATA_DIR / "checkpoints.sqlite")
8
+ ).resolve()
9
+ CHROMA_DB_DIR = Path(os.getenv("CHROMA_DB_DIR", DATA_DIR / "chroma_db")).resolve()
10
+ KNOWLEDGE_BASE_PATH = Path(
11
+ os.getenv("KNOWLEDGE_BASE_PATH", ROOT_DIR / "knowledge")
12
+ ).resolve()
13
+ HF_HOME = Path(os.getenv("HF_HOME", DATA_DIR / "hf-home")).resolve()
14
+ SENTENCE_TRANSFORMERS_HOME = Path(
15
+ os.getenv("SENTENCE_TRANSFORMERS_HOME", DATA_DIR / "sentence-transformers")
16
+ ).resolve()
17
+
18
+
19
+ def ensure_runtime_dirs():
20
+ DATA_DIR.mkdir(parents=True, exist_ok=True)
21
+ CHECKPOINTS_DB_PATH.parent.mkdir(parents=True, exist_ok=True)
22
+ CHROMA_DB_DIR.mkdir(parents=True, exist_ok=True)
23
+ KNOWLEDGE_BASE_PATH.mkdir(parents=True, exist_ok=True)
24
+ HF_HOME.mkdir(parents=True, exist_ok=True)
25
+ SENTENCE_TRANSFORMERS_HOME.mkdir(parents=True, exist_ok=True)
26
+
27
+ os.environ.setdefault("HF_HOME", str(HF_HOME))
28
+ os.environ.setdefault("SENTENCE_TRANSFORMERS_HOME", str(SENTENCE_TRANSFORMERS_HOME))
29
+
30
+
31
+ ensure_runtime_dirs()
static/images/LOGO_final.png ADDED

Git LFS Details

  • SHA256: b319ed1e793a0ae4f846fdfc2213557fee3f1cfd01a94fc7b0c24db1d6217e4d
  • Pointer size: 130 Bytes
  • Size of remote file: 21.8 kB
static/images/academy/1.jpg.webp ADDED
static/images/academy/2.jpg.jpg ADDED

Git LFS Details

  • SHA256: ff610961ff9bd868c7270e113d1f104ba9c4f56fcc6b94e35074628108e1ab24
  • Pointer size: 131 Bytes
  • Size of remote file: 132 kB