How dj-no1/sih_scira works
Project Type and Purpose
• Scira is a full-stack, server-rendered AI-powered search engine built on Next.js 13 (app-router).
• It provides both client-side React UI and server-side API routes (serverless functions), integrates multiple AI/search providers, and persists user data via Drizzle ORM.
File Structure
• Frontend:
• app/ directory (React server & client components, layouts, pages, page.tsx files)
• components/, contexts/, hooks/ directories (reusable UI, state providers, custom hooks)
• Backend/API:
• app/api/* route handlers (auth, search, transcribe, OG image)
• lib/ (utilities, AI-provider clients, database queries via Drizzle)
• Database:
• Drizzle ORM config and migration files under drizzle/
• SQL schema and index scripts
• Deployment & Config:
• Dockerfile, docker-compose.yml, .env.example
• next.config.ts, Vercel config (vercel.json)
• Environment typing under env/client.ts & env/server.ts
README for Insights
• Key external integrations: Vercel AI SDK, Exa.AI, OpenAI, Anthropic, xAI, Google Maps, OpenWeather, TMDB, Aviation Stack, Mem0, Tavily, Daytona sandbox, Better Auth.
• Core features grouped by domain: Web/Memory/Analysis/Chat/X/Reddit/Academic/YouTube/Extreme.
Main Components & Their Relationships
a. Client (Browser / Frontend)
• Renders UI from app/, interacts with user, calls Next.js page endpoints and API routes via HTTP/fetch.
b. Next.js Server (Server Components + API Routes)
• Server Components generate HTML (SSR/SSG).
• API routes handle dynamic logic: search orchestration, authentication, image generation, session management.
• Uses lib/ for business logic and external-service clients.
c. Database Layer
• Postgres (or any SQL) managed via Drizzle ORM.
• Stores user sessions, memories, usage data.
d. External Services
• AI Providers (OpenAI, xAI, Anthropic, Groq) via Vercel AI SDK
• Web search & content retrieval (Exa.AI, Tavily)
• Maps & location (Google Maps, Mapbox)
• Weather (OpenWeather)
• Flight tracking (Aviation Stack)
• Media metadata (TMDB)
• Authentication (Better Auth + OAuth providers)
• Analytics (PostHog)
• Code sandbox (Daytona)
• Memory management (Mem0)
Architectural Patterns & Design Principles
• Containerization: Docker multi-stage build, Docker Compose for local dev.
• Modularization: Clear separation of concerns–UI (app/, components/), state & contexts (contexts/, hooks/), business logic (lib/), data schema & migrations (drizzle/).
• Serverless micro-endpoints: Each app/api/.../route.ts acts as an isolated function.
• C4-like layering:
• Level 1: System Context (User ↔ Scira)
• Level 2: Containers (Browser, Next.js Backend, Database, External Services)
• Level 3: Components (e.g., Auth API, Search Orchestrator, OG Image Generator, Drizzle ORM, AI-SDK client)
Capturing Essential Details
• Only major feature groups in the high-level view (e.g., Search, Auth, Memory, Analytics).
• In detailed view, break down complex modules (e.g., within “Search Orchestrator,” show calls to Exa, AI models, streaming).