CodeAI
CodeAI helps developers understand code faster with clear AI explanations, social sign-in, and saved analysis history.

Overview
CodeAI is an authenticated AI-powered code explanation platform built with Next.js, React, Prisma, PostgreSQL, Better Auth, and the OpenAI Responses API. The application enables developers to paste source code into an editor and receive a structured, AI-generated explanation that is automatically stored for future reference.
Unlike traditional prompt-to-text AI applications that return unstructured responses, CodeAI transforms generated explanations into normalized relational data. This allows explanations to be queried, indexed, rendered, and reused efficiently through a personalized history dashboard.
Key Features
CodeAI combines modern AI capabilities with production-grade application architecture, including:
Multi-user authentication and authorization
Google and GitHub OAuth integration via Better Auth
Server-side session validation using the Next.js App Router
Application-level row ownership enforcement for user data isolation
Structured AI outputs validated with Zod
Normalized relational persistence with Prisma and PostgreSQL
Idempotent request handling through normalized code hashing
User-specific explanation history and retrieval
Dark and light theme support
Syntax-highlighted code rendering
Token usage and model metadata tracking
How It Works
At a high level, CodeAI converts raw source code into a persistent and queryable explanation artifact.
Explanation Generation
A user signs in using Google or GitHub.
The user submits a code snippet through the editor.
The backend sends the code to the OpenAI Responses API.
The generated response is validated against predefined Zod schemas.
The structured output is transformed into normalized database records.
The explanation becomes available in the user's history for future access and analysis.
Structured AI Output
Rather than storing AI responses as a single text blob, CodeAI decomposes each explanation into structured fields.
Each generated explanation contains:
Metadata
Generated title
Detected programming language
Complexity classification
Model information
Token usage statistics
Analysis
Concise summary
Detailed long-form summary
Optimization recommendations
Performance impact assessment
Step-by-Step Breakdown
The explanation is further divided into individual steps, each associated with specific line ranges in the source code. This enables granular rendering and future extensibility for features such as:
Line-by-line explanations
Search and filtering
Analytics and insights
Interactive code walkthroughs
Explanation regeneration
Data Architecture
A core design principle of CodeAI is that AI-generated content should be treated as structured application data rather than opaque text.
To support this, the platform stores:
High-level explanation records
Individual explanation steps
Model metadata
Usage metrics
Ownership relationships between users and explanations
The system also implements deduplication through normalized code hashing, ensuring that identical code submissions can be efficiently identified and managed without creating unnecessary duplicate records.
Technical Highlights
Frontend
Next.js (App Router)
React
TypeScript
Theme support
Syntax-highlighted rendering
Backend
Next.js Server Actions and Route Handlers
Better Auth
OpenAI Responses API
Zod validation
Database Layer
Prisma ORM
PostgreSQL
Relational data modeling
Queryable explanation history
Security & Access Control
OAuth authentication (Google & GitHub)
Server-side session verification
Per-user data ownership enforcement
Protected application routes
Architectural Summary
CodeAI demonstrates how modern AI applications can move beyond simple prompt-response workflows by treating LLM outputs as structured, persistent data. By combining authenticated user access, schema-validated AI generation, normalized database storage, and robust ownership controls, the platform delivers a scalable foundation for creating, storing, and exploring AI-generated code explanations.
Gallery
