e-m/wordpressreact icon
public
Published on 3/16/2025
React using wordpress as a backend

Prompts
Models
Context
anthropic Claude 3.7 Sonnet model icon

Claude 3.7 Sonnet

anthropic

200kinput·8.192koutput
anthropic Claude 3.5 Sonnet model icon

Claude 3.5 Sonnet

anthropic

200kinput·8.192koutput
mistral Codestral model icon

Codestral

mistral

voyage voyage-code-3 model icon

voyage-code-3

voyage

voyage Voyage AI rerank-2 model icon

Voyage AI rerank-2

voyage

No Rules configured

Reacthttps://react.dev/reference/

Prompts

Learn more
# Project Comprehensive Overview

## System Architecture

### Frontend
- **Technology Stack**: React with TypeScript
- **Routing Framework**: Advanced routing system with nested routes
- **State Management**: Custom stores using Zustand-like pattern

### Backend Integration
- WordPress as the primary backend
- Custom authentication and API layer
- Seamless integration between React frontend and WordPress

## Routing Structure

### Authentication Routes
- `/sign-in`: User login
- `/sign-up`: User registration
- `/forgot-password`: Password recovery
- `/otp`: Multi-factor authentication
- `/google-callback`: OAuth integration

### Authenticated Routes
- `/_authenticated/`:
  - `/settings/`: User account settings
    - `/account`: Account details
    - `/appearance`: UI customization
  - `/apps/`: Application management
  - `/tasks/`: Task tracking
  - `/help-center/`: Support and documentation

### Error Handling Routes
- `/401`: Unauthorized access
- `/403`: Forbidden access
- `/404`: Page not found
- `/500`: Server error
- `/503`: Service unavailable

## Key Services

### Authentication Service (`src/services/wordpress-auth.ts`)
- WordPress-specific authentication mechanisms
- Handles:
  - User authentication
  - Token management
  - User profile retrieval

#### Interfaces
- `WordPressAuthResponse`: 
  ```typescript
  {
    token: string
    user_email: string
    user_nicename: string
    user_display_name: string
    user_id: number
  }
  ```
- `WordPressUser`: Detailed user information
- `WordPressSite`: Site metadata

### API Key Management (`src/stores/apiKeyStore.ts`)
- Generate application passwords
- List and revoke API keys
- Secure access token management

#### Interfaces
- `ApiKey`:
  ```typescript
  {
    uuid: string
    name: string
    created: number
    last_used?: number
  }
  ```

### Credit Service (`src/services/credit-service.ts`)
- Manages user credits and transactions
- Tracks subscription plans
- Handles billing cycles

#### Interfaces
- `CreditBalance`:
  ```typescript
  {
    balance: number
    formatted_balance: string
    transactions: Array<{
      type: 'credit' | 'debit'
      amount: number
      balance: number
      date: string
      description: string
    }>
    subscriptionPlan: string
    monthlyAllocation: number
    monthlyUsage: number
  }
  ```

## Authentication Flow

1. User initiates login/signup
2. Frontend communicates with WordPress authentication endpoint
3. WordPress validates credentials
4. Returns authentication token
5. Frontend stores token and user information
6. Subsequent API calls include authentication token

## WordPress Plugin Interactions

### Authentication
- Uses WordPress's built-in REST API
- Generates application-specific passwords
- Supports multiple authentication methods:
  - Standard username/password
  - Google OAuth
  - Multi-factor authentication

### API Integration
- Custom WordPress plugin provides extended API endpoints
- Manages:
  - User profiles
  - Site information
  - Billing and credit systems
  - API key management

## Security Considerations
- Token-based authentication
- Secure storage of access tokens
- Role-based access control
- OAuth integration
- Multi-factor authentication support

## Frontend State Management Patterns

### Auth Store (`src/stores/authStore.ts`)
- Centralized authentication state
- Methods for:
  - User authentication
  - Token validation
  - Logout
  - User information management

#### Auth State Structure
```typescript
interface AuthState {
  user: AuthUser | null
  accessToken: string
  isAuthenticated(): boolean
  login(email: string, password: string): Promise<boolean>
  logout(): void
}
```

## Deployment and Scaling
- Serverless-compatible architecture
- Decoupled frontend and backend
- Supports multiple WordPress instances
- Scalable authentication mechanism


---

**Note**: This is a comprehensive overview of the project's architecture, integrating React frontend with WordPress backend, focusing on authentication, API management, and state handling.

Context

Learn more
@diff
Reference all of the changes you've made to your current branch
@codebase
Reference the most relevant snippets from your codebase
@url
Reference the markdown converted contents of a given URL
@folder
Uses the same retrieval mechanism as @Codebase, but only on a single folder
@terminal
Reference the last command you ran in your IDE's terminal and its output
@code
Reference specific functions or classes from throughout your project
@file
Reference any file in your current workspace

No Data configured

MCP Servers

Learn more

No MCP Servers configured