feat: Market Intel Database & UI Polish

- market_db_manager.py: Created SQLite manager for saving/loading projects.

- server.cjs: Added API routes for project management.

- geminiService.ts: Added client-side DB functions.

- StepInput.tsx: Added 'Past Runs' sidebar to load previous audits.

- App.tsx: Added auto-save functionality and full state hydration logic.

- StepOutreach.tsx: Improved UI layout by merging generated campaigns and suggestions into one list.
This commit is contained in:
2025-12-29 14:44:20 +00:00
parent 47fa37dd98
commit 03610dfd13
6 changed files with 587 additions and 267 deletions

View File

@@ -213,6 +213,34 @@ app.post('/api/generate-outreach', async (req, res) => {
}
});
// --- DATABASE ROUTES ---
// Initialize DB on startup
const dbScript = path.join(__dirname, '..', 'market_db_manager.py');
spawn('python3', [dbScript, 'init']);
app.get('/api/projects', (req, res) => {
runPython([dbScript, 'list'], res);
});
app.get('/api/projects/:id', (req, res) => {
runPython([dbScript, 'load', req.params.id], res);
});
app.post('/api/save-project', (req, res) => {
const projectData = req.body;
const tmpDir = path.join(__dirname, 'tmp');
if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir);
const tempFilePath = path.join(tmpDir, `save_${Date.now()}.json`);
try {
fs.writeFileSync(tempFilePath, JSON.stringify(projectData));
runPython([dbScript, 'save', tempFilePath], res, [tempFilePath]);
} catch (e) {
res.status(500).json({ error: 'Failed to write project data to disk' });
}
});
app.listen(PORT, () => {
console.log(`Node.js API Bridge running on http://localhost:${PORT}`);
});