The frontend is built with React Admin, providing a comprehensive administration panel for the RAG system. It automatically integrates with the backend API through generated code from the Prisma DTO generator.
import { Admin, Resource } from "react-admin";
import { appAuthProvider } from "./AppAuthProvider";
import { appDataProvider } from "./AppDataProvider";
import { CustomLoginPage } from "./forms/CustomLoginPage";
import { client } from "./generated/client/client.gen";
import { resources } from "./generated/resource/resources";
client.setConfig({
baseUrl: import.meta.env.VITE_API_URL,
headers: { "x-api-key": authService.getApiKey() },
});
export const App = () => {
const resourceNames = Object.keys(resources);
return (
<Admin
requireAuth
loginPage={CustomLoginPage}
authProvider={appAuthProvider}
dataProvider={appDataProvider}
>
{resourceNames.map((resourceName, index) => (
<Resource
key={index}
name={resourceName}
options={{ label: resources[resourceName]?.label }}
list={resources[resourceName]?.list}
show={resources[resourceName]?.show}
create={resources[resourceName]?.create}
edit={resources[resourceName]?.edit}
/>
))}
</Admin>
);
};Handles user authentication and session management:
- Login/logout functionality
- API key management
- Session validation
- Permission checking
Central routing layer that delegates to model-specific data providers:
- Routes requests to appropriate generated data providers
- Handles global error management
- Manages authentication token refresh
- Implements retry logic
The system automatically generates complete CRUD interfaces for all Prisma models:
Each model generates:
- DataProvider: Implements all React Admin data operations
- Forms: Create/Edit/Show forms with appropriate input components
- List Views: Searchable and sortable list displays
- Type Definitions: Full TypeScript support
AuthUser- User managementAuthApiKey- API key managementAuthSession- Session tracking
ChatDialog- Conversation dialogsChatMessage- Individual messages with rich contentChatDocumentEmbedding- Document embeddings with vector dataChatMessageDocumentEmbedding- Message-to-document relationshipsChatLlmModel- LLM model configurationsChatEmbeddingModel- Embedding model configurationsChatLlmRequest- LLM request trackingChatPrompt- Prompt templates
Each resource gets a complete data provider implementing:
{
getList: (resource, params) => Promise<GetListResult>,
getOne: (resource, params) => Promise<GetOneResult>,
getMany: (resource, params) => Promise<GetManyResult>,
getManyReference: (resource, params) => Promise<GetManyReferenceResult>,
create: (resource, params) => Promise<CreateResult>,
update: (resource, params) => Promise<UpdateResult>,
updateMany: (resource, params) => Promise<UpdateManyResult>,
delete: (resource, params) => Promise<DeleteResult>,
deleteMany: (resource, params) => Promise<DeleteManyResult>
}Auto-generated forms with:
- Create Forms: Fields for required data entry
- Edit Forms: Fields for updating existing records
- Show Forms: Read-only display of all fields
- Smart input selection based on field types:
TextInputfor stringsNumberInputfor numeric fieldsBooleanInputfor boolean valuesDateTimeInputfor timestampsJsonViewerFieldfor complex JSON data
Searchable and sortable lists with:
- Column-based filtering
- Pagination support
- Bulk actions
- Responsive design
Uses generated OpenAPI client:
- Type-safe API calls
- Automatic request/response validation
- Built-in error handling
- Authentication header injection
- User logs in via custom login page
- API key is stored securely
- All requests include authentication headers
- Automatic logout on authentication errors
- Global error interception
- Automatic session renewal
- User-friendly error messages
- Graceful degradation
Located in src/forms/ directory:
CustomLoginPage.tsx- Custom authentication interface- Extendable for additional custom forms
- Uses Material-UI components
- Theme customization through React Admin theme system
- Responsive design for all screen sizes
- Custom field components can be added
- Additional data providers can be integrated
- Custom actions and buttons supported
- Define model in Prisma schema
- Run
npx prisma generateto regenerate DTOs - Run frontend build to regenerate React Admin components
- New resource automatically appears in admin panel
For special data types like vectors or embeddings:
- Create custom input component
- Register in form generation templates
- Add to field type mapping
- Lazy loading of resource components
- Bundle splitting by resource type
- Dynamic imports for large components
- Client-side caching of frequently accessed data
- Request deduplication
- Stale-while-revalidate patterns
- Tree-shaking of unused components
- Selective imports from Material-UI
- Minification and compression
- API key-based authentication
- Secure token storage
- Session timeout handling
- CSRF protection
- Role-based access control
- Resource-level permissions
- Field-level visibility control
- Input sanitization
- XSS prevention
- Secure API communication
- Audit logging
npm run buildCreates optimized production bundle in dist/ directory.
VITE_API_URL- Backend API endpoint- Authentication settings
- Feature flags
- Static hosting (Netlify, Vercel)
- Traditional web servers
- Container deployment
- Request/response logging
- Error tracking
- Performance metrics
- User activity monitoring
- Development mode with detailed logging
- Component inspection tools
- Network request monitoring
- State debugging utilities
This frontend system provides a complete, type-safe administration interface that automatically adapts to backend schema changes through the Prisma generator integration.