├── database ├── .gitignore ├── seeders │ └── DatabaseSeeder.php ├── factories │ ├── ChatFactory.php │ ├── MessageFactory.php │ └── UserFactory.php └── migrations │ ├── 2025_05_28_173049_create_chats_table.php │ ├── 2025_05_28_173221_create_messages_table.php │ ├── 0001_01_01_000001_create_cache_table.php │ ├── 0001_01_01_000000_create_users_table.php │ └── 0001_01_01_000002_create_jobs_table.php ├── bootstrap ├── cache │ └── .gitignore ├── providers.php └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── private │ │ └── .gitignore │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── public ├── robots.txt ├── favicon.ico ├── apple-touch-icon.png ├── index.php ├── .htaccess └── favicon.svg ├── resources ├── js │ ├── types │ │ ├── vite-env.d.ts │ │ ├── global.d.ts │ │ └── index.d.ts │ ├── lib │ │ └── utils.ts │ ├── hooks │ │ ├── use-mobile-navigation.ts │ │ ├── use-initials.tsx │ │ ├── use-mobile.tsx │ │ └── use-appearance.tsx │ ├── components │ │ ├── ui │ │ │ ├── skeleton.tsx │ │ │ ├── icon.tsx │ │ │ ├── label.tsx │ │ │ ├── placeholder-pattern.tsx │ │ │ ├── separator.tsx │ │ │ ├── collapsible.tsx │ │ │ ├── input.tsx │ │ │ ├── checkbox.tsx │ │ │ ├── avatar.tsx │ │ │ ├── toggle.tsx │ │ │ ├── badge.tsx │ │ │ ├── card.tsx │ │ │ ├── scroll-area.tsx │ │ │ ├── alert.tsx │ │ │ ├── tooltip.tsx │ │ │ ├── toggle-group.tsx │ │ │ ├── button.tsx │ │ │ └── breadcrumb.tsx │ │ ├── heading-small.tsx │ │ ├── heading.tsx │ │ ├── input-error.tsx │ │ ├── icon.tsx │ │ ├── app-logo.tsx │ │ ├── app-shell.tsx │ │ ├── text-link.tsx │ │ ├── streaming-indicator.tsx │ │ ├── app-content.tsx │ │ ├── app-logo-icon.tsx │ │ ├── user-info.tsx │ │ ├── nav-main.tsx │ │ ├── title-generator.tsx │ │ ├── sidebar-title-updater.tsx │ │ ├── chat-title-updater.tsx │ │ ├── app-sidebar.tsx │ │ ├── nav-footer.tsx │ │ ├── breadcrumbs.tsx │ │ ├── appearance-tabs.tsx │ │ ├── nav-user.tsx │ │ ├── user-menu-content.tsx │ │ ├── app-sidebar-header.tsx │ │ ├── appearance-dropdown.tsx │ │ ├── test-event-stream.tsx │ │ └── conversation.tsx │ ├── layouts │ │ ├── auth-layout.tsx │ │ ├── app │ │ │ ├── app-header-layout.tsx │ │ │ └── app-sidebar-layout.tsx │ │ ├── app-layout.tsx │ │ ├── auth │ │ │ ├── auth-card-layout.tsx │ │ │ ├── auth-simple-layout.tsx │ │ │ └── auth-split-layout.tsx │ │ └── settings │ │ │ └── layout.tsx │ ├── app.tsx │ ├── pages │ │ ├── settings │ │ │ └── appearance.tsx │ │ ├── auth │ │ │ ├── verify-email.tsx │ │ │ ├── confirm-password.tsx │ │ │ ├── forgot-password.tsx │ │ │ └── reset-password.tsx │ │ └── dashboard.tsx │ └── ssr.tsx └── views │ └── app.blade.php ├── .prettierignore ├── tests ├── Unit │ ├── ExampleTest.php │ └── ChatPersistenceTest.php ├── Feature │ ├── ExampleTest.php │ ├── DashboardTest.php │ ├── Auth │ │ ├── RegistrationTest.php │ │ ├── PasswordConfirmationTest.php │ │ ├── AuthenticationTest.php │ │ ├── EmailVerificationTest.php │ │ └── PasswordResetTest.php │ ├── Settings │ │ ├── PasswordUpdateTest.php │ │ └── ProfileUpdateTest.php │ ├── ChatAuthenticationFlowTest.php │ ├── ChatTest.php │ ├── SidebarStateTest.php │ └── ChatFirstMessageTest.php ├── TestCase.php └── Pest.php ├── app ├── Http │ ├── Controllers │ │ ├── Controller.php │ │ ├── Auth │ │ │ ├── EmailVerificationNotificationController.php │ │ │ ├── EmailVerificationPromptController.php │ │ │ ├── VerifyEmailController.php │ │ │ ├── PasswordResetLinkController.php │ │ │ ├── ConfirmablePasswordController.php │ │ │ ├── AuthenticatedSessionController.php │ │ │ ├── RegisteredUserController.php │ │ │ └── NewPasswordController.php │ │ ├── Api │ │ │ └── ChatController.php │ │ └── Settings │ │ │ ├── PasswordController.php │ │ │ └── ProfileController.php │ ├── Middleware │ │ ├── HandleAppearance.php │ │ └── HandleInertiaRequests.php │ └── Requests │ │ ├── Settings │ │ └── ProfileUpdateRequest.php │ │ └── Auth │ │ └── LoginRequest.php ├── Providers │ └── AppServiceProvider.php ├── Models │ ├── Chat.php │ ├── Message.php │ └── User.php └── Policies │ └── ChatPolicy.php ├── .gitattributes ├── routes ├── console.php ├── web.php ├── chat.php ├── settings.php └── auth.php ├── .editorconfig ├── .gitignore ├── artisan ├── .prettierrc ├── components.json ├── vite.config.ts ├── .github └── workflows │ ├── lint.yml │ └── tests.yml ├── config ├── services.php ├── inertia.php ├── openai.php ├── filesystems.php ├── cache.php ├── mail.php └── queue.php ├── phpunit.xml ├── .env.example ├── eslint.config.js ├── package.json ├── composer.json └── CLAUDE.md /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/private/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !private/ 3 | !public/ 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /resources/js/types/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laravel/larachat/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | resources/js/components/ui/* 2 | resources/js/ziggy.js 3 | resources/views/mail/* 4 | -------------------------------------------------------------------------------- /bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | get('/'); 5 | 6 | $response->assertStatus(200); 7 | }); 8 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote'); 9 | -------------------------------------------------------------------------------- /resources/js/hooks/use-mobile-navigation.ts: -------------------------------------------------------------------------------- 1 | import { useCallback } from 'react'; 2 | 3 | export function useMobileNavigation() { 4 | return useCallback(() => { 5 | // Remove pointer-events style from body... 6 | document.body.style.removeProperty('pointer-events'); 7 | }, []); 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /resources/js/components/ui/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from "@/lib/utils" 2 | 3 | function Skeleton({ className, ...props }: React.ComponentProps<"div">) { 4 | return ( 5 |
10 | ) 11 | } 12 | 13 | export { Skeleton } 14 | -------------------------------------------------------------------------------- /resources/js/components/heading-small.tsx: -------------------------------------------------------------------------------- 1 | export default function HeadingSmall({ title, description }: { title: string; description?: string }) { 2 | return ( 3 |
4 |

{title}

5 | {description &&

{description}

} 6 |
7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /resources/js/components/heading.tsx: -------------------------------------------------------------------------------- 1 | export default function Heading({ title, description }: { title: string; description?: string }) { 2 | return ( 3 |
4 |

{title}

5 | {description &&

{description}

} 6 |
7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /resources/js/components/ui/icon.tsx: -------------------------------------------------------------------------------- 1 | import { LucideIcon } from 'lucide-react'; 2 | 3 | interface IconProps { 4 | iconNode?: LucideIcon | null; 5 | className?: string; 6 | } 7 | 8 | export function Icon({ iconNode: IconComponent, className }: IconProps) { 9 | if (!IconComponent) { 10 | return null; 11 | } 12 | 13 | return ; 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /bootstrap/ssr 3 | /node_modules 4 | /public/build 5 | /public/hot 6 | /public/storage 7 | /storage/*.key 8 | /storage/pail 9 | /vendor 10 | .env 11 | .env.backup 12 | .env.production 13 | .phpactor.json 14 | .phpunit.result.cache 15 | Homestead.json 16 | Homestead.yaml 17 | npm-debug.log 18 | yarn-error.log 19 | /auth.json 20 | /.fleet 21 | /.idea 22 | /.nova 23 | /.vscode 24 | /.zed 25 | -------------------------------------------------------------------------------- /resources/js/layouts/auth-layout.tsx: -------------------------------------------------------------------------------- 1 | import AuthLayoutTemplate from '@/layouts/auth/auth-simple-layout'; 2 | 3 | export default function AuthLayout({ children, title, description, ...props }: { children: React.ReactNode; title: string; description: string }) { 4 | return ( 5 | 6 | {children} 7 | 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /resources/js/components/input-error.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils'; 2 | import { type HTMLAttributes } from 'react'; 3 | 4 | export default function InputError({ message, className = '', ...props }: HTMLAttributes & { message?: string }) { 5 | return message ? ( 6 |

7 | {message} 8 |

9 | ) : null; 10 | } 11 | -------------------------------------------------------------------------------- /resources/js/components/icon.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils'; 2 | import { type LucideProps } from 'lucide-react'; 3 | import { type ComponentType } from 'react'; 4 | 5 | interface IconProps extends Omit { 6 | iconNode: ComponentType; 7 | } 8 | 9 | export function Icon({ iconNode: IconComponent, className, ...props }: IconProps) { 10 | return ; 11 | } 12 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | name('home'); 6 | 7 | // Dashboard route removed - using chat as main page 8 | 9 | // API routes 10 | Route::get('/api/chats', [\App\Http\Controllers\Api\ChatController::class, 'index'])->name('api.chats.index'); 11 | 12 | require __DIR__.'/chat.php'; 13 | require __DIR__.'/settings.php'; 14 | require __DIR__.'/auth.php'; 15 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 17 | 18 | exit($status); 19 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": true, 4 | "singleAttributePerLine": false, 5 | "htmlWhitespaceSensitivity": "css", 6 | "printWidth": 150, 7 | "plugins": ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"], 8 | "tailwindFunctions": ["clsx", "cn"], 9 | "tabWidth": 4, 10 | "overrides": [ 11 | { 12 | "files": "**/*.yml", 13 | "options": { 14 | "tabWidth": 2 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/Feature/DashboardTest.php: -------------------------------------------------------------------------------- 1 | get('/dashboard')->assertStatus(404); 9 | }); 10 | 11 | test('authenticated users redirected to home after login', function () { 12 | $user = User::factory()->create(); 13 | 14 | $this->post('/login', [ 15 | 'email' => $user->email, 16 | 'password' => 'password', 17 | ])->assertRedirect('/'); 18 | }); 19 | -------------------------------------------------------------------------------- /resources/js/hooks/use-initials.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback } from 'react'; 2 | 3 | export function useInitials() { 4 | return useCallback((fullName: string): string => { 5 | const names = fullName.trim().split(' '); 6 | 7 | if (names.length === 0) return ''; 8 | if (names.length === 1) return names[0].charAt(0).toUpperCase(); 9 | 10 | const firstInitial = names[0].charAt(0); 11 | const lastInitial = names[names.length - 1].charAt(0); 12 | 13 | return `${firstInitial}${lastInitial}`.toUpperCase(); 14 | }, []); 15 | } 16 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | 18 | User::factory()->create([ 19 | 'name' => 'Test User', 20 | 'email' => 'test@example.com', 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": false, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "resources/css/app.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib", 18 | "hooks": "@/hooks" 19 | }, 20 | "iconLibrary": "lucide" 21 | } 22 | -------------------------------------------------------------------------------- /resources/js/layouts/app/app-header-layout.tsx: -------------------------------------------------------------------------------- 1 | import { AppContent } from '@/components/app-content'; 2 | import { AppHeader } from '@/components/app-header'; 3 | import { AppShell } from '@/components/app-shell'; 4 | import { type BreadcrumbItem } from '@/types'; 5 | import type { PropsWithChildren } from 'react'; 6 | 7 | export default function AppHeaderLayout({ children, breadcrumbs }: PropsWithChildren<{ breadcrumbs?: BreadcrumbItem[] }>) { 8 | return ( 9 | 10 | 11 | {children} 12 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 21 | -------------------------------------------------------------------------------- /database/factories/ChatFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class ChatFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'user_id' => User::factory(), 22 | 'title' => $this->faker->sentence(4), 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /resources/js/components/app-logo.tsx: -------------------------------------------------------------------------------- 1 | import AppLogoIcon from './app-logo-icon'; 2 | 3 | export default function AppLogo() { 4 | return ( 5 | <> 6 |
7 | 8 |
9 |
10 | LaraChat 11 |
12 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /resources/js/layouts/app-layout.tsx: -------------------------------------------------------------------------------- 1 | import AppLayoutTemplate from '@/layouts/app/app-sidebar-layout'; 2 | import { type BreadcrumbItem } from '@/types'; 3 | import { type ReactNode } from 'react'; 4 | 5 | interface AppLayoutProps { 6 | children: ReactNode; 7 | breadcrumbs?: BreadcrumbItem[]; 8 | currentChatId?: number; 9 | className?: string; 10 | } 11 | 12 | export default ({ children, breadcrumbs, currentChatId, className, ...props }: AppLayoutProps) => ( 13 | 14 | {children} 15 | 16 | ); 17 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | get('/register'); 7 | 8 | $response->assertStatus(200); 9 | }); 10 | 11 | test('new users can register', function () { 12 | $response = $this->post('/register', [ 13 | 'name' => 'Test User', 14 | 'email' => 'test@example.com', 15 | 'password' => 'password', 16 | 'password_confirmation' => 'password', 17 | ]); 18 | 19 | $this->assertAuthenticated(); 20 | $response->assertRedirect(route('home', absolute: false)); 21 | }); 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleAppearance.php: -------------------------------------------------------------------------------- 1 | cookie('appearance') ?? 'system'); 20 | 21 | return $next($request); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/js/components/app-shell.tsx: -------------------------------------------------------------------------------- 1 | import { SidebarProvider } from '@/components/ui/sidebar'; 2 | import { SharedData } from '@/types'; 3 | import { usePage } from '@inertiajs/react'; 4 | 5 | interface AppShellProps { 6 | children: React.ReactNode; 7 | variant?: 'header' | 'sidebar'; 8 | } 9 | 10 | export function AppShell({ children, variant = 'header' }: AppShellProps) { 11 | const isOpen = usePage().props.sidebarOpen; 12 | 13 | if (variant === 'header') { 14 | return
{children}
; 15 | } 16 | 17 | return {children}; 18 | } 19 | -------------------------------------------------------------------------------- /resources/js/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as LabelPrimitive from "@radix-ui/react-label" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | function Label({ 7 | className, 8 | ...props 9 | }: React.ComponentProps) { 10 | return ( 11 | 19 | ) 20 | } 21 | 22 | export { Label } 23 | -------------------------------------------------------------------------------- /resources/js/components/text-link.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils'; 2 | import { Link } from '@inertiajs/react'; 3 | import { ComponentProps } from 'react'; 4 | 5 | type LinkProps = ComponentProps; 6 | 7 | export default function TextLink({ className = '', children, ...props }: LinkProps) { 8 | return ( 9 | 16 | {children} 17 | 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /resources/js/hooks/use-mobile.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react'; 2 | 3 | const MOBILE_BREAKPOINT = 768; 4 | 5 | export function useIsMobile() { 6 | const [isMobile, setIsMobile] = useState(); 7 | 8 | useEffect(() => { 9 | const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`); 10 | 11 | const onChange = () => { 12 | setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); 13 | }; 14 | 15 | mql.addEventListener('change', onChange); 16 | setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); 17 | 18 | return () => mql.removeEventListener('change', onChange); 19 | }, []); 20 | 21 | return !!isMobile; 22 | } 23 | -------------------------------------------------------------------------------- /resources/js/components/streaming-indicator.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils'; 2 | import { useStream } from '@laravel/stream-react'; 3 | 4 | interface StreamingIndicatorProps { 5 | id: string; 6 | className?: string; 7 | } 8 | 9 | export default function StreamingIndicator({ id, className }: StreamingIndicatorProps) { 10 | const { isFetching, isStreaming } = useStream('chat', { id }); 11 | 12 | if (isStreaming) { 13 | return
; 14 | } 15 | 16 | if (isFetching) { 17 | return
; 18 | } 19 | 20 | return null; 21 | } 22 | -------------------------------------------------------------------------------- /database/factories/MessageFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class MessageFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'chat_id' => Chat::factory(), 22 | 'type' => $this->faker->randomElement(['prompt', 'response']), 23 | 'content' => $this->faker->paragraph(), 24 | ]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Models/Chat.php: -------------------------------------------------------------------------------- 1 | */ 13 | use HasFactory; 14 | 15 | protected $fillable = [ 16 | 'user_id', 17 | 'title', 18 | ]; 19 | 20 | public function user(): BelongsTo 21 | { 22 | return $this->belongsTo(User::class); 23 | } 24 | 25 | public function messages(): HasMany 26 | { 27 | return $this->hasMany(Message::class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import tailwindcss from '@tailwindcss/vite'; 2 | import react from '@vitejs/plugin-react'; 3 | import laravel from 'laravel-vite-plugin'; 4 | import { resolve } from 'node:path'; 5 | import { defineConfig } from 'vite'; 6 | 7 | export default defineConfig({ 8 | plugins: [ 9 | laravel({ 10 | input: ['resources/css/app.css', 'resources/js/app.tsx'], 11 | ssr: 'resources/js/ssr.tsx', 12 | refresh: true, 13 | }), 14 | react(), 15 | tailwindcss(), 16 | ], 17 | esbuild: { 18 | jsx: 'automatic', 19 | }, 20 | resolve: { 21 | alias: { 22 | 'ziggy-js': resolve(__dirname, 'vendor/tightenco/ziggy'), 23 | }, 24 | }, 25 | }); 26 | -------------------------------------------------------------------------------- /resources/js/components/ui/placeholder-pattern.tsx: -------------------------------------------------------------------------------- 1 | import { useId } from 'react'; 2 | 3 | interface PlaceholderPatternProps { 4 | className?: string; 5 | } 6 | 7 | export function PlaceholderPattern({ className }: PlaceholderPatternProps) { 8 | const patternId = useId(); 9 | 10 | return ( 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationNotificationController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 17 | return redirect()->intended(route('home', absolute: false)); 18 | } 19 | 20 | $request->user()->sendEmailVerificationNotification(); 21 | 22 | return back()->with('status', 'verification-link-sent'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationPromptController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail() 19 | ? redirect()->intended(route('home', absolute: false)) 20 | : Inertia::render('auth/verify-email', ['status' => $request->session()->get('status')]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /resources/js/components/app-content.tsx: -------------------------------------------------------------------------------- 1 | import { SidebarInset } from '@/components/ui/sidebar'; 2 | import * as React from 'react'; 3 | 4 | interface AppContentProps extends React.ComponentProps<'main'> { 5 | variant?: 'header' | 'sidebar'; 6 | className?: string; 7 | } 8 | 9 | export function AppContent({ variant = 'header', children, className, ...props }: AppContentProps) { 10 | if (variant === 'sidebar') { 11 | return ( 12 | 13 | {children} 14 | 15 | ); 16 | } 17 | 18 | return ( 19 |
20 | {children} 21 |
22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /app/Models/Message.php: -------------------------------------------------------------------------------- 1 | */ 12 | use HasFactory; 13 | 14 | protected $fillable = [ 15 | 'chat_id', 16 | 'type', 17 | 'content', 18 | ]; 19 | 20 | protected $casts = [ 21 | 'type' => 'string', 22 | ]; 23 | 24 | protected $appends = ['saved']; 25 | 26 | public function getSavedAttribute() 27 | { 28 | return true; 29 | } 30 | 31 | public function chat(): BelongsTo 32 | { 33 | return $this->belongsTo(Chat::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2025_05_28_173049_create_chats_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('user_id')->constrained()->cascadeOnDelete(); 17 | $table->string('title')->nullable(); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | */ 25 | public function down(): void 26 | { 27 | Schema::dropIfExists('chats'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /resources/js/components/ui/separator.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as SeparatorPrimitive from "@radix-ui/react-separator" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | function Separator({ 7 | className, 8 | orientation = "horizontal", 9 | decorative = true, 10 | ...props 11 | }: React.ComponentProps) { 12 | return ( 13 | 23 | ) 24 | } 25 | 26 | export { Separator } 27 | -------------------------------------------------------------------------------- /resources/js/app.tsx: -------------------------------------------------------------------------------- 1 | import '../css/app.css'; 2 | 3 | import { createInertiaApp } from '@inertiajs/react'; 4 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 5 | import { createRoot } from 'react-dom/client'; 6 | import { initializeTheme } from './hooks/use-appearance'; 7 | 8 | const appName = import.meta.env.VITE_APP_NAME || 'Laravel'; 9 | 10 | createInertiaApp({ 11 | title: (title) => `${title} - ${appName}`, 12 | resolve: (name) => resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob('./pages/**/*.tsx')), 13 | setup({ el, App, props }) { 14 | const root = createRoot(el); 15 | 16 | root.render(); 17 | }, 18 | progress: { 19 | color: '#4B5563', 20 | }, 21 | }); 22 | 23 | // This will set light / dark mode on load... 24 | initializeTheme(); 25 | -------------------------------------------------------------------------------- /routes/chat.php: -------------------------------------------------------------------------------- 1 | name('chat.stream'); 7 | 8 | Route::middleware('auth')->group(function () { 9 | Route::post('/chat', [ChatController::class, 'store'])->name('chat.store'); 10 | Route::get('/chat/{chat}', [ChatController::class, 'show'])->name('chat.show'); 11 | Route::patch('/chat/{chat}', [ChatController::class, 'update'])->name('chat.update'); 12 | Route::delete('/chat/{chat}', [ChatController::class, 'destroy'])->name('chat.destroy'); 13 | Route::post('/chat/{chat}/stream', [ChatController::class, 'stream'])->name('chat.show.stream'); 14 | Route::get('/chat/{chat}/title-stream', [ChatController::class, 'titleStream'])->name('chat.title.stream'); 15 | }); 16 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Handle X-XSRF-Token Header 13 | RewriteCond %{HTTP:x-xsrf-token} . 14 | RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}] 15 | 16 | # Redirect Trailing Slashes If Not A Folder... 17 | RewriteCond %{REQUEST_FILENAME} !-d 18 | RewriteCond %{REQUEST_URI} (.+)/$ 19 | RewriteRule ^ %1 [L,R=301] 20 | 21 | # Send Requests To Front Controller... 22 | RewriteCond %{REQUEST_FILENAME} !-d 23 | RewriteCond %{REQUEST_FILENAME} !-f 24 | RewriteRule ^ index.php [L] 25 | 26 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/ChatController.php: -------------------------------------------------------------------------------- 1 | json([]); 14 | } 15 | 16 | $chats = Auth::user()->chats() 17 | ->latest() 18 | ->get() 19 | ->map(function ($chat) { 20 | return [ 21 | 'id' => $chat->id, 22 | 'title' => $chat->title ?? 'Untitled Chat', 23 | 'created_at' => $chat->created_at, 24 | 'updated_at' => $chat->updated_at, 25 | ]; 26 | }); 27 | 28 | return response()->json($chats); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2025_05_28_173221_create_messages_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('chat_id')->constrained()->cascadeOnDelete(); 17 | $table->enum('type', ['prompt', 'response', 'error']); 18 | $table->text('content'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('messages'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /app/Http/Requests/Settings/ProfileUpdateRequest.php: -------------------------------------------------------------------------------- 1 | |string> 16 | */ 17 | public function rules(): array 18 | { 19 | return [ 20 | 'name' => ['required', 'string', 'max:255'], 21 | 22 | 'email' => [ 23 | 'required', 24 | 'string', 25 | 'lowercase', 26 | 'email', 27 | 'max:255', 28 | Rule::unique(User::class)->ignore($this->user()->id), 29 | ], 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /resources/js/components/ui/collapsible.tsx: -------------------------------------------------------------------------------- 1 | import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" 2 | 3 | function Collapsible({ 4 | ...props 5 | }: React.ComponentProps) { 6 | return 7 | } 8 | 9 | function CollapsibleTrigger({ 10 | ...props 11 | }: React.ComponentProps) { 12 | return ( 13 | 17 | ) 18 | } 19 | 20 | function CollapsibleContent({ 21 | ...props 22 | }: React.ComponentProps) { 23 | return ( 24 | 28 | ) 29 | } 30 | 31 | export { Collapsible, CollapsibleTrigger, CollapsibleContent } 32 | -------------------------------------------------------------------------------- /routes/settings.php: -------------------------------------------------------------------------------- 1 | group(function () { 9 | Route::redirect('settings', 'settings/profile'); 10 | 11 | Route::get('settings/profile', [ProfileController::class, 'edit'])->name('profile.edit'); 12 | Route::patch('settings/profile', [ProfileController::class, 'update'])->name('profile.update'); 13 | Route::delete('settings/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); 14 | 15 | Route::get('settings/password', [PasswordController::class, 'edit'])->name('password.edit'); 16 | Route::put('settings/password', [PasswordController::class, 'update'])->name('password.update'); 17 | 18 | Route::get('settings/appearance', function () { 19 | return Inertia::render('settings/appearance'); 20 | })->name('appearance'); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordConfirmationTest.php: -------------------------------------------------------------------------------- 1 | create(); 9 | 10 | $response = $this->actingAs($user)->get('/confirm-password'); 11 | 12 | $response->assertStatus(200); 13 | }); 14 | 15 | test('password can be confirmed', function () { 16 | $user = User::factory()->create(); 17 | 18 | $response = $this->actingAs($user)->post('/confirm-password', [ 19 | 'password' => 'password', 20 | ]); 21 | 22 | $response->assertRedirect(); 23 | $response->assertSessionHasNoErrors(); 24 | }); 25 | 26 | test('password is not confirmed with invalid password', function () { 27 | $user = User::factory()->create(); 28 | 29 | $response = $this->actingAs($user)->post('/confirm-password', [ 30 | 'password' => 'wrong-password', 31 | ]); 32 | 33 | $response->assertSessionHasErrors(); 34 | }); 35 | -------------------------------------------------------------------------------- /resources/js/layouts/app/app-sidebar-layout.tsx: -------------------------------------------------------------------------------- 1 | import { AppContent } from '@/components/app-content'; 2 | import { AppShell } from '@/components/app-shell'; 3 | import { AppSidebar } from '@/components/app-sidebar'; 4 | import { AppSidebarHeader } from '@/components/app-sidebar-header'; 5 | import { type BreadcrumbItem } from '@/types'; 6 | import { type PropsWithChildren } from 'react'; 7 | 8 | interface AppSidebarLayoutProps { 9 | breadcrumbs?: BreadcrumbItem[]; 10 | currentChatId?: number; 11 | className?: string; 12 | } 13 | 14 | export default function AppSidebarLayout({ children, breadcrumbs = [], currentChatId, className }: PropsWithChildren) { 15 | return ( 16 | 17 | 18 | 19 | 20 | {children} 21 | 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /database/migrations/0001_01_01_000001_create_cache_table.php: -------------------------------------------------------------------------------- 1 | string('key')->primary(); 16 | $table->mediumText('value'); 17 | $table->integer('expiration'); 18 | }); 19 | 20 | Schema::create('cache_locks', function (Blueprint $table) { 21 | $table->string('key')->primary(); 22 | $table->string('owner'); 23 | $table->integer('expiration'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('cache'); 33 | Schema::dropIfExists('cache_locks'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerifyEmailController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 18 | return redirect()->intended(route('home', absolute: false).'?verified=1'); 19 | } 20 | 21 | if ($request->user()->markEmailAsVerified()) { 22 | /** @var \Illuminate\Contracts\Auth\MustVerifyEmail $user */ 23 | $user = $request->user(); 24 | 25 | event(new Verified($user)); 26 | } 27 | 28 | return redirect()->intended(route('home', absolute: false).'?verified=1'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/js/components/ui/input.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | function Input({ className, type, ...props }: React.ComponentProps<"input">) { 6 | return ( 7 | 18 | ) 19 | } 20 | 21 | export { Input } 22 | -------------------------------------------------------------------------------- /resources/js/pages/settings/appearance.tsx: -------------------------------------------------------------------------------- 1 | import { Head } from '@inertiajs/react'; 2 | 3 | import AppearanceTabs from '@/components/appearance-tabs'; 4 | import HeadingSmall from '@/components/heading-small'; 5 | import { type BreadcrumbItem } from '@/types'; 6 | 7 | import AppLayout from '@/layouts/app-layout'; 8 | import SettingsLayout from '@/layouts/settings/layout'; 9 | 10 | const breadcrumbs: BreadcrumbItem[] = [ 11 | { 12 | title: 'Appearance settings', 13 | href: '/settings/appearance', 14 | }, 15 | ]; 16 | 17 | export default function Appearance() { 18 | return ( 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 |
27 |
28 |
29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /resources/js/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { LucideIcon } from 'lucide-react'; 2 | import type { Config } from 'ziggy-js'; 3 | 4 | export interface Auth { 5 | user: User; 6 | } 7 | 8 | export interface BreadcrumbItem { 9 | title: string; 10 | href: string; 11 | } 12 | 13 | export interface NavGroup { 14 | title: string; 15 | items: NavItem[]; 16 | } 17 | 18 | export interface NavItem { 19 | title: string; 20 | href: string; 21 | icon?: LucideIcon | null; 22 | isActive?: boolean; 23 | } 24 | 25 | export interface SharedData { 26 | name: string; 27 | quote: { message: string; author: string }; 28 | auth: Auth; 29 | ziggy: Config & { location: string }; 30 | sidebarOpen: boolean; 31 | [key: string]: unknown; 32 | } 33 | 34 | export interface User { 35 | id: number; 36 | name: string; 37 | email: string; 38 | avatar?: string; 39 | email_verified_at: string | null; 40 | created_at: string; 41 | updated_at: string; 42 | [key: string]: unknown; // This allows for additional properties... 43 | } 44 | -------------------------------------------------------------------------------- /resources/js/components/app-logo-icon.tsx: -------------------------------------------------------------------------------- 1 | import { SVGAttributes } from 'react'; 2 | 3 | export default function AppLogoIcon(props: SVGAttributes) { 4 | return ( 5 | 6 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /resources/js/components/user-info.tsx: -------------------------------------------------------------------------------- 1 | import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; 2 | import { useInitials } from '@/hooks/use-initials'; 3 | import { type User } from '@/types'; 4 | 5 | export function UserInfo({ user, showEmail = false }: { user: User; showEmail?: boolean }) { 6 | const getInitials = useInitials(); 7 | 8 | return ( 9 | <> 10 | 11 | 12 | 13 | {getInitials(user.name)} 14 | 15 | 16 |
17 | {user.name} 18 | {showEmail && {user.email}} 19 |
20 | 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: linter 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | - main 8 | pull_request: 9 | branches: 10 | - develop 11 | - main 12 | 13 | permissions: 14 | contents: write 15 | 16 | jobs: 17 | quality: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - name: Setup PHP 23 | uses: shivammathur/setup-php@v2 24 | with: 25 | php-version: '8.4' 26 | 27 | - name: Install Dependencies 28 | run: | 29 | composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist 30 | npm install 31 | 32 | - name: Run Pint 33 | run: vendor/bin/pint 34 | 35 | - name: Format Frontend 36 | run: npm run format 37 | 38 | - name: Lint Frontend 39 | run: npm run lint 40 | 41 | # - name: Commit Changes 42 | # uses: stefanzweifel/git-auto-commit-action@v5 43 | # with: 44 | # commit_message: fix code style 45 | # commit_options: '--no-verify' 46 | -------------------------------------------------------------------------------- /app/Http/Controllers/Settings/PasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 29 | 'current_password' => ['required', 'current_password'], 30 | 'password' => ['required', Password::defaults(), 'confirmed'], 31 | ]); 32 | 33 | $request->user()->update([ 34 | 'password' => Hash::make($validated['password']), 35 | ]); 36 | 37 | return back(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /resources/js/components/nav-main.tsx: -------------------------------------------------------------------------------- 1 | import { SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar'; 2 | import { type NavItem } from '@/types'; 3 | import { Link, usePage } from '@inertiajs/react'; 4 | 5 | export function NavMain({ items = [] }: { items: NavItem[] }) { 6 | const page = usePage(); 7 | return ( 8 | 9 | Platform 10 | 11 | {items.map((item) => ( 12 | 13 | 14 | 15 | {item.icon && } 16 | {item.title} 17 | 18 | 19 | 20 | ))} 21 | 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 12 | web: __DIR__.'/../routes/web.php', 13 | commands: __DIR__.'/../routes/console.php', 14 | health: '/up', 15 | ) 16 | ->withMiddleware(function (Middleware $middleware) { 17 | $middleware->encryptCookies(except: ['appearance', 'sidebar_state']); 18 | 19 | $middleware->web(append: [ 20 | HandleAppearance::class, 21 | HandleInertiaRequests::class, 22 | AddLinkHeadersForPreloadedAssets::class, 23 | ]); 24 | 25 | $middleware->validateCsrfTokens(except: [ 26 | 'chat/stream', 27 | 'chat/*/stream', 28 | ]); 29 | }) 30 | ->withExceptions(function (Exceptions $exceptions) { 31 | // 32 | })->create(); 33 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | - main 8 | pull_request: 9 | branches: 10 | - develop 11 | - main 12 | 13 | jobs: 14 | ci: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v4 20 | 21 | - name: Setup PHP 22 | uses: shivammathur/setup-php@v2 23 | with: 24 | php-version: 8.4 25 | tools: composer:v2 26 | coverage: xdebug 27 | 28 | - name: Setup Node 29 | uses: actions/setup-node@v4 30 | with: 31 | node-version: '22' 32 | cache: 'npm' 33 | 34 | - name: Install Node Dependencies 35 | run: npm ci 36 | 37 | - name: Build Assets 38 | run: npm run build 39 | 40 | - name: Install Dependencies 41 | run: composer install --no-interaction --prefer-dist --optimize-autoloader 42 | 43 | - name: Copy Environment File 44 | run: cp .env.example .env 45 | 46 | - name: Generate Application Key 47 | run: php artisan key:generate 48 | 49 | - name: Tests 50 | run: ./vendor/bin/pest 51 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'resend' => [ 28 | 'key' => env('RESEND_KEY'), 29 | ], 30 | 31 | 'slack' => [ 32 | 'notifications' => [ 33 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 34 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 35 | ], 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /tests/Feature/Auth/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get('/login'); 9 | 10 | $response->assertStatus(200); 11 | }); 12 | 13 | test('users can authenticate using the login screen', function () { 14 | $user = User::factory()->create(); 15 | 16 | $response = $this->post('/login', [ 17 | 'email' => $user->email, 18 | 'password' => 'password', 19 | ]); 20 | 21 | $this->assertAuthenticated(); 22 | $response->assertRedirect(route('home', absolute: false)); 23 | }); 24 | 25 | test('users can not authenticate with invalid password', function () { 26 | $user = User::factory()->create(); 27 | 28 | $this->post('/login', [ 29 | 'email' => $user->email, 30 | 'password' => 'wrong-password', 31 | ]); 32 | 33 | $this->assertGuest(); 34 | }); 35 | 36 | test('users can logout', function () { 37 | $user = User::factory()->create(); 38 | 39 | $response = $this->actingAs($user)->post('/logout'); 40 | 41 | $this->assertGuest(); 42 | $response->assertRedirect('/'); 43 | }); 44 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordResetLinkController.php: -------------------------------------------------------------------------------- 1 | $request->session()->get('status'), 21 | ]); 22 | } 23 | 24 | /** 25 | * Handle an incoming password reset link request. 26 | * 27 | * @throws \Illuminate\Validation\ValidationException 28 | */ 29 | public function store(Request $request): RedirectResponse 30 | { 31 | $request->validate([ 32 | 'email' => 'required|email', 33 | ]); 34 | 35 | Password::sendResetLink( 36 | $request->only('email') 37 | ); 38 | 39 | return back()->with('status', __('A reset link will be sent if the account exists.')); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /resources/js/ssr.tsx: -------------------------------------------------------------------------------- 1 | import { createInertiaApp } from '@inertiajs/react'; 2 | import createServer from '@inertiajs/react/server'; 3 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 4 | import ReactDOMServer from 'react-dom/server'; 5 | import { type RouteName, route } from 'ziggy-js'; 6 | 7 | const appName = import.meta.env.VITE_APP_NAME || 'Laravel'; 8 | 9 | createServer((page) => 10 | createInertiaApp({ 11 | page, 12 | render: ReactDOMServer.renderToString, 13 | title: (title) => `${title} - ${appName}`, 14 | resolve: (name) => resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob('./pages/**/*.tsx')), 15 | setup: ({ App, props }) => { 16 | /* eslint-disable */ 17 | // @ts-expect-error 18 | global.route = (name, params, absolute) => 19 | route(name, params as any, absolute, { 20 | // @ts-expect-error 21 | ...page.props.ziggy, 22 | // @ts-expect-error 23 | location: new URL(page.props.ziggy.location), 24 | }); 25 | /* eslint-enable */ 26 | 27 | return ; 28 | }, 29 | }), 30 | ); 31 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ConfirmablePasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 29 | 'email' => $request->user()->email, 30 | 'password' => $request->password, 31 | ])) { 32 | throw ValidationException::withMessages([ 33 | 'password' => __('auth.password'), 34 | ]); 35 | } 36 | 37 | $request->session()->put('auth.password_confirmed_at', time()); 38 | 39 | return redirect()->intended(route('home', absolute: false)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'name' => fake()->name(), 28 | 'email' => fake()->unique()->safeEmail(), 29 | 'email_verified_at' => now(), 30 | 'password' => static::$password ??= Hash::make('password'), 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | 35 | /** 36 | * Indicate that the model's email address should be unverified. 37 | */ 38 | public function unverified(): static 39 | { 40 | return $this->state(fn (array $attributes) => [ 41 | 'email_verified_at' => null, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /resources/js/components/ui/checkbox.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as CheckboxPrimitive from "@radix-ui/react-checkbox" 3 | import { CheckIcon } from "lucide-react" 4 | 5 | import { cn } from "@/lib/utils" 6 | 7 | function Checkbox({ 8 | className, 9 | ...props 10 | }: React.ComponentProps) { 11 | return ( 12 | 20 | 24 | 25 | 26 | 27 | ) 28 | } 29 | 30 | export { Checkbox } 31 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Unit 10 | 11 | 12 | tests/Feature 13 | 14 | 15 | 16 | 17 | app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /resources/js/components/ui/avatar.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as AvatarPrimitive from "@radix-ui/react-avatar" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | function Avatar({ 7 | className, 8 | ...props 9 | }: React.ComponentProps) { 10 | return ( 11 | 19 | ) 20 | } 21 | 22 | function AvatarImage({ 23 | className, 24 | ...props 25 | }: React.ComponentProps) { 26 | return ( 27 | 32 | ) 33 | } 34 | 35 | function AvatarFallback({ 36 | className, 37 | ...props 38 | }: React.ComponentProps) { 39 | return ( 40 | 48 | ) 49 | } 50 | 51 | export { Avatar, AvatarImage, AvatarFallback } 52 | -------------------------------------------------------------------------------- /resources/js/components/title-generator.tsx: -------------------------------------------------------------------------------- 1 | import { useEventStream } from '@laravel/stream-react'; 2 | import { useState, useEffect } from 'react'; 3 | 4 | interface TitleGeneratorProps { 5 | chatId: number; 6 | onTitleUpdate: (title: string, isStreaming?: boolean) => void; 7 | onComplete: () => void; 8 | } 9 | 10 | export default function TitleGenerator({ chatId, onTitleUpdate, onComplete }: TitleGeneratorProps) { 11 | // Use the useEventStream configuration 12 | const { message } = useEventStream(`/chat/${chatId}/title-stream`, { 13 | eventName: "title-update", 14 | endSignal: "", 15 | onMessage: (event) => { 16 | try { 17 | const parsed = JSON.parse(event.data); 18 | 19 | if (parsed.title) { 20 | onTitleUpdate(parsed.title, false); 21 | } 22 | } catch (error) { 23 | console.error('Error parsing title JSON:', error); 24 | } 25 | }, 26 | onComplete: () => { 27 | onComplete(); 28 | }, 29 | onError: (error) => { 30 | console.error('Title generation error:', error); 31 | onComplete(); 32 | }, 33 | }); 34 | 35 | // This component doesn't render anything 36 | return null; 37 | } -------------------------------------------------------------------------------- /resources/js/components/sidebar-title-updater.tsx: -------------------------------------------------------------------------------- 1 | import { useEventStream } from '@laravel/stream-react'; 2 | 3 | interface SidebarTitleUpdaterProps { 4 | chatId: number; 5 | onComplete: () => void; 6 | } 7 | 8 | export default function SidebarTitleUpdater({ chatId, onComplete }: SidebarTitleUpdaterProps) { 9 | const { message } = useEventStream(`/chat/${chatId}/title-stream`, { 10 | eventName: "title-update", 11 | endSignal: "", 12 | onMessage: (event) => { 13 | try { 14 | const parsed = JSON.parse(event.data); 15 | 16 | if (parsed.title) { 17 | // Broadcast to any listening components (like ChatList) 18 | window.dispatchEvent(new CustomEvent('chatTitleUpdated', { 19 | detail: { chatId, newTitle: parsed.title } 20 | })); 21 | } 22 | } catch (error) { 23 | console.error('Error parsing sidebar title:', error); 24 | } 25 | }, 26 | onComplete: () => { 27 | onComplete(); 28 | }, 29 | onError: (error) => { 30 | console.error('Sidebar title update error:', error); 31 | onComplete(); 32 | }, 33 | }); 34 | 35 | // This component doesn't render anything 36 | return null; 37 | } -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | */ 14 | use HasFactory, Notifiable; 15 | 16 | /** 17 | * The attributes that are mass assignable. 18 | * 19 | * @var list 20 | */ 21 | protected $fillable = [ 22 | 'name', 23 | 'email', 24 | 'password', 25 | ]; 26 | 27 | /** 28 | * The attributes that should be hidden for serialization. 29 | * 30 | * @var list 31 | */ 32 | protected $hidden = [ 33 | 'password', 34 | 'remember_token', 35 | ]; 36 | 37 | /** 38 | * Get the attributes that should be cast. 39 | * 40 | * @return array 41 | */ 42 | protected function casts(): array 43 | { 44 | return [ 45 | 'email_verified_at' => 'datetime', 46 | 'password' => 'hashed', 47 | ]; 48 | } 49 | 50 | public function chats(): HasMany 51 | { 52 | return $this->hasMany(Chat::class); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Feature/Settings/PasswordUpdateTest.php: -------------------------------------------------------------------------------- 1 | create(); 10 | 11 | $response = $this 12 | ->actingAs($user) 13 | ->from('/settings/password') 14 | ->put('/settings/password', [ 15 | 'current_password' => 'password', 16 | 'password' => 'new-password', 17 | 'password_confirmation' => 'new-password', 18 | ]); 19 | 20 | $response 21 | ->assertSessionHasNoErrors() 22 | ->assertRedirect('/settings/password'); 23 | 24 | expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue(); 25 | }); 26 | 27 | test('correct password must be provided to update password', function () { 28 | $user = User::factory()->create(); 29 | 30 | $response = $this 31 | ->actingAs($user) 32 | ->from('/settings/password') 33 | ->put('/settings/password', [ 34 | 'current_password' => 'wrong-password', 35 | 'password' => 'new-password', 36 | 'password_confirmation' => 'new-password', 37 | ]); 38 | 39 | $response 40 | ->assertSessionHasErrors('current_password') 41 | ->assertRedirect('/settings/password'); 42 | }); 43 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | APP_LOCALE=en 8 | APP_FALLBACK_LOCALE=en 9 | APP_FAKER_LOCALE=en_US 10 | 11 | APP_MAINTENANCE_DRIVER=file 12 | # APP_MAINTENANCE_STORE=database 13 | 14 | PHP_CLI_SERVER_WORKERS=4 15 | 16 | BCRYPT_ROUNDS=12 17 | 18 | LOG_CHANNEL=stack 19 | LOG_STACK=single 20 | LOG_DEPRECATIONS_CHANNEL=null 21 | LOG_LEVEL=debug 22 | 23 | DB_CONNECTION=sqlite 24 | # DB_HOST=127.0.0.1 25 | # DB_PORT=3306 26 | # DB_DATABASE=laravel 27 | # DB_USERNAME=root 28 | # DB_PASSWORD= 29 | 30 | SESSION_DRIVER=database 31 | SESSION_LIFETIME=120 32 | SESSION_ENCRYPT=false 33 | SESSION_PATH=/ 34 | SESSION_DOMAIN=null 35 | 36 | BROADCAST_CONNECTION=log 37 | FILESYSTEM_DISK=local 38 | QUEUE_CONNECTION=database 39 | 40 | CACHE_STORE=database 41 | # CACHE_PREFIX= 42 | 43 | MEMCACHED_HOST=127.0.0.1 44 | 45 | REDIS_CLIENT=phpredis 46 | REDIS_HOST=127.0.0.1 47 | REDIS_PASSWORD=null 48 | REDIS_PORT=6379 49 | 50 | MAIL_MAILER=log 51 | MAIL_SCHEME=null 52 | MAIL_HOST=127.0.0.1 53 | MAIL_PORT=2525 54 | MAIL_USERNAME=null 55 | MAIL_PASSWORD=null 56 | MAIL_FROM_ADDRESS="hello@example.com" 57 | MAIL_FROM_NAME="${APP_NAME}" 58 | 59 | AWS_ACCESS_KEY_ID= 60 | AWS_SECRET_ACCESS_KEY= 61 | AWS_DEFAULT_REGION=us-east-1 62 | AWS_BUCKET= 63 | AWS_USE_PATH_STYLE_ENDPOINT=false 64 | 65 | VITE_APP_NAME="${APP_NAME}" 66 | 67 | OPENAI_API_KEY= 68 | OPENAI_ORGANIZATION= 69 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js'; 2 | import prettier from 'eslint-config-prettier'; 3 | import react from 'eslint-plugin-react'; 4 | import reactHooks from 'eslint-plugin-react-hooks'; 5 | import globals from 'globals'; 6 | import typescript from 'typescript-eslint'; 7 | 8 | /** @type {import('eslint').Linter.Config[]} */ 9 | export default [ 10 | js.configs.recommended, 11 | ...typescript.configs.recommended, 12 | { 13 | ...react.configs.flat.recommended, 14 | ...react.configs.flat['jsx-runtime'], // Required for React 17+ 15 | languageOptions: { 16 | globals: { 17 | ...globals.browser, 18 | }, 19 | }, 20 | rules: { 21 | 'react/react-in-jsx-scope': 'off', 22 | 'react/prop-types': 'off', 23 | 'react/no-unescaped-entities': 'off', 24 | }, 25 | settings: { 26 | react: { 27 | version: 'detect', 28 | }, 29 | }, 30 | }, 31 | { 32 | plugins: { 33 | 'react-hooks': reactHooks, 34 | }, 35 | rules: { 36 | 'react-hooks/rules-of-hooks': 'error', 37 | 'react-hooks/exhaustive-deps': 'warn', 38 | }, 39 | }, 40 | { 41 | ignores: ['vendor', 'node_modules', 'public', 'bootstrap/ssr', 'tailwind.config.js'], 42 | }, 43 | prettier, // Turn off all rules that might conflict with Prettier 44 | ]; 45 | -------------------------------------------------------------------------------- /resources/js/components/chat-title-updater.tsx: -------------------------------------------------------------------------------- 1 | import { useEventStream } from '@laravel/stream-react'; 2 | 3 | interface ChatTitleUpdaterProps { 4 | chatId: number; 5 | currentTitle: string; 6 | onTitleUpdate?: (title: string) => void; 7 | } 8 | 9 | export default function ChatTitleUpdater({ chatId, currentTitle, onTitleUpdate }: ChatTitleUpdaterProps) { 10 | const { message } = useEventStream(`/chat/${chatId}/title-stream`, { 11 | event: 'title-update', 12 | onMessage: (event) => { 13 | try { 14 | const parsed = JSON.parse(event.data); 15 | 16 | if (parsed.title) { 17 | // Update the page title 18 | document.title = `${parsed.title} - LaraChat`; 19 | 20 | // Update the conversation title via callback 21 | if (onTitleUpdate) { 22 | onTitleUpdate(parsed.title); 23 | } 24 | } 25 | } catch (error) { 26 | console.error('Error parsing title update:', error); 27 | } 28 | }, 29 | onError: (error) => { 30 | console.error('EventStream error:', error); 31 | }, 32 | onComplete: () => { 33 | // Title stream completed 34 | }, 35 | }); 36 | 37 | // Don't render anything - this is just a listener component 38 | return null; 39 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | Route::has('password.request'), 23 | 'status' => $request->session()->get('status'), 24 | ]); 25 | } 26 | 27 | /** 28 | * Handle an incoming authentication request. 29 | */ 30 | public function store(LoginRequest $request): RedirectResponse 31 | { 32 | $request->authenticate(); 33 | 34 | $request->session()->regenerate(); 35 | 36 | return redirect()->intended(route('home', absolute: false)); 37 | } 38 | 39 | /** 40 | * Destroy an authenticated session. 41 | */ 42 | public function destroy(Request $request): RedirectResponse 43 | { 44 | Auth::guard('web')->logout(); 45 | 46 | $request->session()->invalidate(); 47 | $request->session()->regenerateToken(); 48 | 49 | return redirect('/'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /resources/js/components/app-sidebar.tsx: -------------------------------------------------------------------------------- 1 | import { NavUser } from '@/components/nav-user'; 2 | import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar'; 3 | import { type User } from '@/types'; 4 | import { Link, usePage } from '@inertiajs/react'; 5 | import AppLogo from './app-logo'; 6 | import ChatList from './chat-list'; 7 | 8 | interface AppSidebarProps { 9 | currentChatId?: number; 10 | } 11 | 12 | export function AppSidebar({ currentChatId }: AppSidebarProps) { 13 | const { auth } = usePage<{ auth: { user?: User } }>().props; 14 | 15 | return ( 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | 32 |
33 |
34 | 35 | {auth.user && } 36 |
37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisteredUserController.php: -------------------------------------------------------------------------------- 1 | validate([ 34 | 'name' => 'required|string|max:255', 35 | 'email' => 'required|string|lowercase|email|max:255|unique:'.User::class, 36 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 37 | ]); 38 | 39 | $user = User::create([ 40 | 'name' => $request->name, 41 | 'email' => $request->email, 42 | 'password' => Hash::make($request->password), 43 | ]); 44 | 45 | event(new Registered($user)); 46 | 47 | Auth::login($user); 48 | 49 | return to_route('home'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /resources/js/components/nav-footer.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from '@/components/icon'; 2 | import { SidebarGroup, SidebarGroupContent, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar'; 3 | import { type NavItem } from '@/types'; 4 | import { type ComponentPropsWithoutRef } from 'react'; 5 | 6 | export function NavFooter({ 7 | items, 8 | className, 9 | ...props 10 | }: ComponentPropsWithoutRef & { 11 | items: NavItem[]; 12 | }) { 13 | return ( 14 | 15 | 16 | 17 | {items.map((item) => ( 18 | 19 | 23 | 24 | {item.icon && } 25 | {item.title} 26 | 27 | 28 | 29 | ))} 30 | 31 | 32 | 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /tests/Feature/Auth/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | unverified()->create(); 12 | 13 | $response = $this->actingAs($user)->get('/verify-email'); 14 | 15 | $response->assertStatus(200); 16 | }); 17 | 18 | test('email can be verified', function () { 19 | $user = User::factory()->unverified()->create(); 20 | 21 | Event::fake(); 22 | 23 | $verificationUrl = URL::temporarySignedRoute( 24 | 'verification.verify', 25 | now()->addMinutes(60), 26 | ['id' => $user->id, 'hash' => sha1($user->email)] 27 | ); 28 | 29 | $response = $this->actingAs($user)->get($verificationUrl); 30 | 31 | Event::assertDispatched(Verified::class); 32 | expect($user->fresh()->hasVerifiedEmail())->toBeTrue(); 33 | $response->assertRedirect(route('home', absolute: false).'?verified=1'); 34 | }); 35 | 36 | test('email is not verified with invalid hash', function () { 37 | $user = User::factory()->unverified()->create(); 38 | 39 | $verificationUrl = URL::temporarySignedRoute( 40 | 'verification.verify', 41 | now()->addMinutes(60), 42 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 43 | ); 44 | 45 | $this->actingAs($user)->get($verificationUrl); 46 | 47 | expect($user->fresh()->hasVerifiedEmail())->toBeFalse(); 48 | }); 49 | -------------------------------------------------------------------------------- /config/inertia.php: -------------------------------------------------------------------------------- 1 | [ 19 | 'enabled' => true, 20 | 'url' => 'http://127.0.0.1:13714', 21 | // 'bundle' => base_path('bootstrap/ssr/ssr.mjs'), 22 | 23 | ], 24 | 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | Testing 28 | |-------------------------------------------------------------------------- 29 | | 30 | | The values described here are used to locate Inertia components on the 31 | | filesystem. For instance, when using `assertInertia`, the assertion 32 | | attempts to locate the component as a file relative to the paths. 33 | | 34 | */ 35 | 36 | 'testing' => [ 37 | 38 | 'ensure_pages_exist' => true, 39 | 40 | 'page_paths' => [ 41 | resource_path('js/pages'), 42 | ], 43 | 44 | 'page_extensions' => [ 45 | 'js', 46 | 'jsx', 47 | 'svelte', 48 | 'ts', 49 | 'tsx', 50 | 'vue', 51 | ], 52 | 53 | ], 54 | 55 | ]; 56 | -------------------------------------------------------------------------------- /resources/js/layouts/auth/auth-card-layout.tsx: -------------------------------------------------------------------------------- 1 | import AppLogoIcon from '@/components/app-logo-icon'; 2 | import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; 3 | import { Link } from '@inertiajs/react'; 4 | import { type PropsWithChildren } from 'react'; 5 | 6 | export default function AuthCardLayout({ 7 | children, 8 | title, 9 | description, 10 | }: PropsWithChildren<{ 11 | name?: string; 12 | title?: string; 13 | description?: string; 14 | }>) { 15 | return ( 16 |
17 |
18 | 19 |
20 | 21 |
22 | 23 | 24 |
25 | 26 | 27 | {title} 28 | {description} 29 | 30 | {children} 31 | 32 |
33 |
34 |
35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /resources/js/layouts/auth/auth-simple-layout.tsx: -------------------------------------------------------------------------------- 1 | import AppLogoIcon from '@/components/app-logo-icon'; 2 | import { Link } from '@inertiajs/react'; 3 | import { type PropsWithChildren } from 'react'; 4 | 5 | interface AuthLayoutProps { 6 | name?: string; 7 | title?: string; 8 | description?: string; 9 | } 10 | 11 | export default function AuthSimpleLayout({ children, title, description }: PropsWithChildren) { 12 | return ( 13 |
14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 | {title} 22 | 23 | 24 |
25 |

{title}

26 |

{description}

27 |
28 |
29 | {children} 30 |
31 |
32 |
33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /app/Policies/ChatPolicy.php: -------------------------------------------------------------------------------- 1 | id === $chat->user_id; 24 | } 25 | 26 | /** 27 | * Determine whether the user can create models. 28 | */ 29 | public function create(User $user): bool 30 | { 31 | return true; // Authenticated users can create chats 32 | } 33 | 34 | /** 35 | * Determine whether the user can update the model. 36 | */ 37 | public function update(User $user, Chat $chat): bool 38 | { 39 | return $user->id === $chat->user_id; // Users can update their own chats 40 | } 41 | 42 | /** 43 | * Determine whether the user can delete the model. 44 | */ 45 | public function delete(User $user, Chat $chat): bool 46 | { 47 | return $user->id === $chat->user_id; // Users can delete their own chats 48 | } 49 | 50 | /** 51 | * Determine whether the user can restore the model. 52 | */ 53 | public function restore(User $user, Chat $chat): bool 54 | { 55 | return false; 56 | } 57 | 58 | /** 59 | * Determine whether the user can permanently delete the model. 60 | */ 61 | public function forceDelete(User $user, Chat $chat): bool 62 | { 63 | return false; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /database/migrations/0001_01_01_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | 24 | Schema::create('password_reset_tokens', function (Blueprint $table) { 25 | $table->string('email')->primary(); 26 | $table->string('token'); 27 | $table->timestamp('created_at')->nullable(); 28 | }); 29 | 30 | Schema::create('sessions', function (Blueprint $table) { 31 | $table->string('id')->primary(); 32 | $table->foreignId('user_id')->nullable()->index(); 33 | $table->string('ip_address', 45)->nullable(); 34 | $table->text('user_agent')->nullable(); 35 | $table->longText('payload'); 36 | $table->integer('last_activity')->index(); 37 | }); 38 | } 39 | 40 | /** 41 | * Reverse the migrations. 42 | */ 43 | public function down(): void 44 | { 45 | Schema::dropIfExists('users'); 46 | Schema::dropIfExists('password_reset_tokens'); 47 | Schema::dropIfExists('sessions'); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /resources/js/components/breadcrumbs.tsx: -------------------------------------------------------------------------------- 1 | import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from '@/components/ui/breadcrumb'; 2 | import { type BreadcrumbItem as BreadcrumbItemType } from '@/types'; 3 | import { Link } from '@inertiajs/react'; 4 | import { Fragment } from 'react'; 5 | 6 | export function Breadcrumbs({ breadcrumbs }: { breadcrumbs: BreadcrumbItemType[] }) { 7 | return ( 8 | <> 9 | {breadcrumbs.length > 0 && ( 10 | 11 | 12 | {breadcrumbs.map((item, index) => { 13 | const isLast = index === breadcrumbs.length - 1; 14 | return ( 15 | 16 | 17 | {isLast ? ( 18 | {item.title} 19 | ) : ( 20 | 21 | {item.title} 22 | 23 | )} 24 | 25 | {!isLast && } 26 | 27 | ); 28 | })} 29 | 30 | 31 | )} 32 | 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /resources/js/pages/auth/verify-email.tsx: -------------------------------------------------------------------------------- 1 | // Components 2 | import { Head, useForm } from '@inertiajs/react'; 3 | import { LoaderCircle } from 'lucide-react'; 4 | import { FormEventHandler } from 'react'; 5 | 6 | import TextLink from '@/components/text-link'; 7 | import { Button } from '@/components/ui/button'; 8 | import AuthLayout from '@/layouts/auth-layout'; 9 | 10 | export default function VerifyEmail({ status }: { status?: string }) { 11 | const { post, processing } = useForm({}); 12 | 13 | const submit: FormEventHandler = (e) => { 14 | e.preventDefault(); 15 | 16 | post(route('verification.send')); 17 | }; 18 | 19 | return ( 20 | 21 | 22 | 23 | {status === 'verification-link-sent' && ( 24 |
25 | A new verification link has been sent to the email address you provided during registration. 26 |
27 | )} 28 | 29 |
30 | 34 | 35 | 36 | Log out 37 | 38 |
39 |
40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /resources/js/components/appearance-tabs.tsx: -------------------------------------------------------------------------------- 1 | import { Appearance, useAppearance } from '@/hooks/use-appearance'; 2 | import { cn } from '@/lib/utils'; 3 | import { LucideIcon, Monitor, Moon, Sun } from 'lucide-react'; 4 | import { HTMLAttributes } from 'react'; 5 | 6 | export default function AppearanceToggleTab({ className = '', ...props }: HTMLAttributes) { 7 | const { appearance, updateAppearance } = useAppearance(); 8 | 9 | const tabs: { value: Appearance; icon: LucideIcon; label: string }[] = [ 10 | { value: 'light', icon: Sun, label: 'Light' }, 11 | { value: 'dark', icon: Moon, label: 'Dark' }, 12 | { value: 'system', icon: Monitor, label: 'System' }, 13 | ]; 14 | 15 | return ( 16 |
17 | {tabs.map(({ value, icon: Icon, label }) => ( 18 | 31 | ))} 32 |
33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /resources/js/components/ui/toggle.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as TogglePrimitive from "@radix-ui/react-toggle" 3 | import { cva, type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "@/lib/utils" 6 | 7 | const toggleVariants = cva( 8 | "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", 9 | { 10 | variants: { 11 | variant: { 12 | default: "bg-transparent", 13 | outline: 14 | "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground", 15 | }, 16 | size: { 17 | default: "h-9 px-2 min-w-9", 18 | sm: "h-8 px-1.5 min-w-8", 19 | lg: "h-10 px-2.5 min-w-10", 20 | }, 21 | }, 22 | defaultVariants: { 23 | variant: "default", 24 | size: "default", 25 | }, 26 | } 27 | ) 28 | 29 | function Toggle({ 30 | className, 31 | variant, 32 | size, 33 | ...props 34 | }: React.ComponentProps & 35 | VariantProps) { 36 | return ( 37 | 42 | ) 43 | } 44 | 45 | export { Toggle, toggleVariants } 46 | -------------------------------------------------------------------------------- /tests/Pest.php: -------------------------------------------------------------------------------- 1 | extend(Tests\TestCase::class) 15 | // ->use(Illuminate\Foundation\Testing\RefreshDatabase::class) 16 | ->in('Feature'); 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Expectations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | When you're writing tests, you often need to check that values meet certain conditions. The 24 | | "expect()" function gives you access to a set of "expectations" methods that you can use 25 | | to assert different things. Of course, you may extend the Expectation API at any time. 26 | | 27 | */ 28 | 29 | expect()->extend('toBeOne', function () { 30 | return $this->toBe(1); 31 | }); 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Functions 36 | |-------------------------------------------------------------------------- 37 | | 38 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your 39 | | project that you don't want to repeat in every file. Here you can also expose helpers as 40 | | global functions to help you to reduce the number of lines of code in your test files. 41 | | 42 | */ 43 | 44 | function something() 45 | { 46 | // .. 47 | } 48 | -------------------------------------------------------------------------------- /resources/js/components/nav-user.tsx: -------------------------------------------------------------------------------- 1 | import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; 2 | import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from '@/components/ui/sidebar'; 3 | import { UserInfo } from '@/components/user-info'; 4 | import { UserMenuContent } from '@/components/user-menu-content'; 5 | import { useIsMobile } from '@/hooks/use-mobile'; 6 | import { type SharedData } from '@/types'; 7 | import { usePage } from '@inertiajs/react'; 8 | import { ChevronsUpDown } from 'lucide-react'; 9 | 10 | export function NavUser() { 11 | const { auth } = usePage().props; 12 | const { state } = useSidebar(); 13 | const isMobile = useIsMobile(); 14 | 15 | return ( 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /resources/js/components/ui/badge.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Slot } from "@radix-ui/react-slot" 3 | import { cva, type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "@/lib/utils" 6 | 7 | const badgeVariants = cva( 8 | "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto", 9 | { 10 | variants: { 11 | variant: { 12 | default: 13 | "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90", 14 | secondary: 15 | "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", 16 | destructive: 17 | "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40", 18 | outline: 19 | "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", 20 | }, 21 | }, 22 | defaultVariants: { 23 | variant: "default", 24 | }, 25 | } 26 | ) 27 | 28 | function Badge({ 29 | className, 30 | variant, 31 | asChild = false, 32 | ...props 33 | }: React.ComponentProps<"span"> & 34 | VariantProps & { asChild?: boolean }) { 35 | const Comp = asChild ? Slot : "span" 36 | 37 | return ( 38 | 43 | ) 44 | } 45 | 46 | export { Badge, badgeVariants } 47 | -------------------------------------------------------------------------------- /resources/js/components/ui/card.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | function Card({ className, ...props }: React.ComponentProps<"div">) { 6 | return ( 7 |
15 | ) 16 | } 17 | 18 | function CardHeader({ className, ...props }: React.ComponentProps<"div">) { 19 | return ( 20 |
25 | ) 26 | } 27 | 28 | function CardTitle({ className, ...props }: React.ComponentProps<"div">) { 29 | return ( 30 |
35 | ) 36 | } 37 | 38 | function CardDescription({ className, ...props }: React.ComponentProps<"div">) { 39 | return ( 40 |
45 | ) 46 | } 47 | 48 | function CardContent({ className, ...props }: React.ComponentProps<"div">) { 49 | return ( 50 |
55 | ) 56 | } 57 | 58 | function CardFooter({ className, ...props }: React.ComponentProps<"div">) { 59 | return ( 60 |
65 | ) 66 | } 67 | 68 | export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } 69 | -------------------------------------------------------------------------------- /app/Http/Controllers/Settings/ProfileController.php: -------------------------------------------------------------------------------- 1 | $request->user() instanceof MustVerifyEmail, 23 | 'status' => $request->session()->get('status'), 24 | ]); 25 | } 26 | 27 | /** 28 | * Update the user's profile settings. 29 | */ 30 | public function update(ProfileUpdateRequest $request): RedirectResponse 31 | { 32 | $request->user()->fill($request->validated()); 33 | 34 | if ($request->user()->isDirty('email')) { 35 | $request->user()->email_verified_at = null; 36 | } 37 | 38 | $request->user()->save(); 39 | 40 | return to_route('profile.edit'); 41 | } 42 | 43 | /** 44 | * Delete the user's account. 45 | */ 46 | public function destroy(Request $request): RedirectResponse 47 | { 48 | $request->validate([ 49 | 'password' => ['required', 'current_password'], 50 | ]); 51 | 52 | $user = $request->user(); 53 | 54 | Auth::logout(); 55 | 56 | $user->delete(); 57 | 58 | $request->session()->invalidate(); 59 | $request->session()->regenerateToken(); 60 | 61 | return redirect('/'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /resources/js/components/ui/scroll-area.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | const ScrollArea = React.forwardRef< 7 | React.ElementRef, 8 | React.ComponentPropsWithoutRef 9 | >(({ className, children, ...props }, ref) => ( 10 | 15 | 16 | {children} 17 | 18 | 19 | 20 | 21 | )) 22 | ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName 23 | 24 | const ScrollBar = React.forwardRef< 25 | React.ElementRef, 26 | React.ComponentPropsWithoutRef 27 | >(({ className, orientation = "vertical", ...props }, ref) => ( 28 | 41 | 42 | 43 | )) 44 | ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName 45 | 46 | export { ScrollArea, ScrollBar } -------------------------------------------------------------------------------- /resources/js/components/user-menu-content.tsx: -------------------------------------------------------------------------------- 1 | import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from '@/components/ui/dropdown-menu'; 2 | import { UserInfo } from '@/components/user-info'; 3 | import { useMobileNavigation } from '@/hooks/use-mobile-navigation'; 4 | import { type User } from '@/types'; 5 | import { Link, router } from '@inertiajs/react'; 6 | import { LogOut, Settings } from 'lucide-react'; 7 | 8 | interface UserMenuContentProps { 9 | user: User; 10 | } 11 | 12 | export function UserMenuContent({ user }: UserMenuContentProps) { 13 | const cleanup = useMobileNavigation(); 14 | 15 | const handleLogout = () => { 16 | cleanup(); 17 | router.flushAll(); 18 | }; 19 | 20 | return ( 21 | <> 22 | 23 |
24 | 25 |
26 |
27 | 28 | 29 | 30 | 31 | 32 | Settings 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Log out 41 | 42 | 43 | 44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | 37 | */ 38 | public function share(Request $request): array 39 | { 40 | [$message, $author] = str(Inspiring::quotes()->random())->explode('-'); 41 | 42 | return [ 43 | ...parent::share($request), 44 | 'name' => config('app.name'), 45 | 'quote' => ['message' => trim($message), 'author' => trim($author)], 46 | 'auth' => [ 47 | 'user' => $request->user(), 48 | ], 49 | 'ziggy' => fn (): array => [ 50 | ...(new Ziggy)->toArray(), 51 | 'location' => $request->url(), 52 | ], 53 | 'sidebarOpen' => $request->user() 54 | ? (! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true') 55 | : ($request->hasCookie('sidebar_state') && $request->cookie('sidebar_state') === 'true'), 56 | ]; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /resources/js/components/ui/alert.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { cva, type VariantProps } from "class-variance-authority" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | const alertVariants = cva( 7 | "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", 8 | { 9 | variants: { 10 | variant: { 11 | default: "bg-background text-foreground", 12 | destructive: 13 | "text-destructive-foreground [&>svg]:text-current *:data-[slot=alert-description]:text-destructive-foreground/80", 14 | }, 15 | }, 16 | defaultVariants: { 17 | variant: "default", 18 | }, 19 | } 20 | ) 21 | 22 | function Alert({ 23 | className, 24 | variant, 25 | ...props 26 | }: React.ComponentProps<"div"> & VariantProps) { 27 | return ( 28 |
34 | ) 35 | } 36 | 37 | function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { 38 | return ( 39 |
47 | ) 48 | } 49 | 50 | function AlertDescription({ 51 | className, 52 | ...props 53 | }: React.ComponentProps<"div">) { 54 | return ( 55 |
63 | ) 64 | } 65 | 66 | export { Alert, AlertTitle, AlertDescription } 67 | -------------------------------------------------------------------------------- /tests/Feature/ChatAuthenticationFlowTest.php: -------------------------------------------------------------------------------- 1 | post('/chat'); 16 | 17 | $response->assertRedirect('/login'); 18 | } 19 | 20 | public function test_anonymous_user_redirected_to_login_when_viewing_specific_chat(): void 21 | { 22 | $response = $this->get('/chat/1'); 23 | 24 | $response->assertRedirect('/login'); 25 | } 26 | 27 | public function test_authenticated_user_can_access_chat_routes(): void 28 | { 29 | $user = User::factory()->create(); 30 | 31 | // Authenticated users get redirected to a new chat from home 32 | $response = $this->actingAs($user)->get('/'); 33 | $response->assertRedirect(); 34 | 35 | $response = $this->actingAs($user)->post('/chat'); 36 | $response->assertRedirect(); // Redirects to new chat 37 | } 38 | 39 | public function test_anonymous_user_can_access_main_chat_page(): void 40 | { 41 | $response = $this->get('/'); 42 | 43 | $response->assertStatus(200); 44 | $response->assertInertia(fn ($page) => $page 45 | ->component('chat') 46 | ->where('chat', null) 47 | ); 48 | } 49 | 50 | public function test_anonymous_user_can_stream_without_authentication(): void 51 | { 52 | $response = $this->post('/chat/stream', [ 53 | 'messages' => [ 54 | ['type' => 'prompt', 'content' => 'Hello'], 55 | ], 56 | ]); 57 | 58 | $response->assertStatus(200); 59 | $response->assertHeader('Content-Type', 'text/event-stream; charset=UTF-8'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | get('/forgot-password'); 11 | 12 | $response->assertStatus(200); 13 | }); 14 | 15 | test('reset password link can be requested', function () { 16 | Notification::fake(); 17 | 18 | $user = User::factory()->create(); 19 | 20 | $this->post('/forgot-password', ['email' => $user->email]); 21 | 22 | Notification::assertSentTo($user, ResetPassword::class); 23 | }); 24 | 25 | test('reset password screen can be rendered', function () { 26 | Notification::fake(); 27 | 28 | $user = User::factory()->create(); 29 | 30 | $this->post('/forgot-password', ['email' => $user->email]); 31 | 32 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) { 33 | $response = $this->get('/reset-password/'.$notification->token); 34 | 35 | $response->assertStatus(200); 36 | 37 | return true; 38 | }); 39 | }); 40 | 41 | test('password can be reset with valid token', function () { 42 | Notification::fake(); 43 | 44 | $user = User::factory()->create(); 45 | 46 | $this->post('/forgot-password', ['email' => $user->email]); 47 | 48 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { 49 | $response = $this->post('/reset-password', [ 50 | 'token' => $notification->token, 51 | 'email' => $user->email, 52 | 'password' => 'password', 53 | 'password_confirmation' => 'password', 54 | ]); 55 | 56 | $response 57 | ->assertSessionHasNoErrors() 58 | ->assertRedirect(route('login')); 59 | 60 | return true; 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /config/openai.php: -------------------------------------------------------------------------------- 1 | env('OPENAI_API_KEY'), 16 | 'organization' => env('OPENAI_ORGANIZATION'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | OpenAI API Project 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may specify your OpenAI API project. This is used optionally in 24 | | situations where you are using a legacy user API key and need association 25 | | with a project. This is not required for the newer API keys. 26 | */ 27 | 'project' => env('OPENAI_PROJECT'), 28 | 29 | /* 30 | |-------------------------------------------------------------------------- 31 | | OpenAI Base URL 32 | |-------------------------------------------------------------------------- 33 | | 34 | | Here you may specify your OpenAI API base URL used to make requests. This 35 | | is needed if using a custom API endpoint. Defaults to: api.openai.com/v1 36 | */ 37 | 'base_uri' => env('OPENAI_BASE_URL'), 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Request Timeout 42 | |-------------------------------------------------------------------------- 43 | | 44 | | The timeout may be used to specify the maximum number of seconds to wait 45 | | for a response. By default, the client will time out after 30 seconds. 46 | */ 47 | 48 | 'request_timeout' => env('OPENAI_REQUEST_TIMEOUT', 30), 49 | ]; 50 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | ($appearance ?? 'system') == 'dark'])> 3 | 4 | 5 | 6 | 7 | 8 | {{-- Inline script to detect system dark mode preference and apply it immediately --}} 9 | 22 | 23 | {{-- Inline style to set the HTML background color based on our theme in app.css --}} 24 | 33 | 34 | {{ config('app.name', 'Laravel') }} 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | @routes 44 | @viteReactRefresh 45 | @vite(['resources/js/app.tsx', "resources/js/pages/{$page['component']}.tsx"]) 46 | @inertiaHead 47 | 48 | 49 | @inertia 50 | 51 | 52 | -------------------------------------------------------------------------------- /resources/js/pages/dashboard.tsx: -------------------------------------------------------------------------------- 1 | import { PlaceholderPattern } from '@/components/ui/placeholder-pattern'; 2 | import AppLayout from '@/layouts/app-layout'; 3 | import { type BreadcrumbItem } from '@/types'; 4 | import { Head } from '@inertiajs/react'; 5 | 6 | const breadcrumbs: BreadcrumbItem[] = [ 7 | { 8 | title: 'Dashboard', 9 | href: '/dashboard', 10 | }, 11 | ]; 12 | 13 | export default function Dashboard() { 14 | return ( 15 | 16 | 17 |
18 |
19 |
20 | 21 |
22 |
23 | 24 |
25 |
26 | 27 |
28 |
29 |
30 | 31 |
32 |
33 |
34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /resources/js/components/ui/tooltip.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as TooltipPrimitive from "@radix-ui/react-tooltip" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | function TooltipProvider({ 7 | delayDuration = 0, 8 | ...props 9 | }: React.ComponentProps) { 10 | return ( 11 | 16 | ) 17 | } 18 | 19 | function Tooltip({ 20 | ...props 21 | }: React.ComponentProps) { 22 | return ( 23 | 24 | 25 | 26 | ) 27 | } 28 | 29 | function TooltipTrigger({ 30 | ...props 31 | }: React.ComponentProps) { 32 | return 33 | } 34 | 35 | function TooltipContent({ 36 | className, 37 | sideOffset = 4, 38 | children, 39 | ...props 40 | }: React.ComponentProps) { 41 | return ( 42 | 43 | 52 | {children} 53 | 54 | 55 | 56 | ) 57 | } 58 | 59 | export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } 60 | -------------------------------------------------------------------------------- /database/migrations/0001_01_01_000002_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('queue')->index(); 17 | $table->longText('payload'); 18 | $table->unsignedTinyInteger('attempts'); 19 | $table->unsignedInteger('reserved_at')->nullable(); 20 | $table->unsignedInteger('available_at'); 21 | $table->unsignedInteger('created_at'); 22 | }); 23 | 24 | Schema::create('job_batches', function (Blueprint $table) { 25 | $table->string('id')->primary(); 26 | $table->string('name'); 27 | $table->integer('total_jobs'); 28 | $table->integer('pending_jobs'); 29 | $table->integer('failed_jobs'); 30 | $table->longText('failed_job_ids'); 31 | $table->mediumText('options')->nullable(); 32 | $table->integer('cancelled_at')->nullable(); 33 | $table->integer('created_at'); 34 | $table->integer('finished_at')->nullable(); 35 | }); 36 | 37 | Schema::create('failed_jobs', function (Blueprint $table) { 38 | $table->id(); 39 | $table->string('uuid')->unique(); 40 | $table->text('connection'); 41 | $table->text('queue'); 42 | $table->longText('payload'); 43 | $table->longText('exception'); 44 | $table->timestamp('failed_at')->useCurrent(); 45 | }); 46 | } 47 | 48 | /** 49 | * Reverse the migrations. 50 | */ 51 | public function down(): void 52 | { 53 | Schema::dropIfExists('jobs'); 54 | Schema::dropIfExists('job_batches'); 55 | Schema::dropIfExists('failed_jobs'); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /resources/js/components/app-sidebar-header.tsx: -------------------------------------------------------------------------------- 1 | import { Breadcrumbs } from '@/components/breadcrumbs'; 2 | import { Button } from '@/components/ui/button'; 3 | import { SidebarTrigger } from '@/components/ui/sidebar'; 4 | import { type BreadcrumbItem as BreadcrumbItemType, type User } from '@/types'; 5 | import { Link, router, useForm, usePage } from '@inertiajs/react'; 6 | import { Plus } from 'lucide-react'; 7 | 8 | interface AppSidebarHeaderProps { 9 | breadcrumbs?: BreadcrumbItemType[]; 10 | } 11 | 12 | export function AppSidebarHeader({ breadcrumbs = [] }: AppSidebarHeaderProps) { 13 | const { auth } = usePage<{ auth: { user?: User } }>().props; 14 | const { post, processing } = useForm(); 15 | 16 | const handleNewChat = () => { 17 | if (!auth.user) { 18 | router.visit('/login'); 19 | } else { 20 | post('/chat'); 21 | } 22 | }; 23 | 24 | return ( 25 |
26 |
27 | 28 | 29 |
30 |
31 | {!auth.user ? ( 32 | <> 33 | 36 | 39 | 40 | ) : ( 41 | 44 | )} 45 |
46 |
47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /resources/js/components/ui/toggle-group.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group" 3 | import { type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "@/lib/utils" 6 | import { toggleVariants } from "@/components/ui/toggle" 7 | 8 | const ToggleGroupContext = React.createContext< 9 | VariantProps 10 | >({ 11 | size: "default", 12 | variant: "default", 13 | }) 14 | 15 | function ToggleGroup({ 16 | className, 17 | variant, 18 | size, 19 | children, 20 | ...props 21 | }: React.ComponentProps & 22 | VariantProps) { 23 | return ( 24 | 34 | 35 | {children} 36 | 37 | 38 | ) 39 | } 40 | 41 | function ToggleGroupItem({ 42 | className, 43 | children, 44 | variant, 45 | size, 46 | ...props 47 | }: React.ComponentProps & 48 | VariantProps) { 49 | const context = React.useContext(ToggleGroupContext) 50 | 51 | return ( 52 | 66 | {children} 67 | 68 | ) 69 | } 70 | 71 | export { ToggleGroup, ToggleGroupItem } 72 | -------------------------------------------------------------------------------- /resources/js/components/ui/button.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Slot } from "@radix-ui/react-slot" 3 | import { cva, type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "@/lib/utils" 6 | 7 | const buttonVariants = cva( 8 | "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", 9 | { 10 | variants: { 11 | variant: { 12 | default: 13 | "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90", 14 | destructive: 15 | "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40", 16 | outline: 17 | "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground", 18 | secondary: 19 | "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80", 20 | ghost: "hover:bg-accent hover:text-accent-foreground", 21 | link: "text-primary underline-offset-4 hover:underline", 22 | }, 23 | size: { 24 | default: "h-9 px-4 py-2 has-[>svg]:px-3", 25 | sm: "h-8 rounded-md px-3 has-[>svg]:px-2.5", 26 | lg: "h-10 rounded-md px-6 has-[>svg]:px-4", 27 | icon: "size-9", 28 | }, 29 | }, 30 | defaultVariants: { 31 | variant: "default", 32 | size: "default", 33 | }, 34 | } 35 | ) 36 | 37 | function Button({ 38 | className, 39 | variant, 40 | size, 41 | asChild = false, 42 | ...props 43 | }: React.ComponentProps<"button"> & 44 | VariantProps & { 45 | asChild?: boolean 46 | }) { 47 | const Comp = asChild ? Slot : "button" 48 | 49 | return ( 50 | 55 | ) 56 | } 57 | 58 | export { Button, buttonVariants } 59 | -------------------------------------------------------------------------------- /resources/js/layouts/auth/auth-split-layout.tsx: -------------------------------------------------------------------------------- 1 | import AppLogoIcon from '@/components/app-logo-icon'; 2 | import { type SharedData } from '@/types'; 3 | import { Link, usePage } from '@inertiajs/react'; 4 | import { type PropsWithChildren } from 'react'; 5 | 6 | interface AuthLayoutProps { 7 | title?: string; 8 | description?: string; 9 | } 10 | 11 | export default function AuthSplitLayout({ children, title, description }: PropsWithChildren) { 12 | const { name, quote } = usePage().props; 13 | 14 | return ( 15 |
16 |
17 |
18 | 19 | 20 | {name} 21 | 22 | {quote && ( 23 |
24 |
25 |

“{quote.message}”

26 |
{quote.author}
27 |
28 |
29 | )} 30 |
31 |
32 |
33 | 34 | 35 | 36 |
37 |

{title}

38 |

{description}

39 |
40 | {children} 41 |
42 |
43 |
44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /routes/auth.php: -------------------------------------------------------------------------------- 1 | group(function () { 14 | Route::get('register', [RegisteredUserController::class, 'create']) 15 | ->name('register'); 16 | 17 | Route::post('register', [RegisteredUserController::class, 'store']); 18 | 19 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 20 | ->name('login'); 21 | 22 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 23 | 24 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) 25 | ->name('password.request'); 26 | 27 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) 28 | ->name('password.email'); 29 | 30 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) 31 | ->name('password.reset'); 32 | 33 | Route::post('reset-password', [NewPasswordController::class, 'store']) 34 | ->name('password.store'); 35 | }); 36 | 37 | Route::middleware('auth')->group(function () { 38 | Route::get('verify-email', EmailVerificationPromptController::class) 39 | ->name('verification.notice'); 40 | 41 | Route::get('verify-email/{id}/{hash}', VerifyEmailController::class) 42 | ->middleware(['signed', 'throttle:6,1']) 43 | ->name('verification.verify'); 44 | 45 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) 46 | ->middleware('throttle:6,1') 47 | ->name('verification.send'); 48 | 49 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) 50 | ->name('password.confirm'); 51 | 52 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); 53 | 54 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 55 | ->name('logout'); 56 | }); 57 | -------------------------------------------------------------------------------- /resources/js/pages/auth/confirm-password.tsx: -------------------------------------------------------------------------------- 1 | // Components 2 | import { Head, useForm } from '@inertiajs/react'; 3 | import { LoaderCircle } from 'lucide-react'; 4 | import { FormEventHandler } from 'react'; 5 | 6 | import InputError from '@/components/input-error'; 7 | import { Button } from '@/components/ui/button'; 8 | import { Input } from '@/components/ui/input'; 9 | import { Label } from '@/components/ui/label'; 10 | import AuthLayout from '@/layouts/auth-layout'; 11 | 12 | export default function ConfirmPassword() { 13 | const { data, setData, post, processing, errors, reset } = useForm>({ 14 | password: '', 15 | }); 16 | 17 | const submit: FormEventHandler = (e) => { 18 | e.preventDefault(); 19 | 20 | post(route('password.confirm'), { 21 | onFinish: () => reset('password'), 22 | }); 23 | }; 24 | 25 | return ( 26 | 30 | 31 | 32 |
33 |
34 |
35 | 36 | setData('password', e.target.value)} 45 | /> 46 | 47 | 48 |
49 | 50 |
51 | 55 |
56 |
57 |
58 |
59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /resources/js/hooks/use-appearance.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useEffect, useState } from 'react'; 2 | 3 | export type Appearance = 'light' | 'dark' | 'system'; 4 | 5 | const prefersDark = () => { 6 | if (typeof window === 'undefined') { 7 | return false; 8 | } 9 | 10 | return window.matchMedia('(prefers-color-scheme: dark)').matches; 11 | }; 12 | 13 | const setCookie = (name: string, value: string, days = 365) => { 14 | if (typeof document === 'undefined') { 15 | return; 16 | } 17 | 18 | const maxAge = days * 24 * 60 * 60; 19 | document.cookie = `${name}=${value};path=/;max-age=${maxAge};SameSite=Lax`; 20 | }; 21 | 22 | const applyTheme = (appearance: Appearance) => { 23 | const isDark = appearance === 'dark' || (appearance === 'system' && prefersDark()); 24 | 25 | document.documentElement.classList.toggle('dark', isDark); 26 | }; 27 | 28 | const mediaQuery = () => { 29 | if (typeof window === 'undefined') { 30 | return null; 31 | } 32 | 33 | return window.matchMedia('(prefers-color-scheme: dark)'); 34 | }; 35 | 36 | const handleSystemThemeChange = () => { 37 | const currentAppearance = localStorage.getItem('appearance') as Appearance; 38 | applyTheme(currentAppearance || 'system'); 39 | }; 40 | 41 | export function initializeTheme() { 42 | const savedAppearance = (localStorage.getItem('appearance') as Appearance) || 'system'; 43 | 44 | applyTheme(savedAppearance); 45 | 46 | // Add the event listener for system theme changes... 47 | mediaQuery()?.addEventListener('change', handleSystemThemeChange); 48 | } 49 | 50 | export function useAppearance() { 51 | const [appearance, setAppearance] = useState('system'); 52 | 53 | const updateAppearance = useCallback((mode: Appearance) => { 54 | setAppearance(mode); 55 | 56 | // Store in localStorage for client-side persistence... 57 | localStorage.setItem('appearance', mode); 58 | 59 | // Store in cookie for SSR... 60 | setCookie('appearance', mode); 61 | 62 | applyTheme(mode); 63 | }, []); 64 | 65 | useEffect(() => { 66 | const savedAppearance = localStorage.getItem('appearance') as Appearance | null; 67 | updateAppearance(savedAppearance || 'system'); 68 | 69 | return () => mediaQuery()?.removeEventListener('change', handleSystemThemeChange); 70 | }, [updateAppearance]); 71 | 72 | return { appearance, updateAppearance } as const; 73 | } 74 | -------------------------------------------------------------------------------- /resources/js/components/appearance-dropdown.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from '@/components/ui/button'; 2 | import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; 3 | import { useAppearance } from '@/hooks/use-appearance'; 4 | import { Monitor, Moon, Sun } from 'lucide-react'; 5 | import { HTMLAttributes } from 'react'; 6 | 7 | export default function AppearanceToggleDropdown({ className = '', ...props }: HTMLAttributes) { 8 | const { appearance, updateAppearance } = useAppearance(); 9 | 10 | const getCurrentIcon = () => { 11 | switch (appearance) { 12 | case 'dark': 13 | return ; 14 | case 'light': 15 | return ; 16 | default: 17 | return ; 18 | } 19 | }; 20 | 21 | return ( 22 |
23 | 24 | 25 | 29 | 30 | 31 | updateAppearance('light')}> 32 | 33 | 34 | Light 35 | 36 | 37 | updateAppearance('dark')}> 38 | 39 | 40 | Dark 41 | 42 | 43 | updateAppearance('system')}> 44 | 45 | 46 | System 47 | 48 | 49 | 50 | 51 |
52 | ); 53 | } 54 | -------------------------------------------------------------------------------- /tests/Feature/Settings/ProfileUpdateTest.php: -------------------------------------------------------------------------------- 1 | create(); 9 | 10 | $response = $this 11 | ->actingAs($user) 12 | ->get('/settings/profile'); 13 | 14 | $response->assertOk(); 15 | }); 16 | 17 | test('profile information can be updated', function () { 18 | $user = User::factory()->create(); 19 | 20 | $response = $this 21 | ->actingAs($user) 22 | ->patch('/settings/profile', [ 23 | 'name' => 'Test User', 24 | 'email' => 'test@example.com', 25 | ]); 26 | 27 | $response 28 | ->assertSessionHasNoErrors() 29 | ->assertRedirect('/settings/profile'); 30 | 31 | $user->refresh(); 32 | 33 | expect($user->name)->toBe('Test User'); 34 | expect($user->email)->toBe('test@example.com'); 35 | expect($user->email_verified_at)->toBeNull(); 36 | }); 37 | 38 | test('email verification status is unchanged when the email address is unchanged', function () { 39 | $user = User::factory()->create(); 40 | 41 | $response = $this 42 | ->actingAs($user) 43 | ->patch('/settings/profile', [ 44 | 'name' => 'Test User', 45 | 'email' => $user->email, 46 | ]); 47 | 48 | $response 49 | ->assertSessionHasNoErrors() 50 | ->assertRedirect('/settings/profile'); 51 | 52 | expect($user->refresh()->email_verified_at)->not->toBeNull(); 53 | }); 54 | 55 | test('user can delete their account', function () { 56 | $user = User::factory()->create(); 57 | 58 | $response = $this 59 | ->actingAs($user) 60 | ->delete('/settings/profile', [ 61 | 'password' => 'password', 62 | ]); 63 | 64 | $response 65 | ->assertSessionHasNoErrors() 66 | ->assertRedirect('/'); 67 | 68 | $this->assertGuest(); 69 | expect($user->fresh())->toBeNull(); 70 | }); 71 | 72 | test('correct password must be provided to delete account', function () { 73 | $user = User::factory()->create(); 74 | 75 | $response = $this 76 | ->actingAs($user) 77 | ->from('/settings/profile') 78 | ->delete('/settings/profile', [ 79 | 'password' => 'wrong-password', 80 | ]); 81 | 82 | $response 83 | ->assertSessionHasErrors('password') 84 | ->assertRedirect('/settings/profile'); 85 | 86 | expect($user->fresh())->not->toBeNull(); 87 | }); 88 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | |string> 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'email' => ['required', 'string', 'email'], 31 | 'password' => ['required', 'string'], 32 | ]; 33 | } 34 | 35 | /** 36 | * Attempt to authenticate the request's credentials. 37 | * 38 | * @throws \Illuminate\Validation\ValidationException 39 | */ 40 | public function authenticate(): void 41 | { 42 | $this->ensureIsNotRateLimited(); 43 | 44 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 45 | RateLimiter::hit($this->throttleKey()); 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => __('auth.failed'), 49 | ]); 50 | } 51 | 52 | RateLimiter::clear($this->throttleKey()); 53 | } 54 | 55 | /** 56 | * Ensure the login request is not rate limited. 57 | * 58 | * @throws \Illuminate\Validation\ValidationException 59 | */ 60 | public function ensureIsNotRateLimited(): void 61 | { 62 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 63 | return; 64 | } 65 | 66 | event(new Lockout($this)); 67 | 68 | $seconds = RateLimiter::availableIn($this->throttleKey()); 69 | 70 | throw ValidationException::withMessages([ 71 | 'email' => __('auth.throttle', [ 72 | 'seconds' => $seconds, 73 | 'minutes' => ceil($seconds / 60), 74 | ]), 75 | ]); 76 | } 77 | 78 | /** 79 | * Get the rate limiting throttle key for the request. 80 | */ 81 | public function throttleKey(): string 82 | { 83 | return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/NewPasswordController.php: -------------------------------------------------------------------------------- 1 | $request->email, 26 | 'token' => $request->route('token'), 27 | ]); 28 | } 29 | 30 | /** 31 | * Handle an incoming new password request. 32 | * 33 | * @throws \Illuminate\Validation\ValidationException 34 | */ 35 | public function store(Request $request): RedirectResponse 36 | { 37 | $request->validate([ 38 | 'token' => 'required', 39 | 'email' => 'required|email', 40 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 41 | ]); 42 | 43 | // Here we will attempt to reset the user's password. If it is successful we 44 | // will update the password on an actual user model and persist it to the 45 | // database. Otherwise we will parse the error and return the response. 46 | $status = Password::reset( 47 | $request->only('email', 'password', 'password_confirmation', 'token'), 48 | function ($user) use ($request) { 49 | $user->forceFill([ 50 | 'password' => Hash::make($request->password), 51 | 'remember_token' => Str::random(60), 52 | ])->save(); 53 | 54 | event(new PasswordReset($user)); 55 | } 56 | ); 57 | 58 | // If the password was successfully reset, we will redirect the user back to 59 | // the application's home authenticated view. If there is an error we can 60 | // redirect them back to where they came from with their error message. 61 | if ($status == Password::PasswordReset) { 62 | return to_route('login')->with('status', __($status)); 63 | } 64 | 65 | throw ValidationException::withMessages([ 66 | 'email' => [__($status)], 67 | ]); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /resources/js/layouts/settings/layout.tsx: -------------------------------------------------------------------------------- 1 | import Heading from '@/components/heading'; 2 | import { Button } from '@/components/ui/button'; 3 | import { Separator } from '@/components/ui/separator'; 4 | import { cn } from '@/lib/utils'; 5 | import { type NavItem } from '@/types'; 6 | import { Link } from '@inertiajs/react'; 7 | import { type PropsWithChildren } from 'react'; 8 | 9 | const sidebarNavItems: NavItem[] = [ 10 | { 11 | title: 'Profile', 12 | href: '/settings/profile', 13 | icon: null, 14 | }, 15 | { 16 | title: 'Password', 17 | href: '/settings/password', 18 | icon: null, 19 | }, 20 | { 21 | title: 'Appearance', 22 | href: '/settings/appearance', 23 | icon: null, 24 | }, 25 | ]; 26 | 27 | export default function SettingsLayout({ children }: PropsWithChildren) { 28 | // When server-side rendering, we only render the layout on the client... 29 | if (typeof window === 'undefined') { 30 | return null; 31 | } 32 | 33 | const currentPath = window.location.pathname; 34 | 35 | return ( 36 |
37 | 38 | 39 |
40 | 59 | 60 | 61 | 62 |
63 |
{children}
64 |
65 |
66 |
67 | ); 68 | } 69 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "build": "vite build", 6 | "build:ssr": "vite build && vite build --ssr", 7 | "dev": "vite", 8 | "format": "prettier --write resources/", 9 | "format:check": "prettier --check resources/", 10 | "lint": "eslint . --fix", 11 | "types": "tsc --noEmit" 12 | }, 13 | "devDependencies": { 14 | "@eslint/js": "^9.19.0", 15 | "@types/node": "^22.13.5", 16 | "eslint": "^9.17.0", 17 | "eslint-config-prettier": "^10.0.1", 18 | "eslint-plugin-react": "^7.37.3", 19 | "eslint-plugin-react-hooks": "^5.1.0", 20 | "prettier": "^3.4.2", 21 | "prettier-plugin-organize-imports": "^4.1.0", 22 | "prettier-plugin-tailwindcss": "^0.6.11", 23 | "typescript-eslint": "^8.23.0" 24 | }, 25 | "dependencies": { 26 | "@headlessui/react": "^2.2.0", 27 | "@inertiajs/react": "^2.0.0", 28 | "@laravel/stream-react": "^0.3.5", 29 | "@radix-ui/react-alert-dialog": "^1.1.14", 30 | "@radix-ui/react-avatar": "^1.1.3", 31 | "@radix-ui/react-checkbox": "^1.1.4", 32 | "@radix-ui/react-collapsible": "^1.1.3", 33 | "@radix-ui/react-dialog": "^1.1.6", 34 | "@radix-ui/react-dropdown-menu": "^2.1.6", 35 | "@radix-ui/react-label": "^2.1.2", 36 | "@radix-ui/react-navigation-menu": "^1.2.5", 37 | "@radix-ui/react-scroll-area": "^1.2.9", 38 | "@radix-ui/react-select": "^2.1.6", 39 | "@radix-ui/react-separator": "^1.1.2", 40 | "@radix-ui/react-slot": "^1.2.3", 41 | "@radix-ui/react-toggle": "^1.1.2", 42 | "@radix-ui/react-toggle-group": "^1.1.2", 43 | "@radix-ui/react-tooltip": "^1.1.8", 44 | "@tailwindcss/vite": "^4.0.6", 45 | "@types/react": "^19.0.3", 46 | "@types/react-dom": "^19.0.2", 47 | "@vitejs/plugin-react": "^4.3.4", 48 | "class-variance-authority": "^0.7.1", 49 | "clsx": "^2.1.1", 50 | "concurrently": "^9.0.1", 51 | "globals": "^15.14.0", 52 | "laravel-vite-plugin": "^1.0", 53 | "lucide-react": "^0.475.0", 54 | "react": "^19.0.0", 55 | "react-dom": "^19.0.0", 56 | "tailwind-merge": "^3.0.1", 57 | "tailwindcss": "^4.0.0", 58 | "tailwindcss-animate": "^1.0.7", 59 | "typescript": "^5.7.2", 60 | "vite": "^6.0" 61 | }, 62 | "optionalDependencies": { 63 | "@rollup/rollup-linux-x64-gnu": "4.9.5", 64 | "@tailwindcss/oxide-linux-x64-gnu": "^4.0.1", 65 | "lightningcss-linux-x64-gnu": "^1.29.1" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /resources/js/pages/auth/forgot-password.tsx: -------------------------------------------------------------------------------- 1 | // Components 2 | import { Head, useForm } from '@inertiajs/react'; 3 | import { LoaderCircle } from 'lucide-react'; 4 | import { FormEventHandler } from 'react'; 5 | 6 | import InputError from '@/components/input-error'; 7 | import TextLink from '@/components/text-link'; 8 | import { Button } from '@/components/ui/button'; 9 | import { Input } from '@/components/ui/input'; 10 | import { Label } from '@/components/ui/label'; 11 | import AuthLayout from '@/layouts/auth-layout'; 12 | 13 | export default function ForgotPassword({ status }: { status?: string }) { 14 | const { data, setData, post, processing, errors } = useForm>({ 15 | email: '', 16 | }); 17 | 18 | const submit: FormEventHandler = (e) => { 19 | e.preventDefault(); 20 | 21 | post(route('password.email')); 22 | }; 23 | 24 | return ( 25 | 26 | 27 | 28 | {status &&
{status}
} 29 | 30 |
31 |
32 |
33 | 34 | setData('email', e.target.value)} 42 | placeholder="email@example.com" 43 | /> 44 | 45 | 46 |
47 | 48 |
49 | 53 |
54 |
55 | 56 |
57 | Or, return to 58 | log in 59 |
60 |
61 |
62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app/private'), 36 | 'serve' => true, 37 | 'throw' => false, 38 | 'report' => false, 39 | ], 40 | 41 | 'public' => [ 42 | 'driver' => 'local', 43 | 'root' => storage_path('app/public'), 44 | 'url' => env('APP_URL').'/storage', 45 | 'visibility' => 'public', 46 | 'throw' => false, 47 | 'report' => false, 48 | ], 49 | 50 | 's3' => [ 51 | 'driver' => 's3', 52 | 'key' => env('AWS_ACCESS_KEY_ID'), 53 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 54 | 'region' => env('AWS_DEFAULT_REGION'), 55 | 'bucket' => env('AWS_BUCKET'), 56 | 'url' => env('AWS_URL'), 57 | 'endpoint' => env('AWS_ENDPOINT'), 58 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 59 | 'throw' => false, 60 | 'report' => false, 61 | ], 62 | 63 | ], 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Symbolic Links 68 | |-------------------------------------------------------------------------- 69 | | 70 | | Here you may configure the symbolic links that will be created when the 71 | | `storage:link` Artisan command is executed. The array keys should be 72 | | the locations of the links and the values should be their targets. 73 | | 74 | */ 75 | 76 | 'links' => [ 77 | public_path('storage') => storage_path('app/public'), 78 | ], 79 | 80 | ]; 81 | -------------------------------------------------------------------------------- /tests/Feature/ChatTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | $response->assertInertia(fn (Assert $page) => $page 21 | ->component('chat') 22 | ->where('chat', null) 23 | ); 24 | } 25 | 26 | public function test_authenticated_user_can_fetch_chats_via_api(): void 27 | { 28 | $user = User::factory()->create(); 29 | $chat = Chat::factory()->create(['user_id' => $user->id, 'title' => 'Test Chat']); 30 | 31 | $response = $this->actingAs($user)->get('/api/chats'); 32 | 33 | $response->assertStatus(200); 34 | $response->assertJsonCount(1); 35 | $response->assertJson([ 36 | [ 37 | 'id' => $chat->id, 38 | 'title' => 'Test Chat', 39 | ], 40 | ]); 41 | } 42 | 43 | public function test_user_can_view_specific_chat(): void 44 | { 45 | $user = User::factory()->create(); 46 | $chat = Chat::factory()->create(['user_id' => $user->id]); 47 | 48 | $response = $this->actingAs($user)->get("/chat/{$chat->id}"); 49 | 50 | $response->assertStatus(200); 51 | $response->assertInertia(fn (Assert $page) => $page 52 | ->component('chat') 53 | ->where('chat.id', $chat->id) 54 | ); 55 | } 56 | 57 | public function test_user_cannot_view_other_users_chat(): void 58 | { 59 | $user = User::factory()->create(); 60 | $otherUser = User::factory()->create(); 61 | $chat = Chat::factory()->create(['user_id' => $otherUser->id]); 62 | 63 | $response = $this->actingAs($user)->get("/chat/{$chat->id}"); 64 | 65 | $response->assertStatus(403); 66 | } 67 | 68 | public function test_authenticated_user_can_create_new_chat(): void 69 | { 70 | $user = User::factory()->create(); 71 | 72 | $response = $this->actingAs($user)->post('/chat', [ 73 | 'title' => 'New Chat', 74 | ]); 75 | 76 | $response->assertRedirect(); 77 | $this->assertDatabaseHas('chats', [ 78 | 'user_id' => $user->id, 79 | 'title' => 'New Chat', 80 | ]); 81 | } 82 | 83 | public function test_unauthenticated_user_cannot_create_chat(): void 84 | { 85 | $response = $this->post('/chat', [ 86 | 'title' => 'New Chat', 87 | ]); 88 | 89 | $response->assertRedirect('/login'); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /resources/js/components/test-event-stream.tsx: -------------------------------------------------------------------------------- 1 | import { useEventStream } from '@laravel/stream-react'; 2 | import { useEffect, useState } from 'react'; 3 | 4 | interface TestEventStreamProps { 5 | chatId: number; 6 | } 7 | 8 | // DEBUG: Test component for EventStream - remove in production 9 | export default function TestEventStream({ chatId }: TestEventStreamProps) { 10 | const [manualMessage, setManualMessage] = useState(''); 11 | const [status, setStatus] = useState('Not started'); 12 | 13 | const { message } = useEventStream(`/chat/${chatId}/title-stream`, { 14 | eventName: "title-update", 15 | endSignal: "", 16 | onMessage: (event) => { 17 | console.log('useEventStream onMessage:', event); 18 | console.log('useEventStream data:', event.data); 19 | }, 20 | onComplete: () => { 21 | console.log('useEventStream complete'); 22 | }, 23 | onError: (error) => { 24 | console.log('useEventStream error:', error); 25 | }, 26 | }); 27 | 28 | // Test with manual EventSource 29 | useEffect(() => { 30 | console.log('Starting manual EventSource test'); 31 | setStatus('Connecting...'); 32 | 33 | const eventSource = new EventSource(`/chat/${chatId}/title-stream`); 34 | 35 | eventSource.onopen = () => { 36 | console.log('Manual EventSource opened'); 37 | setStatus('Connected'); 38 | }; 39 | 40 | eventSource.addEventListener('title-update', (event) => { 41 | console.log('Manual EventSource received title-update:', event.data); 42 | if (event.data !== '') { 43 | setManualMessage(event.data); 44 | } 45 | }); 46 | 47 | eventSource.onmessage = (event) => { 48 | console.log('Manual EventSource onmessage:', event.data); 49 | if (event.data !== '') { 50 | setManualMessage(event.data); 51 | } 52 | }; 53 | 54 | eventSource.onerror = (error) => { 55 | console.log('Manual EventSource error:', error); 56 | setStatus('Error: ' + error.type); 57 | }; 58 | 59 | return () => { 60 | console.log('Closing manual EventSource'); 61 | eventSource.close(); 62 | }; 63 | }, [chatId]); 64 | 65 | console.log('TestEventStream - useEventStream message:', message); 66 | 67 | return ( 68 |
69 |

Test EventStream

70 |

Chat ID: {chatId}

71 |

useEventStream Message: {message || 'No message yet'}

72 |

Manual EventSource Status: {status}

73 |

Manual EventSource Message: {manualMessage || 'No message yet'}

74 |
75 | ); 76 | } -------------------------------------------------------------------------------- /resources/js/components/ui/breadcrumb.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Slot } from "@radix-ui/react-slot" 3 | import { ChevronRight, MoreHorizontal } from "lucide-react" 4 | 5 | import { cn } from "@/lib/utils" 6 | 7 | function Breadcrumb({ ...props }: React.ComponentProps<"nav">) { 8 | return