Develop a complete, end-to-end full-stack multiplayer Wordle game application using Next.js and TypeScript. The application should feature user authentication, real-time gameplay, and a database to manage user data and game state. Implement the following features:
User Authentication:
Game Logic:
Multiplayer Gameplay:
Database and Data Management:
User Interface:
Technology Stack:
Additional Considerations:
I'll create a full-stack multiplayer Wordle game using Next.js, TypeScript, Clerk for authentication, Prisma with Neon PostgreSQL for the database, and WebSockets for real-time gameplay.
First, we need to set up the integrations:
Great! Now that we have the Neon database integration set up, let's create the necessary database tables for our multiplayer Wordle game.
First, let's create the database schema using Prisma:
-- Create users table
CREATE TABLE users (
id TEXT PRIMARY KEY,
username TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- Create games table
CREATE TABLE games (
id SERIAL PRIMARY KEY,
word TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'waiting', -- waiting, active, completed
max_players INTEGER NOT NULL DEFAULT 2,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- Create player_games table (join table for users and games)
CREATE TABLE player_games (
id SERIAL PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
game_id INTEGER NOT NULL REFERENCES games(id) ON DELETE CASCADE,
guesses JSONB DEFAULT '[]',
current_row INTEGER DEFAULT 0,
is_winner BOOLEAN DEFAULT FALSE,
joined_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
UNIQUE(user_id, game_id)
);
-- Create words table for valid words
CREATE TABLE words (
id SERIAL PRIMARY KEY,
word TEXT UNIQUE NOT NULL,
is_solution BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- Create statistics table
CREATE TABLE statistics (
id SERIAL PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
games_played INTEGER DEFAULT 0,
games_won INTEGER DEFAULT 0,
current_streak INTEGER DEFAULT 0,
max_streak INTEGER DEFAULT 0,
guess_distribution JSONB DEFAULT '{"1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0}',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
UNIQUE(user_id)
);