Skip to content

Latest commit

 

History

History
163 lines (138 loc) · 4.16 KB

File metadata and controls

163 lines (138 loc) · 4.16 KB

GameFriend Architecture

System Overview

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Frontend  │     │   Backend   │     │   Mistral   │
│  (Next.js)  │◄───►│  (FastAPI)  │◄───►│     AI      │
└─────────────┘     └─────────────┘     └─────────────┘
       ▲                    ▲
       │                    │
       ▼                    ▼
┌─────────────┐     ┌─────────────┐
│   Browser   │     │  GameFAQs   │
│   Storage   │     │  Website    │
└─────────────┘     └─────────────┘

Component Architecture

Frontend (Next.js)

  • Purpose: Modern web interface for user interaction
  • Key Features:
    • Guide management interface
    • Interactive chat with AI
    • Game selection and navigation
    • User settings and preferences
  • Directory Structure:
    frontend/
    ├── src/
    │   ├── components/     # Reusable UI components
    │   ├── pages/         # Next.js pages
    │   ├── api/           # API client code
    │   ├── hooks/         # Custom React hooks
    │   └── styles/        # CSS and styling
    ├── public/            # Static assets
    └── package.json       # Dependencies
    

Backend (FastAPI)

  • Purpose: API server and business logic
  • Key Features:
    • Guide management
    • Chat functionality
    • API key management
    • Data persistence
  • Directory Structure:
    gamefriend/
    ├── api/              # API endpoints
    ├── chat/             # Chat functionality
    ├── guide/            # Guide management
    ├── models/           # Data models
    └── utils/            # Utility functions
    

Key Components

Guide Management

  • Frontend:
    • Guide list view
    • Guide download interface
    • Game selection
  • Backend:
    • Guide storage
    • GameFAQs scraping
    • File system operations

Chat System

  • Frontend:
    • Chat interface
    • Message history
    • Real-time updates
  • Backend:
    • Mistral AI integration
    • Chat history management
    • Context handling

Data Flow

Guide Import

  1. User initiates guide download in web interface
  2. Frontend calls backend API
  3. Backend scrapes GameFAQs
  4. Guide is stored and indexed
  5. Frontend updates guide list

Chat Interaction

  1. User sends message in web interface
  2. Frontend calls chat API endpoint
  3. Backend processes with Mistral AI
  4. Response is returned to frontend
  5. Chat interface updates

Game Selection

  1. User browses available games
  2. Frontend fetches game list from API
  3. User selects game for chat
  4. Context is maintained in backend
  5. Chat history is preserved

State Management

Frontend State

  • React state for UI components
  • API client for data fetching
  • Local storage for preferences
  • WebSocket for real-time updates

Backend State

  • Database for persistent storage
  • In-memory cache for performance
  • Session management
  • API key storage

API Endpoints

Guide Management

  • GET /api/guides - List available guides
  • POST /api/guides/download - Download new guide
  • GET /api/guides/{game_id} - Get specific guide
  • DELETE /api/guides/{game_id} - Remove guide

Chat

  • POST /api/chat/start - Start new chat session
  • POST /api/chat/message - Send message
  • GET /api/chat/history - Get chat history
  • DELETE /api/chat/session - End chat session

Security Considerations

API Security

  • JWT authentication
  • Rate limiting
  • Input validation
  • CORS configuration

Data Security

  • API key encryption
  • Secure storage
  • Input sanitization
  • Error handling

Future Considerations

Scalability

  • Horizontal scaling
  • Load balancing
  • Caching strategies
  • Database optimization

Features

  • User accounts
  • Guide sharing
  • Community features
  • Mobile app

Performance

  • API response time
  • Frontend optimization
  • Asset delivery
  • Real-time updates