1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { getAllTools, getToolsByCategory, getToolById, searchTools } from "../database/queries";
4import { AITool, SearchRequest, ToolCategory } from "../../shared/types";
5
7
8// Create tables for the AI tools directory
9export async function setupDatabase() {
10 // Create tools table
11 await sqlite.execute(`
31 `);
32
33 // Check if we need to seed the database
34 const count = await sqlite.execute(`SELECT COUNT(*) as count FROM ${TOOLS_TABLE}`);
35 if (count.rows[0].count === 0) {
36 await seedDatabase();
37 }
38}
39
40// Seed the database with initial AI tools
41async function seedDatabase() {
42 // Sample tools data
43 const tools = [
17```
18โโโ backend/
19โ โโโ database/
20โ โ โโโ migrations.ts # Database schema setup
21โ โ โโโ queries.ts # Database query functions
22โ โโโ routes/
23โ โ โโโ api.ts # API routes for search and recommendations
47- Backend: Hono API framework
48- AI: OpenAI for query understanding and tool recommendations
49- Database: SQLite for tool information storage
4import { useAuth } from "../../hooks/useAuth";
5import { useExamService } from "../../hooks/useExamService";
6import { Exam, Attempt } from "../../../shared/database/schema";
7
8const AdminDashboard: React.FC = () => {
4import { useAuth } from "../../hooks/useAuth";
5import { useExamService } from "../../hooks/useExamService";
6import { Attempt, Exam, Question, Answer } from "../../../shared/database/schema";
7
8interface QuestionWithAnswer extends Question {
4import { useAuth } from "../../hooks/useAuth";
5import { useExamService } from "../../hooks/useExamService";
6import { Exam, Question, Attempt } from "../../../shared/database/schema";
7
8const TakeExam: React.FC = () => {
128 }));
129
130 // Save answer to database
131 if (attempt) {
132 const currentQuestion = questions[currentQuestionIndex];
4import { useAuth } from "../../hooks/useAuth";
5import { useExamService } from "../../hooks/useExamService";
6import { Exam, Attempt } from "../../../shared/database/schema";
7
8const StudentDashboard: React.FC = () => {
3import { useNavigate, Link } from "https://esm.sh/react-router-dom@6.20.1?deps=react@18.2.0";
4import { useAuth } from "../hooks/useAuth";
5import { UserRole } from "../../shared/database/schema";
6
7const Register: React.FC = () => {
1import { useMemo } from "https://esm.sh/react@18.2.0";
2import { useDatabase } from "./useDatabase";
3import { ExamService } from "../services/examService";
4
5export const useExamService = () => {
6 const { db, isInitialized } = useDatabase();
7
8 const examService = useMemo(() => {
5 Attempt,
6 Answer
7} from "../../shared/database/schema";
8
9/**
11 */
12export class ExamService {
13 private db: IDBDatabase;
14
15 constructor(db: IDBDatabase) {
16 this.db = db;
17 }