This application is a typing game inspired by TypeRacer that allows users to practice their typing skills in both solo and multiplayer modes. It features a clean, modern interface built with Vue.js for the frontend and a Node.js/Express backend with PostgreSQL database support.
- Solo Typing Practice: Practice typing with random text passages from a database of stories
- Multiplayer Racing: Compete against other players in real-time typing races
- Real-time Progress Tracking: See your progress and compare with others during races
- WPM (Words Per Minute) Calculation: Track your typing speed
- Interactive UI: Character-by-character feedback on typing accuracy
- Language/Framework: Node.js with Express
- Database: PostgreSQL
- Real-time Communication: Socket.IO for multiplayer functionality
- Structure:
src/api: API controllers for handling HTTP requestssrc/config: Database and application configurationsrc/migrations: SQL schema files for database setupsrc/models: Data models for interacting with the databasesrc/routes: Express route definitionssrc/sockets: Socket.IO event handlers for real-time functionality
- Framework: Vue 3 with Composition API
- Routing: Vue Router
- Styling: TailwindCSS
- Structure:
src/components: Reusable UI componentssrc/composables: Shared logic and state managementsrc/pages: Main application pagessrc/router: Route configurationsrc/icons: SVG icons used throughout the application
- Node.js (v14 or higher)
- PostgreSQL (v12 or higher)
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install -
Create a
.envfile in the backend directory with the following environment variables:PORT=3000 DATABASE_URL=postgres://username:password@localhost:5432/typeracer -
Set up the database:
node src/config/migrate.js node src/config/randomStories.js -
Start the server:
npm run dev
The backend will run a production version. The steps below are for development purposes, for running the frontend on a different terminal using vite.
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install -
Start the development server:
npm run dev
- Navigate to the home page
- The application will load a random text passage from the database
- Start typing in the input field to begin the test
- The application provides real-time feedback on your typing accuracy
- You can request a new text passage by clicking the refresh button
- Navigate to the Race page
- Click "Join Queue" to enter a waiting room
- When the room fills with 4 players (or the timeout is reached), a countdown will begin
- Race against other players by typing the provided text as quickly and accurately as possible
- View real-time progress of all participants
- Results are displayed after all players complete the race
Returns a random story from the database. Depending on the type. Options are multiplayer, time, or no type
Response:
{
"id": "uuid",
"title": "Story Title",
"content": "Story content...",
"created_at": "timestamp"
}joinQueue: Join the multiplayer queueupdateProgress: Send current progress to the serverdisconnect: Handle player disconnection
playerJoined: Notifies when a new player joins the roomplayerLeft: Notifies when a player leavescountdown: Countdown before race startsgameStart: Sends the text for the raceprogressUpdate: Updates on other players' progressgameText: Sends the typing text to newly joined players
The application implements a room-based multiplayer system:
- Players join a queue via WebSocket
- The server places them in available rooms (up to 4 players per room)
- When a room is full, a countdown begins
- All players in the room receive the same text to type
- Progress is synchronized in real-time
- Players can see their position relative to others
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
