The AI (via OpenRouter) should only create/modify files in:
src/directory - All application source codepackage.json- For npm package management and dependencies
The frontend should prevent AI from creating/modifying:
- System configuration files (vite.config.ts, tsconfig.json, etc.)
- Build scripts and tooling
- Docker-related files
- ESLint, PostCSS, or Tailwind configurations
- HTML files
- Any files outside the
src/directory (except package.json)
Note: Backend has no restrictions - all validation occurs on frontend
All system files are automatically copied from the React base template:
/react-base/
βββ vite.config.ts # Vite configuration
βββ tsconfig.json # TypeScript config
βββ tsconfig.app.json # App-specific TypeScript config
βββ tsconfig.node.json # Node.js TypeScript config
βββ eslint.config.js # ESLint configuration
βββ index.html # HTML template
βββ postcss.config.cjs # PostCSS configuration (auto-generated)
βββ tailwind.config.cjs # Tailwind configuration (auto-generated)
βββ Dockerfile # Container definition
/project-container/
βββ src/ # Frontend should limit AI to this directory
β βββ App.tsx
β βββ main.tsx
β βββ components/
β βββ hooks/
β βββ utils/
β βββ ... # Any src/ structure AI desires
βββ package.json # Frontend should allow AI to modify for dependencies
The orchestrator backend:
- Accepts any file operations - no path restrictions
- Relies on frontend for AI access validation
- Full container access - can write any file location
- System Setup: Copy all system files from React base template
- AI Content: Write AI-generated files to
src/directory only - Package Management: Update
package.jsonif AI provides new dependencies - Dependency Installation: Auto-run
npm installon package.json changes - Start Services: Launch development server with configured tooling
The orchestrator now validates all AI file operations:
const allowedPaths = ['src/', 'package.json'];
const isValidPath = allowedPaths.some(allowedPath =>
filepath === allowedPath || filepath.startsWith(allowedPath)
);POST /containers
Content-Type: application/jsonRequest Body (AI-Restricted):
{
"projectId": "my-project",
"files": {
"src/App.tsx": "export default function App() { return <div>Hello World</div>; }",
"src/components/Button.tsx": "export const Button = () => <button>Click me</button>;",
"package.json": "{ \"name\": \"my-app\", \"dependencies\": { \"react\": \"^18.0.0\", \"axios\": \"^1.0.0\" } }"
}
}System Response: Auto-generated system files + AI files
PUT /containers/:containerId/files
Content-Type: application/jsonAllowed Updates Only:
{
"files": {
"src/App.tsx": "export default function App() { return <div>Updated</div>; }",
"src/utils/api.ts": "export const api = () => {};",
"package.json": "{ \"name\": \"my-app\", \"dependencies\": { \"react\": \"^18.0.0\", \"axios\": \"^1.2.0\" } }"
}
}- Strict Whitelisting: Only
src/andpackage.jsonare allowed - Path Traversal Prevention:
../and absolute paths are blocked - Automatic Logging: All unauthorized access attempts are logged
- Immutable System Files: Configuration files cannot be modified by AI
- Consistent Build Environment: All containers use identical system configuration
- Dependency Safety: Package.json updates trigger fresh
npm install
When your frontend interacts with the AI system:
- File Path Restrictions: Ensure AI responses only reference
src/paths - Package Management: Handle dependency updates through
package.jsononly - Error Handling: Expect warnings for unauthorized file access attempts
- System Files: Never request AI to modify configuration files
Recommended constraints for AI prompts:
"Create React components in the src/ directory only.
You may update package.json to add new dependencies.
Do not create or modify any configuration files or files outside src/."
// Client-side validation before sending to API
const validateAIFiles = (files) => {
const allowedPaths = ['src/', 'package.json'];
const validFiles = {};
for (const [path, content] of Object.entries(files)) {
const isValid = allowedPaths.some(allowed =>
path === allowed || path.startsWith(allowed)
);
if (isValid) {
validFiles[path] = content;
} else {
console.warn(`Invalid path skipped: ${path}`);
}
}
return validFiles;
};When creating new containers, the system:
- Copies Template Files: All configuration files from React base
- Handles ES Modules: Automatic conversion of config files to
.cjsif needed - Creates Default Configs: Generates PostCSS and Tailwind configs if missing
- Validates Structure: Ensures all required system files exist
- Vite: Optimized for development with HMR
- TypeScript: Strict type checking enabled
- ESLint: Code quality rules enforced
- Tailwind CSS: Utility-first styling framework
- PostCSS: CSS processing pipeline
The system logs all AI file operations:
Writing: src/App.tsx
Writing: src/components/Button.tsx
β οΈ AI attempted to write to restricted path: vite.config.ts (skipping)
Writing: package.json
Installing new dependencies...
β
Project initialized! 3 files written.System health checks include:
- File integrity validation
- Dependency installation status
- Configuration file consistency
- Container resource utilization
- File Management: Only create/modify files in
src/directory - Dependencies: Update
package.jsonfor new packages - Build System: Use Vite's built-in tooling (no configuration needed)
- Styling: Tailwind CSS is pre-configured and ready to use
- Source Code: All application logic goes in
src/ - Components: React components in
src/components/ - Utilities: Helper functions in
src/utils/ - Hooks: Custom React hooks in
src/hooks/ - Assets: Images, fonts, etc. in
src/assets/
- Never request AI to modify system files
- Always validate AI-generated file paths
- Use package.json for all dependency management
- Monitor logs for unauthorized access attempts
- Follow React best practices in component structure
- Utilize TypeScript for type safety
- Leverage Tailwind CSS for styling
- Organize code within
src/directory structure
- Restricted File Access: AI can only modify
src/andpackage.json - Auto-Generated System Files: All configuration files are now immutable
- Enhanced Security: Path validation and logging for all operations
- Simplified Workflow: No need to manage build configuration
- Existing containers continue to work
- API endpoints remain the same
- Only file creation restrictions have been added
- System file generation is now automatic
Last Updated: January 2024
Platform Version: 1.1.0 - AI Restricted Access