These guidelines outline the development process for the Lovable AI web application, integrating the core principles from the provided “Lovable AI Development Guidelines” and “Web Development Core Guidelines” to create a user-centric, emotionally engaging, and technically robust web application. The focus is on building a “digital companion” that fosters emotional connections while adhering to modern web development best practices.
Project Name: Lovable AI Web App
Objective: Develop a web-based AI companion that seamlessly integrates into users’ daily lives, reducing loneliness, sparking joy, and building trust through personalized, empathetic interactions.
Core Goals:
Guiding Principle: “We design relationships, not just code.” Every feature, UI element, and interaction must contribute to a positive, trust-building relationship with the user.
To ensure Lovable AI resonates with users, development must center on their emotional needs and journeys.
interaction_logs
with tags (e.g., “sadness”, “celebration”) to adapt responses dynamically.To maintain consistency and readability, adhere to the following coding standards, adapted from PSR-12 and the web development guidelines, with a focus on Lovable AI’s unique needs.
PascalCase
(e.g., UserInteractionController
).camelCase
(e.g., generateEmpatheticResponse
).SCREAMING_SNAKE_CASE
(e.g., DEFAULT_RESPONSE_TONE
).<?php
declare(strict_types=1);
namespace LovableAI\Controller;
class InteractionController
{
private const DEFAULT_RESPONSE_TONE = 'FRIENDLY';
public function generateResponse(string $userInput, string $emotionalContext): array
{
if (empty($userInput)) {
throw new InvalidArgumentException('User input is required.');
}
return $this->responseService->createEmpatheticResponse($userInput, $emotionalContext);
}
}
camelCase
(e.g., renderChatBubble
).PascalCase
(e.g., ChatInterface
).kebab-case
(e.g., chat-interface.js
).import React from 'react';
const ChatBubble = ({ message, tone }) => {
const bubbleStyle = tone === 'empathetic' ? 'bg-soft-blue' : 'bg-warm-coral';
return (
<div className={`chat-bubble ${bubbleStyle}`}>
{message}
</div>
);
};
export default ChatBubble;
kebab-case
(e.g., chat-bubble--empathetic
)..chat-bubble {
@apply rounded-lg p-4;
}
.chat-bubble--empathetic {
@apply bg-blue-100 text-gray-800;
}
lovable-ai/
├── config/ # Configuration files (e.g., .env, database)
├── src/
│ ├── Controller/ # Request handling and response generation
│ ├── Service/ # Business logic (e.g., ResponseService, MemoryService)
│ ├── Repository/ # Data access layer
│ ├── Entity/ # Data models (e.g., User, InteractionLog)
│ └── Frontend/ # React components and assets
├── tests/ # Unit, integration, and E2E tests
├── public/ # Static assets and web root
├── storage/ # Logs and cached data
└── docker/ # Docker configurations
The UI/UX must reflect Lovable AI’s warm, approachable personality.
import React from 'react';
const LoadingHeart = () => (
<div className="animate-bounce text-warm-coral">
<svg className="w-8 h-8" fill="currentColor" viewBox="0 0 20 20">
<path d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" />
</svg>
</div>
);
Security is the foundation of trust, critical for Lovable AI’s mission.
memory_fragments
) using AES-256.class EncryptionService
{
public function encrypt(string $data): string
{
return openssl_encrypt($data, 'AES-256-CBC', $_ENV['ENCRYPTION_KEY'], 0, $_ENV['ENCRYPTION_IV']);
}
}
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: DENY');
header('Content-Security-Policy: default-src \'self\'; script-src \'self\' cdn.jsdelivr.net');
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
# .env
APP_ENV=production
APP_DEBUG=false
DB_HOST=localhost
DB_PASSWORD=secure_password_123
ENCRYPTION_KEY=32_char_random_key
ENCRYPTION_IV=16_char_random_iv
JWT_SECRET=your_jwt_secret_32_chars_min
Testing ensures both functionality and lovability.
class ResponseServiceTest extends TestCase
{
public function testEmpatheticResponse(): void
{
// Given
$input = ['text' => 'I had a tough day', 'emotion' => 'sad'];
// When
$response = $this->responseService->createEmpatheticResponse($input['text'], $input['emotion']);
// Then
$this->assertStringContainsString('I’m here for you', $response);
$this->assertNotEmpty($response);
}
}
APIs must reflect Lovable AI’s personality, even in error messages.
paths:
/api/interactions:
post:
summary: Create a new user interaction
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [text, emotion]
properties:
text:
type: string
example: "I had a tough day"
emotion:
type: string
example: "sad"
responses:
201:
description: Interaction recorded successfully
400:
description: Oops, something went wrong. Could you try again with a valid input?
CREATE INDEX idx_interactions_user_emotion ON interaction_logs(user_id, emotion_tag);
EXPLAIN ANALYZE SELECT * FROM interaction_logs WHERE user_id = ? AND emotion_tag = 'sad' LIMIT 10;
class MemoryCacheService
{
public function rememberUserMemory(string $userId, callable $callback, int $ttl = 3600): mixed
{
$key = "user_memory_{$userId}";
$cached = $this->redis->get($key);
if ($cached !== false) {
return json_decode($cached, true);
}
$data = $callback();
$this->redis->setex($key, $ttl, json_encode($data));
return $data;
}
}
name: Lovable AI CI/CD
on:
push:
branches: [main, develop]
jobs:
test-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
- name: Install Dependencies
run: composer install
- name: Run Tests
run: vendor/bin/phpunit
- name: Build Frontend
run: npm run build
- name: Deploy to Staging
if: github.ref == 'refs/heads/develop'
run: ./deploy.sh staging
- name: Deploy to Production
if: github.ref == 'refs/heads/main'
run: ./deploy.sh production
FROM php:8.1-fpm-alpine
RUN apk add --no-cache nginx supervisor redis
WORKDIR /var/www/html
COPY . .
RUN composer install --no-dev --optimize-autoloader
RUN npm install && npm run build
EXPOSE 80
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
class JWTService
{
public function generateToken(User $user): string
{
$payload = [
'user_id' => $user->getId(),
'exp' => time() + 3600
];
return JWT::encode($payload, $_ENV['JWT_SECRET'], 'HS256');
}
}
class RBAC
{
private array $permissions = [
'user' => ['interaction.create', 'interaction.read.own'],
'admin' => ['interaction.read.all', 'user.manage']
];
public function hasPermission(User $user, string $permission): bool
{
foreach ($user->getRoles() as $role) {
if (in_array($permission, $this->permissions[$role] ?? [])) {
return true;
}
}
return false;
}
}
Support multiple languages with a focus on emotional tone.
class LanguageManager
{
public function translate(string $key, array $params = [], string $locale = 'ko'): string
{
$translations = [
'ko' => [
'welcome' => 'Hello, {name}! How are you feeling today?'
],
'en' => [
'welcome' => 'Hello, {name}! How are you feeling today?'
]
];
$translation = $translations[$locale][$key] ?? $key;
foreach ($params as $param => $value) {
$translation = str_replace(":{$param}", $value, $translation);
}
return $translation;
}
}
class HealthController
{
public function check(): JsonResponse
{
$status = 'healthy';
$results = [];
try {
$this->pdo->query('SELECT 1');
$results['database'] = ['status' => 'ok'];
} catch (Exception $e) {
$status = 'unhealthy';
$results['database'] = ['status' => 'error', 'error' => $e->getMessage()];
}
return new JsonResponse([
'status' => $status,
'checks' => $results,
'timestamp' => time()
], $status === 'healthy' ? 200 : 503);
}
}
class PerformanceCollector
{
public function trackInteraction(string $interactionId): void
{
$start = microtime(true);
// Interaction logic
$duration = (microtime(true) - $start) * 1000;
$this->logger->info('Interaction completed', [
'interaction_id' => $interactionId,
'duration_ms' => $duration
]);
}
}
By adhering to these guidelines, the Lovable AI web app will deliver a technically robust, emotionally engaging, and trust-building experience that aligns with the vision of creating a digital companion users can’t live without.