Skip to content

Commit 57bd13e

Browse files
SUPER UPGRADE ONLINE DATABASE
1 parent b6cbd22 commit 57bd13e

23 files changed

Lines changed: 1071 additions & 207 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ yarn-error.log*
1414

1515
# Local QA artifacts
1616
screenshots/
17+
18+
# playwright
19+
.env

README.MD

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,89 @@ https://api-myaichatbotproject.onrender.com
103103

104104
### Main Database
105105

106-
- Uses **SQLite**
107-
- Automatically initializes on first run
108-
- Custom database path configurable via `DB_PATH` environment variable
106+
- Uses **SQLiteCloud (ONLINE)**
107+
- User/profile/chat/recommendation/job catalog data are stored online
108+
- Backend is configured in ONLINE-only mode (no local SQLite fallback)
109+
110+
### ✅ Online Database Mode (Recommended for production)
111+
112+
Backend now uses **ONLINE database** via **SQLiteCloud**.
113+
114+
When configured, user/chat/profile data is stored online and shared across all backend instances.
115+
116+
#### Environment variables
117+
118+
- `DB_PROVIDER=sqlitecloud`
119+
- `SQLITECLOUD_URL=sqlitecloud://<host>:<port>/<database>?apikey=<api-key>`
120+
121+
`SQLITECLOUD_URL` must be a real connection string, not the dashboard URL.
122+
123+
Optional (instead of `SQLITECLOUD_URL`):
124+
125+
- `SQLITECLOUD_HOST=<host>`
126+
- `SQLITECLOUD_PORT=8860` (default)
127+
- `SQLITECLOUD_DATABASE=<database-name>`
128+
- One auth mode only:
129+
- `SQLITECLOUD_API_KEY=<api-key>` **or**
130+
- `SQLITECLOUD_TOKEN=<token>` **or**
131+
- `SQLITECLOUD_USERNAME=<username>` + `SQLITECLOUD_PASSWORD=<password>`
132+
133+
Optional TLS/debug option:
134+
135+
- `SQLITECLOUD_INSECURE=1` (only for troubleshooting; do not use in production)
136+
137+
#### Setup steps (SQLiteCloud)
138+
139+
1. Create/identify your SQLiteCloud database in dashboard.
140+
141+
2. Generate API key for backend access.
142+
143+
3. Build connection string:
144+
- `sqlitecloud://<host>:8860/<database>?apikey=<api-key>`
145+
146+
4. Set backend environment variables (local `.env` or Render env):
147+
- `DB_PROVIDER=sqlitecloud`
148+
- `SQLITECLOUD_URL=<connection-string-from-step-3>`
149+
150+
5. Initialize schema/migrations on online DB:
151+
- `npm --prefix backend run setup-db`
152+
153+
6. Start backend:
154+
- `npm --prefix backend run start`
155+
156+
7. Verify health:
157+
- `GET /health`
158+
- Test register/login/chat and confirm data persists after backend restart/redeploy.
159+
160+
#### Render deployment notes
161+
162+
Add these env vars in Render Service → Environment:
163+
164+
- `DB_PROVIDER`
165+
- `SQLITECLOUD_URL`
166+
- plus existing vars: `JWT_SECRET`, `ADMIN_EMAIL`, `ADMIN_PASSWORD`, `GROQ_API_KEY`, ...
167+
168+
After deploy, run one-time DB init command using Render Shell:
169+
170+
- `npm run setup-db`
171+
172+
Then normal runtime command remains:
173+
174+
- `npm run start`
109175

110176
### Database Commands
111177

112178
| Command | Description |
113179
|---------|------------|
114-
| `npm run setup-db` | Initialize database (skips if already exists) |
115-
| `npm run reset-db` | Delete and recreate database |
180+
| `npm run setup-db` | Initialize ONLINE SQLiteCloud database (idempotent) |
181+
| `npm run reset-db` | In ONLINE mode, warns and does not delete cloud DB |
116182
| Auto-init | Server initializes DB automatically if empty |
117183

118184
---
119185

120186
## 📚 Career Catalog (Job Explorer)
121187

122-
The job catalog is stored in a separate SQLite database.
188+
The job catalog is also stored in SQLiteCloud (online), alongside app data.
123189

124190
### 📥 Import 1000+ Jobs from O*NET
125191

@@ -157,7 +223,7 @@ Used for conversational intelligence, contextual understanding, and personalized
157223

158224
## ⚙️ Architecture Notes
159225

160-
- 🪶 SQLite for lightweight local deployment
226+
- ☁️ SQLiteCloud for centralized ONLINE data
161227
- 🧠 Rule-based matching engine (optimized for rapid prototyping)
162228
- 🤖 LLM integration for advanced conversational support
163229
- 🔮 Designed for future ML-based recommendation system expansion

assets/index-0hZkGWZq.js

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-CizWG9CN.js

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-CjDQDQ3n.js

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-DGGiPoMD.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-Po7pD3Bh.js

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ GROQ_API_KEY=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
22
GROQ_BASE_URL=https://api.groq.com/openai/v1
33
GROQ_MODEL=openai/gpt-oss-120b
44
LLM_TIMEOUT_MS=30000
5+
6+
DB_PROVIDER=sqlitecloud
7+
SQLITECLOUD_URL=sqlitecloud://cn2gr5hvdk.g2.sqlite.cloud:8860/auth.sqlitecloud?apikey=V2ktpR7JkdaZTnRXp2MAGcjhOzi9adtOSjzkaGAcf4k

backend/database/career_advisor.db

0 Bytes
Binary file not shown.

backend/database/schema.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ CREATE TABLE IF NOT EXISTS scenario_nodes (
8080
);
8181
CREATE INDEX IF NOT EXISTS idx_nodes_scenario ON scenario_nodes(scenario_id);
8282

83+
CREATE TABLE IF NOT EXISTS careers (
84+
id INTEGER PRIMARY KEY AUTOINCREMENT,
85+
name VARCHAR(255) UNIQUE NOT NULL,
86+
category VARCHAR(100),
87+
required_skills TEXT,
88+
salary_range VARCHAR(100),
89+
job_outlook VARCHAR(100),
90+
description TEXT,
91+
question_count INTEGER DEFAULT 0,
92+
answer_count INTEGER DEFAULT 0,
93+
mention_frequency REAL DEFAULT 0,
94+
weighted_score REAL DEFAULT 0,
95+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
96+
);
97+
CREATE INDEX IF NOT EXISTS idx_careers_name ON careers(name);
98+
CREATE INDEX IF NOT EXISTS idx_careers_category ON careers(category);
99+
CREATE INDEX IF NOT EXISTS idx_careers_frequency ON careers(mention_frequency);
100+
83101
CREATE TABLE IF NOT EXISTS recommendations (
84102
id INTEGER PRIMARY KEY AUTOINCREMENT,
85103
conversation_id VARCHAR(100) NOT NULL,

0 commit comments

Comments
 (0)