How nimit23/orationaiassign works
Project Type and Purpose
• This is a modern, full-stack web application (“orationAiAssign”) built in Next.js + TypeScript, using tRPC as the API layer, a SQL database for persistence, and an external AI service for career counseling.
• The primary purpose is to provide users with a responsive chat UI, store conversation history, and generate AI-driven career advice.
File‐Structure Analysis
• Top-level configs:
• next.config.ts – Next.js build/deploy settings
• eslint.config.mjs, postcss.config.mjs – linting and CSS pipeline
• tsconfig.json – TypeScript compiler options
• src/app directory follows the Next.js App Router pattern:
• layout.tsx – root layout and shared UI
• page.tsx – chat page entrypoint
• globals.css – global styles
• package.json lists dependencies (Next.js, tRPC, database client, AI SDK).
Key Architectural Insights from README
• tRPC is used for end-to-end typed API calls between front end and server functions.
• A SQL database persists message history (likely via an ORM like Prisma).
• An AI service (e.g., OpenAI API) is called from server endpoints to generate counsel.
• Deployed on Vercel, leveraging edge/serverless functions.
a. Client Side (Browser):
• Next.js React App (app/layout.tsx + page.tsx)
• UI: chat interface, input form, history view
b. API Layer (Serverless Functions):
• tRPC router & procedures (e.g., sendMessage, fetchHistory)
• Next.js server runtime (Node.js/Edge)
c. Database:
• SQL database (PostgreSQL/MySQL)
• ORM layer (Prisma or equivalent)
d. External AI Service:
• OpenAI or similar LLM API
e. Deployment Platform:
• Vercel (build, hosting, serverless)
Relationships & Data Flow
• The browser sends user input over a tRPC client call.
• tRPC routes the call to a serverless function.
• The server function writes the message to the SQL DB (ORM).
• It then calls the AI service, receives generated advice, and persists the AI response.
• The function returns the combined response to the client UI.
• On page load or “history” requests, the client calls a tRPC fetchHistory endpoint to read from the DB.
Architectural Patterns & Principles
• Full-Stack React (Next.js App Router) with SSR/CSR hybrid
• End-to-end type safety via tRPC
• Serverless functions for API endpoints
• Single source of truth for state in the database
• Separation of concerns: UI ⇆ API ⇆ Persistence ⇆ External services