Projekt zaawansowanej gry online (MMO) napisanej w Next.js z architekturฤ database-driven i automatycznym generowaniem backendu za pomocฤ PlopJS.
Sybath to gra strategiczna MMO ลฤ czฤ ca elementy rpg, city-buildingu, zarzฤ dzania zasobami i eksploracji mapy ลwiata.
Caลa logika biznesowa jest oparta na bazie danych PostgreSQL:
Definicja w PostgreSQL
โ
PlopJS Generator
โ
Automatyczne tworzenie:
โโโ TypeScript schematรณw typรณw
โโโ API Routes (GET/POST)
โโโ React Hooks (useFetch*)
โโโ Server-side Fetchers
โโโ Atom State (Jotai)
src/
โโโ db/postgresMainDatabase/schemas/
โ โโโ map/ (ลwiat, miasta, dystrykt)
โ โโโ players/ (gracze, umiejฤtnoลci)
โ โโโ items/ (inwentarz, przedmioty)
โ โโโ attributes/ (atrybuty, zdolnoลci)
โ
โ
โโโ app/api/
โ โโโ [schema]/[table]/ (GET - wszystkie rekordy)
โ โโโ [schema]/[table]/[id]/ (GET - po ID)
โ โโโ [schema]/rpc/[method]/ (Wywoลywanie procedur)
โ
โโโ methods/
โ โโโ hooks/ (React useFetch* - client-side)
โ โโโ server-fetchers/ (Server-side data fetching)
โ โโโ actions/ (Server actions - mutacje)
โ
โโโ components/
โ โโโ map/ (komponenty mapy)
โ โโโ city/ (komponenty miasta)
โ โโโ portals/modals/ (modale UI)
โ
โโโ store/
โโโ atoms.ts (Jotai atoms - state management)
| Technologia | Wersja | Uลผycie |
|---|---|---|
| Next.js | 14+ | Framework, App Router |
| React | 18+ | Component model |
| TypeScript | Latest | Type safety |
| Jotai | Latest | State management |
| SWR | Latest | Data fetching |
| TailwindCSS | Latest | Styling |
| shadcn/ui | Latest | UI Components |
| Technologia | Wersja | Uลผycie |
|---|---|---|
| Next.js API Routes | 14+ | Serverless backend |
| PostgreSQL | 17 | Relacyjna baza |
| PlopJS | Latest | Code generation |
| Auth.js | Latest | Authentication |
| Zod | Latest | Schema validation |
- Proceduralne generowanie terenu
- Dynamiczne zaลadowanie danych
- Real-time pozycja gracza
- Eksploracja ลwiata
- Sub-mapy dla miast
- Zarzฤ dzanie budynkami
- Strefa produkcji (dystrykt)
- System rรณl (Owner, Worker)
- Wielowarstwowy system magazynowania
- Inwentarz gracza, budynku, dystryku
- Slot-based storage (grid)
- Automatyczne sortowanie
- Umiejฤtnoลci (Skills)
- Zdolnoลci (Abilities)
- System progresji
- Atrybuty charakteru
- Inspiracja: Slay the Spire
- System akcji turowych
- Karty akcji (Attack, Parry, Riposte)
- Replay systemu rund
Jeden wybรณr z CLI generuje 8+ w peลni funkcjonalnych plikรณw:
plop "Get Data From Table"
โ| Plik | Typ | Opis |
|---|---|---|
db/postgresMainDatabase/schemas/[schema]/[table].ts |
TypeScript | Typ i fetch funkcja |
app/api/[schema]/[table]/route.ts |
API Route | GET wszystkie |
app/api/[schema]/[table]/[id]/route.ts |
API Route | GET po ID |
methods/hooks/[schema]/useFetch[Table].ts |
React Hook | Client-side fetch |
methods/hooks/[schema]/useFetch[Table]ByKey.ts |
React Hook | Fetch z cache |
methods/server-fetchers/[schema]/get[Table]Server.ts |
Server Function | Server-side fetch |
methods/server-fetchers/[schema]/get[Table]ByKeyServer.ts |
Server Function | By Key server |
store/atoms.ts |
Atom Store | State management |
| Metoda | Iloลฤ Kodu | Redukcja |
|---|---|---|
| Tradycyjny | ~500 linii | - |
| Z PlopJS | ~50 linii | 90% |
| Zysk | 450 linii | Per funkcja |
| Warstwa | Mechanizm | Status |
|---|---|---|
| Database | PostgreSQL RLS | โ |
| Auth | Auth.js sessions | โ |
| Validation | Zod schemas | โ |
| Types | TypeScript end-to-end | โ |
| API | CSRF protection | โ |
export async function addItemToInventoryAction({ playerId, item_id, quantity }: TAddItemToInventory) {
// Direct database mutation
}// Jawnie pokazuje uลผywane pola, zachowujฤ
c elastycznoลฤ typu
function addItemToInventory({ playerId, item_id, quantity }: TAddItemToInventory)export const districtAtom = atom<TDistrictRecordById>({})
export const selectedHeroAtom = atom<number | null>(null)| Umiejฤtnoลฤ | Level | Opis |
|---|---|---|
| Full-Stack TypeScript | Expert | End-to-end type safety |
| Database Design | Advanced | PostgreSQL, RLS, procedures |
| Code Generation | Advanced | PlopJS automation |
| Architecture | Senior | Scalable, maintainable |
| Performance | Advanced | ETag caching, SWR |
| Security | Advanced | RLS, validation, auth |
| MMO Architecture | Intermediate | Game systems design |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend Layer โ
โ React 18+ โ TypeScript โ Jotai โ SWR โ TailwindCSS โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
API Layer
โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend Layer โ
โ Next.js API Routes โ Auth.js โ Zod Validation โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Database Layer โ
โ PostgreSQL 17 โ RLS โ Procedures โ PL/pgSQL โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Temat | Insight |
|---|---|
| Database-driven dev | Zmniejsza boilerplate o 90% |
| Code generation | Zmienia produktywnoลฤ |
| Type safety | Od bazy do UI - game-changer |
| PostgreSQL logic | Lepsze niลผ client-side |
| Atom state mgmt | Elegancki i efektywny |
# Instalacja zaleลผnoลci
npm install
# Uruchomienie development
npm run dev
# Code generation
npx run plopProjekt demonstruje zaawansowanฤ wiedzฤ z zakresu:
- โ Full-Stack TypeScript Development
- โ Database Architecture & Optimization
- โ Code Generation & Automation (PlopJS)
- โ MMO Game Architecture & Systems
- โ Production-Ready Code Quality
- โ Performance Optimization
- โ Security Best Practices