An open API service indexing awesome lists of open source software.

https://github.com/olemak/puzloc

Multi-game puzzle platform: NumLock & PhraseLock. Learning .NET, PostgreSQL, SvelteKit in an Nx monorepo.
https://github.com/olemak/puzloc

csharp docker dotnet hangman learning-project monorepo nx postgresql puzzle-game svelte sveltekit typescript wordle

Last synced: 2 months ago
JSON representation

Multi-game puzzle platform: NumLock & PhraseLock. Learning .NET, PostgreSQL, SvelteKit in an Nx monorepo.

Awesome Lists containing this project

README

          

# ๐ŸŽฎ Puzloc - Multi-Game Puzzle Platform

[![GitHub repo](https://img.shields.io/badge/GitHub-puzloc-blue?logo=github)](https://github.com/olemak/puzloc)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![.NET](https://img.shields.io/badge/.NET-8.0-512BD4?logo=dotnet)](https://dotnet.microsoft.com/)
[![Svelte](https://img.shields.io/badge/Svelte-Kit-FF3E00?logo=svelte)](https://kit.svelte.dev/)
[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-16-336791?logo=postgresql)](https://www.postgresql.org/)

A monorepo project for exploring modern full-stack technologies through building an engaging puzzle game platform.

## ๐ŸŽฏ Concept

**Puzloc** (Puzzle Lock) is a collection of puzzle games where players attempt to "unlock" challenges through logic and deduction.

### Game 1: NumLock ๐Ÿ”ข
A Wordle-inspired number guessing game with a keypad interface.

**How it works:**
- Players have to guess a 4-digit code
- Each guess provides feedback:
- โŒ **Gray**: Digit not in the code
- ๐ŸŸก **Yellow**: Digit in code but wrong position
- ๐ŸŸข **Green**: Digit correct and in right position
- Limited attempts to crack the code
- Daily challenges with leaderboards

### Game 2: PhraseLock ๐Ÿ“
A Hangman/Countdown-style phrase guessing game.

**How it works:**
- Players see a masked phrase: `*** **** ***** ***`
- Can guess individual letters or the whole phrase
- Optional: Unlock letters using "coins" or attempts
- Daily phrases with varying difficulty
- Category hints available

## โšก Quick Start

**Just want to start coding?**

```bash
# 1. Clone and setup
git clone https://github.com/olemak/puzloc.git
cd puzloc
npm install

# 2. Start development environment
npm run dev

# 3. Create backend (automated)
npm run setup:backend

# 4. Start coding!
cd apps/backend
dotnet watch run
```

**OR** follow the detailed guide: **[START_HERE.md](START_HERE.md)** ๐Ÿ“–

### Helpful Commands

```bash
npm run dev # Start Docker services
npm run setup:backend # Auto-create backend project
npm run docker:start # Start Docker only
npm run docker:stop # Stop Docker services
npm run db # Open PostgreSQL CLI
```

## ๐Ÿ—๏ธ Architecture

### Monorepo Structure
```
puzloc/
โ”œโ”€โ”€ apps/
โ”‚ โ”œโ”€โ”€ backend/ # .NET Web API
โ”‚ โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Api/ # API controllers & endpoints
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Core/ # Domain models & business logic
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Infrastructure/ # Database, auth, external services
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ Services/ # Game logic services
โ”‚ โ”‚ โ””โ”€โ”€ tests/
โ”‚ โ”œโ”€โ”€ frontend-svelte/ # Svelte web application
โ”‚ โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ lib/
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Shared UI components
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ games/ # Game-specific components
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ services/ # API client, state management
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ routes/ # SvelteKit routes
โ”‚ โ”‚ โ””โ”€โ”€ tests/
โ”‚ โ””โ”€โ”€ frontend-native/ # React Native app (future)
โ”œโ”€โ”€ packages/
โ”‚ โ”œโ”€โ”€ shared-types/ # Shared TypeScript types
โ”‚ โ”œโ”€โ”€ game-engine/ # Shared game logic
โ”‚ โ””โ”€โ”€ api-client/ # Typed API client
โ”œโ”€โ”€ infrastructure/
โ”‚ โ””โ”€โ”€ docker/
โ”‚ โ”œโ”€โ”€ docker-compose.yml
โ”‚ โ””โ”€โ”€ postgres/
โ””โ”€โ”€ docs/
โ”œโ”€โ”€ api/ # API documentation
โ””โ”€โ”€ architecture/ # Architecture decisions
```

### Technology Stack

#### Backend
- **Framework**: .NET 8 Web API
- **Database**: PostgreSQL
- **ORM**: Entity Framework Core
- **Authentication**: JWT tokens
- **Testing**: xUnit

#### Frontend (Web)
- **Framework**: SvelteKit
- **Language**: TypeScript
- **Styling**: TailwindCSS
- **State**: Svelte stores
- **API Client**: Custom typed client

#### Infrastructure
- **Database**: PostgreSQL (Docker)
- **Caching**: Redis (optional, future)
- **Containerization**: Docker & Docker Compose

#### Monorepo
- **Tool**: Nx
- **Package Manager**: npm

## ๐Ÿ—„๏ธ Database Schema (Initial)

```sql
-- Users
CREATE TABLE users (
id UUID PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);

-- Daily Challenges
CREATE TABLE challenges (
id UUID PRIMARY KEY,
game_type VARCHAR(20) NOT NULL, -- 'numlock' or 'phraselock'
challenge_date DATE NOT NULL,
solution TEXT NOT NULL, -- encrypted/hashed
difficulty VARCHAR(20),
created_at TIMESTAMP DEFAULT NOW(),
UNIQUE(game_type, challenge_date)
);

-- Game Attempts
CREATE TABLE attempts (
id UUID PRIMARY KEY,
user_id UUID REFERENCES users(id),
challenge_id UUID REFERENCES challenges(id),
guess TEXT NOT NULL,
result JSONB NOT NULL, -- Feedback data
attempt_number INT NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);

-- User Stats
CREATE TABLE user_stats (
user_id UUID PRIMARY KEY REFERENCES users(id),
game_type VARCHAR(20) NOT NULL,
games_played INT DEFAULT 0,
games_won INT DEFAULT 0,
current_streak INT DEFAULT 0,
max_streak INT DEFAULT 0,
average_attempts DECIMAL(4,2),
updated_at TIMESTAMP DEFAULT NOW(),
UNIQUE(user_id, game_type)
);

-- Leaderboards (computed view or materialized)
CREATE TABLE leaderboard_entries (
id UUID PRIMARY KEY,
user_id UUID REFERENCES users(id),
game_type VARCHAR(20) NOT NULL,
period VARCHAR(20) NOT NULL, -- 'daily', 'weekly', 'all_time'
score INT NOT NULL,
rank INT,
calculated_at TIMESTAMP DEFAULT NOW()
);
```

## ๐Ÿš€ Getting Started

### Prerequisites
- Node.js 20+ (for frontend & tooling)
- .NET 8 SDK
- Docker & Docker Compose
- PostgreSQL (via Docker)

### Setup

1. **Clone and install dependencies:**
```bash
git clone
cd puzloc
npm install
```

2. **Start PostgreSQL:**
```bash
cd infrastructure/docker
docker-compose up -d postgres
```

3. **Run backend:**
```bash
cd apps/backend
dotnet restore
dotnet run
```

4. **Run frontend:**
```bash
cd apps/frontend-svelte
npm install
npm run dev
```

## ๐ŸŽฎ Game Logic

### NumLock Algorithm
```typescript
function checkGuess(guess: string, solution: string): Feedback[] {
// Compare each digit
// Return array of: 'correct' | 'wrong-position' | 'not-in-answer'
}
```

### PhraseLock Algorithm
```typescript
function revealLetter(phrase: string, guessedLetters: Set): string {
// Reveal guessed letters, keep rest masked
}
```

## ๐Ÿ“ˆ Future Features

- [ ] **More Games**: Add Sudoku, Crossword, Logic puzzles
- [ ] **Social Features**: Friends, challenges, shared scores
- [ ] **Achievements**: Badges, milestones, rewards
- [ ] **Multiplayer**: Head-to-head challenges
- [ ] **Mobile App**: React Native or Flutter
- [ ] **Analytics**: Game difficulty balancing, player insights
- [ ] **Observability**: Structured logging, metrics (Serilog + Seq?)

## ๐Ÿงช Learning Goals

This project is designed to explore:
- โœ… .NET backend development
- โœ… PostgreSQL database design
- โœ… JWT authentication
- โœ… SvelteKit frontend
- โœ… Nx monorepo management
- โœ… Docker containerization
- โœ… RESTful API design
- โœ… TypeScript type safety across stack

## ๐Ÿ“ License

MIT

## ๐Ÿ‘ค Author

Built as a learning project to explore modern full-stack technologies.