# ๐ŸŽจ Arquitectura MCP - Nexus AI ## Basado en ChatGPT UI Kit (Figma) + Lobe UI **Referencia Figma**: https://www.figma.com/design/e0F6ZXsMuseZpKbc6IU3jR/ChatGPT-UI-Kit--AI-Chat--Community-?node-id=676-342 --- ## ๐Ÿ“ Estructura MCP (Model-Context-Pattern) ### Model (Datos y Lรณgica) - **`useChat.ts`** - Hook principal con lรณgica de negocio - Gestiรณn de mensajes - Estado de conversaciones - Socket.IO communication - State management ### Context (Tema y Configuraciรณn) - **`theme.ts`** - Tokens de diseรฑo basados en Figma - Colores ChatGPT UI Kit - Gradientes Lobe UI - Espaciado sistema - Z-index layers ### Pattern (Componentes y Estilos) - **Layout Components** - Estructura visual - **UI Components** - Elementos interactivos - **Style Components** - CSS-in-JS con antd-style --- ## ๐Ÿ—๏ธ Arquitectura de Componentes ``` App (ThemeProvider) โ”œโ”€โ”€ Layout โ”‚ โ”œโ”€โ”€ Sidebar โ”‚ โ”‚ โ”œโ”€โ”€ Header โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ CloseButton (mobile) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ NewChatButton โ”‚ โ”‚ โ”œโ”€โ”€ Conversations โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ SectionTitle โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ConversationItem[] โ”‚ โ”‚ โ””โ”€โ”€ Footer โ”‚ โ”‚ โ””โ”€โ”€ UserProfile โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ MainContent โ”‚ โ”œโ”€โ”€ ChatHeader (mobile) โ”‚ โ”‚ โ”œโ”€โ”€ MenuButton โ”‚ โ”‚ โ”œโ”€โ”€ Title โ”‚ โ”‚ โ””โ”€โ”€ Actions โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ChatArea โ”‚ โ”œโ”€โ”€ MessagesContainer โ”‚ โ”‚ โ”œโ”€โ”€ WelcomeScreen โ”‚ โ”‚ โ””โ”€โ”€ ChatMessage[] โ”‚ โ”‚ โ”œโ”€โ”€ Avatar โ”‚ โ”‚ โ””โ”€โ”€ Content โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ InputArea โ”‚ โ””โ”€โ”€ ChatInput โ”‚ โ”œโ”€โ”€ AttachButton โ”‚ โ”œโ”€โ”€ Textarea โ”‚ โ””โ”€โ”€ SendButton โ”‚ โ””โ”€โ”€ Overlay (mobile) ``` --- ## ๐ŸŽจ Sistema de Diseรฑo ### Colores Base (Figma ChatGPT UI Kit) ```typescript // Backgrounds colorBgBase: '#0a0a0a' // Dark base colorBgContainer: '#171717' // Container colorBgElevated: '#202020' // Elevated // Text colorTextBase: '#ececf1' // Primary text colorTextSecondary: '#c5c5d2' // Secondary colorTextTertiary: '#8e8ea0' // Tertiary // Borders colorBorder: 'rgba(255, 255, 255, 0.06)' ``` ### Gradientes (Lobe UI Style) ```typescript // Primary - Purple linear-gradient(135deg, #667eea 0%, #764ba2 100%) // Accent - Cyan linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) // Success - Green linear-gradient(135deg, #43e97b 0%, #38f9d7 100%) ``` ### Glassmorphism ```css background: rgba(17, 17, 17, 0.7); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.08); ``` --- ## ๐Ÿ“ Estructura de Archivos ``` client/src/ โ”œโ”€โ”€ App.tsx # App principal con layout MCP โ”œโ”€โ”€ App.css # Estilos globales mรญnimos โ”‚ โ”œโ”€โ”€ components/ # Componentes UI โ”‚ โ”œโ”€โ”€ SidebarNew.tsx # โœจ Sidebar rediseรฑado โ”‚ โ”œโ”€โ”€ ChatHeader.tsx # โœจ Header mobile โ”‚ โ”œโ”€โ”€ ChatContainer.tsx # Container de chat โ”‚ โ”œโ”€โ”€ ChatMessage.tsx # Mensaje individual โ”‚ โ”œโ”€โ”€ ChatInput.tsx # Input personalizado โ”‚ โ””โ”€โ”€ WelcomeScreen.tsx # Pantalla bienvenida โ”‚ โ”œโ”€โ”€ hooks/ # Custom hooks โ”‚ โ””โ”€โ”€ useChat.ts # Hook principal de chat โ”‚ โ”œโ”€โ”€ styles/ # โœจ Sistema de estilos โ”‚ โ”œโ”€โ”€ theme.ts # Tema ChatGPT + Lobe UI โ”‚ โ””โ”€โ”€ appLayout.styles.ts # Estilos de layout โ”‚ โ””โ”€โ”€ types/ # TypeScript types โ””โ”€โ”€ index.ts # Tipos globales ``` --- ## ๐ŸŽฏ Caracterรญsticas Implementadas ### Layout Principal - โœ… **Sidebar glassmorphism** - Blur 20px + transparencia - โœ… **Layout responsive** - Desktop + Mobile - โœ… **Overlay mobile** - Backdrop blur al abrir sidebar - โœ… **Smooth transitions** - 0.3s ease ### Sidebar (Basado en Figma) - โœ… **Header con botรณn nuevo chat** - Gradiente purple - โœ… **Lista de conversaciones** - Con secciรณn "Recientes" - โœ… **User profile** - Avatar + info - โœ… **Scroll personalizado** - 4px thin purple - โœ… **Hover effects** - Transform translateX(4px) - โœ… **Active state** - Purple tint + border ### Chat Header (Mobile) - โœ… **Menu toggle** - Abre/cierra sidebar - โœ… **Title** - Nombre de la app - โœ… **Actions** - Settings + Profile - โœ… **Glassmorphism** - Blur 12px ### Chat Container - โœ… **Messages area** - Scroll infinito - โœ… **Welcome screen** - Logo + sugerencias - โœ… **Typing indicator** - 3 dots animados - โœ… **Custom input** - Auto-resize + Enter send --- ## ๐Ÿ”ง Configuraciรณn del Tema ### ThemeProvider Setup ```tsx import { ThemeProvider } from 'antd-style'; import { chatGPTTheme } from './styles/theme'; ``` ### Usando Tokens en Componentes ```tsx import { createStyles } from 'antd-style'; const useStyles = createStyles(({ css, token }) => ({ container: css` background: ${token.colorBgContainer}; color: ${token.colorTextBase}; border-radius: ${token.borderRadius}px; `, })); ``` ### Usando Colores Custom (Lobe UI) ```tsx import { lobeUIColors } from '../styles/theme'; const useStyles = createStyles(({ css }) => ({ button: css` background: ${lobeUIColors.gradient.primary}; `, })); ``` --- ## ๐Ÿ“ฑ Responsive Design ### Breakpoints ```css /* Desktop First */ @media (max-width: 768px) { /* Mobile styles */ } ``` ### Mobile Behavior #### Sidebar ```css /* Desktop */ width: 260px; position: relative; /* Mobile */ position: fixed; left: -260px; /* Hidden by default */ z-index: 1000; &.open { left: 0; /* Slide in */ } ``` #### Header ```css /* Desktop */ display: none; /* Mobile */ display: flex; height: 48px; ``` --- ## ๐ŸŽจ Componentes Clave ### 1. Sidebar **Props**: ```typescript interface SidebarProps { conversations: Conversation[]; activeConversationId: string; onNewChat: () => void; onSelectConversation: (id: string) => void; onClose?: () => void; // Para mobile } ``` **Caracterรญsticas**: - Header con botรณn gradiente - Lista scrollable con secciรณn titles - User profile en footer - Close button para mobile ### 2. ChatHeader **Props**: ```typescript interface ChatHeaderProps { onMenuClick?: () => void; onSettingsClick?: () => void; onProfileClick?: () => void; title?: string; } ``` **Caracterรญsticas**: - Solo visible en mobile - Menu toggle para sidebar - Actions buttons (settings, profile) - Glassmorphism style ### 3. ChatContainer **Props**: ```typescript interface ChatContainerProps { messages: Message[]; isTyping: boolean; onSendMessage: (content: string) => void; } ``` **Caracterรญsticas**: - Messages scrollable area - Welcome screen cuando vacรญo - Typing indicator - Custom input area --- ## ๐ŸŽฏ Patrรณn de Estado ### useChat Hook (Model) ```typescript const { messages, // Message[] conversations, // Conversation[] activeConversationId, // string isTyping, // boolean sendMessage, // (content: string) => void createNewConversation, // () => void selectConversation, // (id: string) => void } = useChat(); ``` ### Flujo de Datos ``` Usuario โ†’ Acciรณn โ†“ useChat Hook โ†“ Socket.IO โ†’ Backend โ†“ Backend responde โ†“ useChat actualiza estado โ†“ Componentes re-renderizan ``` --- ## ๐Ÿš€ Cรณmo Usar ### 1. Iniciar Aplicaciรณn ```bash npm run dev:all ``` ### 2. Abrir en Navegador ``` http://localhost:3001 ``` ### 3. Probar Features - โœ… Click "Nuevo chat" โ†’ Crea conversaciรณn - โœ… Escribir mensaje โ†’ Enter envรญa - โœ… Ver respuesta AI โ†’ Con typing indicator - โœ… Mobile: Menu button โ†’ Abre sidebar - โœ… Mobile: Overlay โ†’ Cierra sidebar --- ## ๐ŸŽจ Estilos Destacados ### Sidebar Container ```css background: rgba(13, 13, 13, 0.8); backdrop-filter: blur(20px); border-right: 1px solid rgba(255, 255, 255, 0.06); ``` ### Nuevo Chat Button ```css background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 20px rgba(102, 126, 234, 0.3); &:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 30px rgba(102, 126, 234, 0.5); } ``` ### Conversation Item (Active) ```css background: rgba(102, 126, 234, 0.1); border-color: #667eea; color: white; svg { opacity: 1; } ``` ### User Profile ```css border: 1px solid rgba(255, 255, 255, 0.08); background: transparent; &:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(102, 126, 234, 0.4); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); } ``` --- ## ๐Ÿ“Š Comparaciรณn ### Antes ``` App โ””โ”€โ”€ Container โ”œโ”€โ”€ Sidebar (fijo) โ””โ”€โ”€ Chat ``` ### Ahora (MCP) ``` App (ThemeProvider) โ”œโ”€โ”€ Theme Config (chatGPTTheme) โ”œโ”€โ”€ Layout (appLayout.styles) โ”‚ โ”œโ”€โ”€ Sidebar (glassmorphism) โ”‚ โ”œโ”€โ”€ MainContent โ”‚ โ”‚ โ”œโ”€โ”€ Header (mobile) โ”‚ โ”‚ โ””โ”€โ”€ ChatArea โ”‚ โ””โ”€โ”€ Overlay (mobile) โ””โ”€โ”€ State (useChat hook) ``` **Ventajas**: - โœ… Separaciรณn clara de responsabilidades - โœ… Tema centralizado y reutilizable - โœ… Estilos organizados por contexto - โœ… Mobile-first responsive - โœ… Mรกs escalable y mantenible --- ## ๐Ÿ”ฎ Extensiones Futuras ### Fรกcil de Agregar #### 1. Settings Panel ```tsx ``` #### 2. Search Conversations ```tsx ``` #### 3. Conversation Actions ```tsx ``` #### 4. Themes Switcher ```tsx const themes = ['dark', 'light', 'auto']; ``` --- ## โœ… Checklist de Implementaciรณn ### Estructura - [x] Crear `styles/theme.ts` - [x] Crear `styles/appLayout.styles.ts` - [x] Crear `components/SidebarNew.tsx` - [x] Crear `components/ChatHeader.tsx` - [x] Actualizar `App.tsx` con layout MCP ### Estilos - [x] Colores Figma ChatGPT UI Kit - [x] Gradientes Lobe UI - [x] Glassmorphism effects - [x] Responsive mobile - [x] Animations y transitions ### Funcionalidad - [x] Sidebar toggle mobile - [x] Overlay con backdrop blur - [x] Scroll personalizado - [x] Active states - [x] Hover effects --- ## ๐Ÿ“š Referencias - **Figma Design**: ChatGPT UI Kit (node-id=676-342) - **Lobe UI**: https://ui.lobehub.com - **antd-style**: https://ant-design.github.io/antd-style - **Pattern**: MCP (Model-Context-Pattern) --- **Fecha de implementaciรณn**: 14 de Febrero, 2026 **Arquitectura**: MCP (Model-Context-Pattern) **Design System**: ChatGPT UI Kit + Lobe UI **Estado**: โœ… Implementado y Funcional **Responsive**: โœ… Desktop + Mobile