Next.js 15 + OpenAI Agents SDK + GPT-4o + TypeScript + Cutting-Edge UI/UX
โก๏ธ Enterprise-grade, location-aware AI assistant with terminal-inspired interface โก๏ธ
AI Agent // Personal Assistant represents the pinnacle of modern full-stack AI developmentโa sophisticated, enterprise-ready application that seamlessly blends cutting-edge AI capabilities with stunning user experience design. This isn't just another chatbot; it's a context-aware, location-intelligent AI assistant that demonstrates mastery of contemporary web technologies and AI integration patterns.
Built with Next.js 15's latest App Router, OpenAI's Agents SDK, and React 19's newest features, this application showcases advanced architectural patterns, real-time AI interactions, and pixel-perfect UI craftsmanship that would impress any technical recruiter or engineering team.
๐ฅ Status: Under active development with continuous feature additions and architectural improvements!
- OpenAI Agents SDK: Leveraging the latest
@openai/agentspackage with GPT-4o-mini - Tool-Calling Architecture: Extensible agent with custom tools and real-time execution
- Context-Aware Responses: AI that understands and responds based on user location and context
- Intelligent Error Recovery: Robust error handling with graceful fallbacks
- Real-Time IP Geolocation: Dynamic user location detection via advanced IP-API integration
- Contextual Responses: AI assistant provides location-specific information and recommendations
- Privacy-Conscious: Uses IP-based approximation without compromising user privacy
- Global Compatibility: Supports worldwide location detection and regional customization
- Cyberpunk Aesthetic: Dark-themed, terminal-style UI with cyan accent colors
- Split-Panel Architecture: Professional left-right layout for input and output
- Responsive Grid System: Seamlessly adapts from desktop to mobile devices
- Status Indicators: Real-time connection status and processing feedback
- Typewriter Animation: Character-by-character response rendering for engaging interactions
- Markdown Support: Full GitHub Flavored Markdown with
react-markdownandremark-gfm - Interactive States: Loading animations, success indicators, and error boundaries
- Accessibility: ARIA-compliant design with keyboard navigation support
- Type-Safe Development: 100% TypeScript with strict type checking
- Server Actions: Next.js 15's latest server-side action patterns
- Edge-Compatible: Optimized for serverless and edge deployment
- Environment Security: Secure API key management and environment configuration
| Component | Technology | Version | Purpose |
|---|---|---|---|
| Framework | Next.js | 15.3.4 | App Router, SSR, React Server Components |
| UI Library | React | 19.0.0 | Latest concurrent features, hooks, suspense |
| Styling | TailwindCSS | 4.0 | Utility-first CSS with custom design system |
| Typography | Geist Sans/Mono | Latest | Premium font pairing for modern aesthetics |
| Markdown | react-markdown + remark-gfm | 10.1.0 | Rich text rendering with GitHub flavored markdown |
| Component | Technology | Version | Purpose |
|---|---|---|---|
| API Layer | Next.js Route Handlers | 15.3.4 | Serverless API endpoints with edge compatibility |
| AI Engine | OpenAI Agents SDK | 0.0.9 | Advanced agent orchestration with tool-calling |
| LLM Model | GPT-4o-mini | Latest | Cost-effective, high-performance language model |
| External APIs | IP-API.com | Latest | Real-time geolocation and IP intelligence |
| Type System | TypeScript | 5.0 | End-to-end type safety and developer experience |
| Tool | Purpose | Benefits |
|---|---|---|
| Turbopack | Ultra-fast bundling | 10x faster than Webpack for development |
| ESLint | Code quality | Consistent code style and error prevention |
| PostCSS | CSS processing | TailwindCSS integration and optimization |
The application follows a sophisticated, layered architecture designed for scalability, maintainability, and optimal user experience:
graph TD A["๐ User Interface<br/>Terminal-Inspired Design"] --> B["๐ก Next.js Server Actions<br/>submitPrompt()"] B --> C["๐ API Route Handler<br/>/api/agent"] C --> D["๐ค OpenAI Agent<br/>GPT-4o-mini"] D --> E["๐ ๏ธ Tool: getUserLocation"] E --> F["๐ External APIs<br/>IP-API.com"] F --> G["๐ Location Data<br/>City, Region, Country"] G --> D D --> H["๐ฌ AI Response<br/>Context-Aware"] H --> C C --> I["๐ค JSON Response<br/>aiAgentFinalOutput"] I --> B B --> J["โจ๏ธ Typewriter Effect<br/>Markdown Rendering"] J --> A subgraph "Frontend Layer" A J K["๐จ TailwindCSS<br/>Custom Styling"] L["๐ฑ Responsive Grid<br/>Split Panel Layout"] end subgraph "Backend Layer" B C M["๐ Server-Side Security<br/>Environment Variables"] end subgraph "AI Layer" D E N["๐ง Tool-Calling Architecture<br/>Extensible Design"] end subgraph "External Services" F O["โ๏ธ OpenAI API<br/>GPT-4o-mini"] end style A fill:#1e293b,stroke:#06b6d4,stroke-width:2px,color:#fff style D fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff style F fill:#4c1d95,stroke:#8b5cf6,stroke-width:2px,color:#fff - User Interaction: User submits a prompt via the terminal-style interface
- Server Action: Next.js server action validates and processes the request
- API Gateway: Route handler receives the prompt and initializes the AI agent
- AI Processing: OpenAI agent analyzes the prompt and determines if tools are needed
- Tool Execution: If location context is required, the agent calls the getUserLocation tool
- External Data: IP-API services provide real-time geolocation data
- AI Response: Agent synthesizes a contextual response using all available information
- Data Return: Response flows back through the API to the client
- UI Rendering: Typewriter effect displays the response with markdown formatting
- Terminal Aesthetic: Authentic command-line interface with cyan accents and monospace fonts
- Split-Panel Layout: Professional workspace with dedicated input and output areas
- Real-Time Feedback: Live status indicators showing "ONLINE", "EXECUTING", and response states
- Responsive Design: Seamlessly adapts from desktop workstations to mobile devices
- Instant Validation: Client-side form validation prevents empty submissions
- Loading States: Smooth transitions with "EXECUTING..." and "Awaiting response..." indicators
- Error Boundaries: Graceful error handling with informative user feedback
- Accessibility: Full keyboard navigation and screen reader compatibility
- Custom Color Palette: Deep space blues with electric cyan highlights
- Typography Hierarchy: Perfect balance of Geist Sans and Mono fonts
- Micro-Animations: Subtle hover effects and active states for enhanced interactivity
- Visual Feedback: Clear distinction between user input and AI responses
// Sophisticated OpenAI Agent with Tool Integration const agent = new Agent({ name: "Personal Assistant", model: "gpt-4o-mini", instructions: `You are a personal assistant that can help with tasks and answer questions based on the user's IP address. You address the user as Sir. Remember to use proper grammar and punctuation with proper spacing and formatting in your response.`, tools: [getUserLocation] }); const result = await run(agent, prompt);// Real-time IP-based geolocation with error handling const getUserLocation = tool({ name: 'get_user_location', description: 'Get the location of the user', execute: async () => { try { // Primary IP detection via EDNS const ipResponse = await fetch("http://edns.ip-api.com/json"); const ipData = await ipResponse.json(); const userIp = ipData.dns.ip; // Geolocation lookup with comprehensive data const locationResponse = await fetch(`http://ip-api.com/line/${userIp}`); const locationData = await locationResponse.text(); return locationData; // Returns: Country, Region, City, Timezone, ISP } catch (error) { return "Location unavailable"; } }, parameters: { type: 'object', properties: {}, required: [], additionalProperties: false, }, });// Character-by-character rendering with React hooks function Typewriter({ text }: { text: string }) { const [displayedText, setDisplayedText] = useState(""); useEffect(() => { setDisplayedText(""); let i = 0; const interval = setInterval(() => { if (i < text.length) { setDisplayedText((prev) => prev + text.charAt(i)); i++; } else { clearInterval(interval); } }, 10); // 10ms per character for smooth animation return () => clearInterval(interval); }, [text]); return ( <div className="prose prose-invert prose-sm max-w-none"> <ReactMarkdown remarkPlugins={[remarkGfm]}> {displayedText} </ReactMarkdown> </div> ); }// Next.js 15 Server Actions with comprehensive error handling "use server"; export async function submitPrompt(prevState: any, formData: FormData) { const prompt = formData.get('prompt') as string; if (!prompt) { return { error: 'Prompt is required' }; } try { const response = await fetch( `${process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'}/api/agent`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt }), } ); if (!response.ok) { return { error: 'Failed to get response' }; } const data = await response.json(); return { success: true, data: data.aiAgentFinalOutput }; } catch (error) { return { error: 'Something went wrong' }; } }/* Terminal-inspired design with perfect color harmony */ body { background-color: rgb(2 6 23 / 1); /* Deep space blue */ color: rgb(203 213 225 / 1); /* Soft white text */ font-family: 'Menlo', 'Consolas', 'Monaco', monospace; text-transform: uppercase; letter-spacing: 0.05em; } .prose { --tw-prose-headings: theme(colors.cyan.400); /* Electric cyan headers */ --tw-prose-code: theme(colors.cyan.400); /* Code highlighting */ --tw-prose-bullets: theme(colors.cyan.400); /* List styling */ }ai-agent-openai-api-nextjs-app/ โโโ ๐ src/ โ โโโ ๐ app/ # Next.js 15 App Router โ โ โโโ ๐ api/ โ โ โ โโโ ๐ agent/ โ โ โ โโโ ๐ route.ts # ๐ค AI Agent API endpoint โ โ โโโ ๐ favicon.ico # ๐จ Custom branding โ โ โโโ ๐ globals.css # ๐จ Terminal design system โ โ โโโ ๐ layout.tsx # ๐๏ธ Root layout & typography โ โ โโโ ๐ page.tsx # ๐ป Main interface & typewriter โ โโโ ๐ features/ โ โโโ ๐ actions.ts # ๐ Server actions & validation โโโ ๐ public/ # ๐ผ๏ธ Static assets & icons โ โโโ ๐ globe.svg # ๐ Location-aware branding โ โโโ ๐ file.svg # ๐ File system icons โ โโโ ๐ window.svg # ๐ฅ๏ธ Interface elements โ โโโ ๐ next.svg # โก Framework branding โโโ ๐ package.json # ๐ฆ Dependencies & scripts โโโ ๐ next.config.ts # โ๏ธ Next.js configuration โโโ ๐ tsconfig.json # ๐ง TypeScript config โโโ ๐ eslint.config.mjs # ๐ Code quality rules โโโ ๐ postcss.config.mjs # ๐จ CSS processing โโโ ๐ README.md # ๐ This documentation /appDirectory: Leveraging Next.js 15's App Router for file-based routing and layouts- Server Actions: Co-located in
/featuresfor reusable business logic - API Routes: RESTful endpoints under
/apiwith proper error handling - Component Structure: Single-file components with embedded logic for this MVP
- Type Safety: Strict TypeScript configuration across all layers
- Node.js: 18+ (recommended: 20+)
- Package Manager: pnpm (recommended for performance)
- OpenAI API Key: Required for AI functionality
# Clone the repository git clone https://github.com/hemants1703/ai-agent-openai-api-nextjs-app.git cd ai-agent-openai-api-nextjs-app # Install dependencies with pnpm (ultra-fast) pnpm install # Set up environment variables cp .env.example .env.local # Add your OpenAI API key to .env.local # Start development server with Turbopack pnpm devOpen http://localhost:3000 and experience the AI agent in action!
Try these example prompts:
- "What's the weather like in my location?"
- "Tell me about my current city"
- "What time zone am I in?"
- โ AI Agent Foundation: OpenAI integration with location awareness
- โ Terminal UI: Cyberpunk-inspired interface design
- โ Typewriter Effect: Smooth character-by-character rendering
- ๐ Enhanced Error Handling: More robust error boundaries
- ๐ Performance Optimization: Response caching and lazy loading
- ๐ฏ Multi-Tool Architecture: Weather, calendar, and productivity tools
- ๐ Authentication System: User accounts and personalization
- ๐พ Conversation Memory: Persistent chat history with context
- ๐ฑ Mobile Optimization: PWA capabilities and offline support
- ๐ Internationalization: Multi-language support
- ๐ Analytics Dashboard: Usage metrics and performance insights
- ๐ Enterprise Security: Role-based access and audit logs
- ๐ Microservices: Scalable backend architecture
- โ๏ธ Cloud Deployment: Multi-region deployment on Vercel/AWS
- Frontend Excellence: React 19, Next.js 15, advanced hooks, and custom components
- Backend Sophistication: Server actions, API routes, and external service integration
- AI Integration: OpenAI Agents SDK, tool-calling, and context management
- DevOps Awareness: Turbopack, ESLint, TypeScript, and modern build tools
- Type Safety: 100% TypeScript with strict configuration
- Performance: Optimized rendering, lazy loading, and efficient state management
- User Experience: Accessibility, responsive design, and micro-interactions
- Code Quality: Clean architecture, reusable components, and comprehensive error handling
- AI-First Design: Contextual intelligence with real-time data integration
- Visual Identity: Custom terminal aesthetic with professional polish
- Technical Depth: Advanced React patterns and Next.js 15 features
- Scalable Foundation: Extensible architecture ready for enterprise features
"This project showcases the perfect blend of cutting-edge AI technology, modern web development practices, and exceptional user experience design."
- โ Latest Technologies: Next.js 15, React 19, OpenAI Agents SDK
- โ Full-Stack Capabilities: Frontend excellence + backend sophistication
- โ AI Integration: Real-world AI application with tool-calling
- โ Production Ready: Type-safe, error-handled, and scalable
- โ Code Quality: Clean, maintainable, and well-documented
- โ User Focus: Intuitive interface with exceptional UX
- โ Technical Depth: Advanced patterns and modern best practices
- โ Delivery Speed: Rapid prototyping with production-quality results
Specializations:
- ๐ค AI-Powered Applications: OpenAI, LangChain, vector databases
- โ๏ธ Modern Frontend: React, Next.js, TypeScript, advanced UI patterns
- ๐๏ธ Scalable Backend: Node.js, serverless, microservices architecture
- ๐จ Design Systems: Tailwind, custom CSS, responsive design
What Sets Me Apart:
- ๐ก Innovation: Bleeding-edge technology adoption and creative problem solving
- ๐ฏ Quality: Obsessive attention to detail and user experience
- ๐ Speed: Rapid prototyping without compromising on quality
- ๐ค Collaboration: Clear communication and team-first mentality
Let's Build Something Amazing Together!
MIT License - feel free to use this project as inspiration for your own AI applications!