# ๐จ 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