Skip to content

bele44/react-native-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Trivia Game - Modern React Native App

A modern, scalable React Native trivia game built with the latest technologies and best practices.

πŸš€ Tech Stack

  • Framework: Expo + Expo Router
  • State Management: Zustand
  • Data Fetching: TanStack Query + Axios
  • Styling: NativeWind (Tailwind CSS for React Native)
  • Language: TypeScript
  • Navigation: Expo Router (file-based routing)

πŸ“ Project Structure

β”œβ”€β”€ app/                    # Expo Router pages
β”‚   β”œβ”€β”€ _layout.tsx        # Root layout
β”‚   β”œβ”€β”€ auth/              # Authentication pages
β”‚   β”‚   β”œβ”€β”€ login.tsx
β”‚   β”‚   └── register.tsx
β”‚   └── tabs/              # Main app tabs
β”‚       β”œβ”€β”€ index.tsx      # Game screen
β”‚       β”œβ”€β”€ leaderboard.tsx
β”‚       └── settings.tsx
β”œβ”€β”€ components/            # Reusable components
β”‚   β”œβ”€β”€ ui/               # Base UI components
β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”œβ”€β”€ Card.tsx
β”‚   β”‚   └── Input.tsx
β”‚   β”œβ”€β”€ game/             # Game-specific components
β”‚   β”‚   β”œβ”€β”€ QuestionCard.tsx
β”‚   β”‚   β”œβ”€β”€ AnswerButton.tsx
β”‚   β”‚   └── ProgressBar.tsx
β”‚   └── utils/            # Utility components
β”œβ”€β”€ stores/               # Zustand stores
β”‚   β”œβ”€β”€ authStore.ts
β”‚   β”œβ”€β”€ gameStore.ts
β”‚   └── settingsStore.ts
β”œβ”€β”€ hooks/                # Custom hooks
β”‚   β”œβ”€β”€ useAuth.ts
β”‚   └── useGame.ts
β”œβ”€β”€ services/             # API services
β”‚   β”œβ”€β”€ apiClient.ts
β”‚   β”œβ”€β”€ authService.ts
β”‚   └── mockService.ts
β”œβ”€β”€ types/                # TypeScript types
β”‚   β”œβ”€β”€ auth.ts
β”‚   └── game.ts
└── constants/            # App constants
    β”œβ”€β”€ Colors.ts
    β”œβ”€β”€ Styles.ts
    └── GameConfig.ts

πŸ—οΈ Architecture

State Management (Zustand)

  • authStore: User authentication state
  • gameStore: Game state and history
  • settingsStore: App settings and preferences

Data Fetching (TanStack Query)

  • Automatic caching and synchronization
  • Background refetching
  • Optimistic updates
  • Error handling and retry logic

Styling (NativeWind)

  • Utility-first CSS approach
  • Consistent design system
  • Responsive design
  • Dark mode support

🎯 Key Features

Authentication

  • Secure login/register flow
  • Token-based authentication
  • Automatic token refresh
  • Persistent sessions

Game Features

  • Multiple difficulty levels
  • Category-based questions
  • Real-time scoring
  • Progress tracking
  • Game history

UI/UX

  • Modern, clean design
  • Smooth animations
  • Responsive layout
  • Accessibility support
  • Loading states

πŸ› οΈ Development

Prerequisites

  • Node.js 18+
  • Expo CLI
  • iOS Simulator (for iOS development)
  • Android Studio (for Android development)

Installation

# Install dependencies
npm install

# Start development server
npm start

# Run on iOS
npm run ios

# Run on Android
npm run android

Code Style

  • TypeScript for type safety
  • ESLint for code quality
  • Prettier for formatting
  • Husky for git hooks

πŸ“± Screens

Authentication

  • Login: Email/password authentication
  • Register: New user registration
  • Demo Login: Quick access for testing

Main App

  • Game: Interactive trivia gameplay
  • Leaderboard: Player rankings
  • Settings: App configuration

πŸ”§ Configuration

Environment Variables

# API Configuration
EXPO_PUBLIC_API_URL=https://your-api-url.com
EXPO_PUBLIC_API_TIMEOUT=10000

Tailwind Configuration

Custom colors and utilities defined in tailwind.config.js

πŸš€ Deployment

Build for Production

# Build for iOS
expo build:ios

# Build for Android
expo build:android

# Build for Web
expo build:web

App Store Deployment

  1. Configure app.json with proper bundle identifiers
  2. Build production version
  3. Submit to App Store/Google Play

πŸ§ͺ Testing

Unit Tests

npm test

E2E Tests

npm run e2e

πŸ“ˆ Performance

Optimizations

  • Lazy loading of components
  • Image optimization
  • Bundle splitting
  • Memory management

Monitoring

  • Crash reporting
  • Performance metrics
  • User analytics

πŸ”’ Security

Best Practices

  • Secure token storage
  • API request validation
  • Input sanitization
  • HTTPS enforcement

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ™ Acknowledgments

  • Expo team for the amazing framework
  • React Native community
  • Open source contributors

Built with ❀️ using modern React Native practices

About

a question demo game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published