24βββ backend/
25β βββ auth/ # Authentication & authorization
26β βββ database/ # Database schemas & queries
27β βββ routes/ # API endpoints by user type
28β βββ services/ # Google Workspace integrations
4import { getCookie, setCookie, deleteCookie } from "https://esm.sh/hono@3.11.7/cookie";
5import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
6import { runMigrations, seedData } from './database/migrations.ts';
7import { getDashboardStats } from './database/queries.ts';
8import { GoogleOAuthService } from './auth/google-oauth.ts';
9import { GoogleWorkspaceService } from './services/google-workspace.ts';
20});
21
22// Initialize database on startup
23try {
24 await runMigrations();
25 // Comment out seedData for production
26 // await seedData();
27 console.log('Database initialized successfully');
28} catch (error) {
29 console.error('Database initialization failed:', error);
30}
31
81 const role = googleAuth.determineUserRole(googleUser.email);
82
83 // Create or update user in database
84 const user = {
85 id: `user_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
94 };
95
96 // Store user in database (you'd implement this in queries.ts)
97 // await createOrUpdateUser(user);
98
1// Database migrations for Xplicit E-learning Platform
2
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
29
30export async function runMigrations() {
31 console.log('Running database migrations...');
32
33 // Users table (main authentication table)
525 await sqlite.execute(`CREATE INDEX IF NOT EXISTS idx_teacher_hours_date ON ${TABLES.TEACHER_HOURS}(date)`);
526
527 console.log('Database migrations completed successfully');
528}
529}
11β β βββ api.ts # API endpoints
12β β βββ static.ts # Static file serving
13β βββ database/
14β βββ migrations.ts # Database setup
15β βββ queries.ts # Database operations
16βββ frontend/
17β βββ index.html # Main HTML template
60- **Backend**: Hono framework on Deno
61- **Styling**: TailwindCSS
62- **Database**: SQLite
63- **Storage**: Val Town Blob storage
64- **External**: Google Workspace APIs
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { runMigrations } from "./database/migrations.ts";
3import auth from "./routes/auth.ts";
4import leads from "./routes/leads.ts";
12});
13
14// Initialize database on startup
15await runMigrations();
16
8 updateLeadContact,
9 addNote
10} from "../database/queries.ts";
11import { requireAuth } from "./auth.ts";
12
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { setCookie, getCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createSession, validateSession, deleteExpiredSessions } from "../database/queries.ts";
4
5const auth = new Hono();
33```
34βββ backend/
35β βββ database/
36β β βββ migrations.ts # Schema do banco
37β β βββ queries.ts # FunΓ§Γ΅es de consulta
4import { cors } from "https://esm.sh/hono@3.11.7/middleware";
5import type { ApiResponse } from '../../shared/types.ts';
6import * as queries from '../database/queries.ts';
7
8const api = new Hono();
1// Database query functions for Xplicit E-learning Platform
2
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";