## Backend (server/) - Express 5 API with security middleware (helmet, rate limiting) - SQLite database with WAL mode (schema from docs/architecture/) - Meilisearch integration with tenant tokens - BullMQ + Redis background job queue - OCR pipeline with Tesseract.js - File safety validation (extension, MIME, size) - 4 API route modules: upload, jobs, search, documents ## Frontend (client/) - Vue 3 with Composition API (<script setup>) - Vite 5 build system with HMR - Tailwind CSS (Meilisearch-inspired design) - UploadModal with drag-and-drop - FigureZoom component (ported from lilian1) - Meilisearch search integration with tenant tokens - Job polling composable - Clean SVG icons (no emojis) ## Code Extraction - ✅ manuals.js → UploadModal.vue, useJobPolling.js - ✅ figure-zoom.js → FigureZoom.vue - ✅ service-worker.js → client/public/service-worker.js (TODO) - ✅ glossary.json → Merged into Meilisearch synonyms - ❌ Discarded: quiz.js, persona.js, gamification.js (Frank-AI junk) ## Documentation - Complete extraction plan in docs/analysis/ - README with quick start guide - Architecture summary in docs/architecture/ ## Build Status - Server dependencies: ✅ Installed (234 packages) - Client dependencies: ✅ Installed (160 packages) - Client build: ✅ Successful (2.63s) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
890 B
JavaScript
43 lines
890 B
JavaScript
/**
|
|
* Database connection module
|
|
* Provides SQLite connection with better-sqlite3
|
|
*/
|
|
|
|
import Database from 'better-sqlite3';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join } from 'path';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const DB_PATH = process.env.DATABASE_PATH || join(__dirname, 'navidocs.db');
|
|
|
|
let db = null;
|
|
|
|
/**
|
|
* Get database connection (singleton)
|
|
* @returns {Database.Database} SQLite database instance
|
|
*/
|
|
export function getDb() {
|
|
if (!db) {
|
|
db = new Database(DB_PATH);
|
|
|
|
// Enable foreign keys and WAL mode for better concurrency
|
|
db.pragma('foreign_keys = ON');
|
|
db.pragma('journal_mode = WAL');
|
|
|
|
console.log('Database connected:', DB_PATH);
|
|
}
|
|
|
|
return db;
|
|
}
|
|
|
|
/**
|
|
* Close database connection
|
|
*/
|
|
export function closeDb() {
|
|
if (db) {
|
|
db.close();
|
|
db = null;
|
|
}
|
|
}
|
|
|
|
export default { getDb, closeDb };
|