mirror of
https://github.com/soconnor0919/hristudio.git
synced 2025-12-11 06:34:44 -05:00
ab08c1b724495efcbc77a2b9c96b245ae9c8dd9b
- Add plugin store system with dynamic loading of robot actions - Implement plugin store API routes and database schema - Update experiment designer to support plugin-based actions - Refactor environment configuration and sidebar navigation - Improve authentication session handling with additional user details - Update Tailwind CSS configuration and global styles - Remove deprecated files and consolidate project structure
HRIStudio
A modern web application for managing human-robot interaction studies, built with Next.js 15, TypeScript, and the App Router.
Tech Stack
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Authentication: NextAuth.js
- Database: PostgreSQL with Drizzle ORM
- UI Components: Shadcn UI + Radix UI
- Styling: Tailwind CSS
- API Layer: tRPC
- File Storage: MinIO (S3-compatible)
Key Principles
TypeScript Usage
- Use TypeScript for all code files
- Prefer interfaces over types
- Avoid enums; use const objects with
as constinstead - Use proper type inference with
zodschemas
Component Structure
- Use functional components with TypeScript interfaces
- Structure files in this order:
- Exported component
- Subcomponents
- Helper functions
- Static content
- Types/interfaces
Naming Conventions
- Use lowercase with dashes for directories (e.g.,
components/auth-wizard) - Use PascalCase for components
- Use camelCase for functions and variables
- Prefix boolean variables with auxiliary verbs (e.g.,
isLoading,hasError)
Data Management
- Use Drizzle ORM for database operations
- Split names into
firstNameandlastNamefields - Use tRPC for type-safe API calls
- Implement proper error handling and loading states
Authentication
- Use NextAuth.js for authentication
- Handle user sessions with JWT strategy
- Store passwords with bcrypt hashing
- Implement proper CSRF protection
File Structure
src/
├── app/ # Next.js App Router pages
├── components/
│ ├── ui/ # Reusable UI components
│ └── layout/ # Layout components
├── server/
│ ├── api/ # tRPC routers
│ ├── auth/ # Authentication config
│ └── db/ # Database schema and config
└── lib/ # Utility functions
Best Practices
Forms
// Form Schema
const formSchema = z.object({
firstName: z.string().min(1, "First name is required"),
lastName: z.string().min(1, "Last name is required"),
email: z.string().email(),
// ...
});
// Form Component
export function MyForm() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
firstName: "",
lastName: "",
// ...
},
});
}
Server Components
- Use Server Components by default
- Add 'use client' only when needed for:
- Event listeners
- Browser APIs
- React hooks
- Client-side state
Image Handling
// Image Upload
const handleFileUpload = async (file: File) => {
const formData = new FormData();
formData.append("file", file);
const response = await fetch("/api/upload", {
method: "POST",
body: formData,
});
return response.json();
};
// Image Display
<Image
src={imageUrl}
alt="Description"
width={size}
height={size}
className="object-cover"
priority={isAboveFold}
/>
Database Schema
// User Table
export const users = createTable("user", {
id: varchar("id", { length: 255 })
.notNull()
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
firstName: varchar("first_name", { length: 255 }),
lastName: varchar("last_name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
// ...
});
Performance Optimization
- Use React Server Components where possible
- Implement proper image optimization
- Use dynamic imports for large client components
- Implement proper caching strategies
Security
- Implement proper CSRF protection
- Use environment variables for sensitive data
- Implement proper input validation
- Use proper content security policies
Development
# Install dependencies
pnpm install
# Set up environment variables
cp .env.example .env.local
# Start development server
pnpm dev
# Run type checking
pnpm type-check
# Run linting
pnpm lint
Database Migrations
# Generate migration
pnpm drizzle-kit generate:pg
# Push migration
pnpm db:push
Deployment
The application is designed to be deployed on any platform that supports Node.js. We recommend using Vercel for the best Next.js deployment experience.
Contributing
- Follow the TypeScript guidelines
- Use the provided component patterns
- Implement proper error handling
- Add appropriate tests
- Follow the commit message convention
Description
A web platform for managing human-robot interaction studies, participants, and wizard-of-oz experiments.
Languages
TypeScript
97.1%
HTML
1.8%
CSS
0.5%
Shell
0.3%
JavaScript
0.3%