blog2025-04-08-migration.md1 match
14| | Before | Now |
15|---------------------|---------------------------|------------|
16| **Rendering** | Astro | React |
17| **Version control** | GitHub | Val Town |
18| **Text editing** | Local editor | Val Town |
1# AI Chat App
23A sleek, dark-themed AI chat application built with React on Val Town using the OpenAI API.
45## Features
67- React-based chat interface with component architecture
8- Elegant dark theme with purple/indigo accents
9- Powered by OpenAI's GPT models
20โ โโโ index.ts # Backend API with Hono and OpenAI integration
21โโโ frontend/
22โ โโโ components/ # React components
23โ โ โโโ App.tsx # Main application component
24โ โ โโโ Message.tsx # Message component for chat bubbles
25โ โ โโโ ChatInput.tsx # Input component with send button
26โ โโโ index.html # HTML shell for React app
27โ โโโ index.tsx # React entry point
28โโโ README.md
29```
31## How It Works
32331. The React frontend provides a component-based chat interface
342. Messages are managed with React state
353. API requests are sent to the backend endpoint
364. The backend uses the OpenAI API to generate responses
40## Technologies Used
4142- **React**: For component-based UI architecture
43- **TypeScript**: For type safety and better code organization
44- **Tailwind CSS**: For styling without custom CSS files
6061You can customize the app by:
62- Modifying React components to add new features
63- Changing the OpenAI model in the backend (currently using gpt-4o-mini)
64- Adjusting the max tokens parameter for longer or shorter responses
44});
4546// Serve React app files
47app.get("/", (c) => serveFile("/frontend/index.html", import.meta.url));
48app.get("/index.tsx", (c) => serveFile("/frontend/index.tsx", import.meta.url));
4950// Serve React components
51app.get("/components/:filename", (c) => {
52const filename = c.req.param("filename");
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React from 'https://esm.sh/react@18.2.0';
3import { createRoot } from 'https://esm.sh/react-dom@18.2.0/client';
4import { App } from './components/App.tsx';
511const root = createRoot(rootElement);
12root.render(
13<React.StrictMode>
14<App />
15</React.StrictMode>
16);
17}
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useState, useRef, useEffect } from 'https://esm.sh/react@18.2.0';
3import { Message } from './Message.tsx';
4import { ChatInput } from './ChatInput.tsx';
chatChatInput.tsx2 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useState, useRef, useEffect, KeyboardEvent, MouseEvent } from 'https://esm.sh/react@18.2.0';
34interface ChatInputProps {
chatMessage.tsx2 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useEffect, useRef } from 'https://esm.sh/react@18.2.0';
34interface MessageProps {
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
23export function ValCard({ val }) {
blogBlogPost.tsx2 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React from "https://esm.sh/react@18.2.0";
3import { BlogPost as BlogPostType } from "../utils/types.ts";
4import Byline from "./Byline.tsx";
2021- **`/index.ts`**: Main entry point that sets up Hono routing and middleware
22- **`/components/`**: React components for rendering the blog
23- **`Layout.tsx`**: Shared layout with header, footer, and styling
24- **`HomePage.tsx`**: Renders the blog homepage with featured and recent posts
37### Technical Stack
3839- **React**: For server-side rendering components
40- **Hono**: Lightweight web framework for routing
41- **Custom CSS**: For styling (no external frameworks)