How abneeeees/pewpew works
Purpose and Runtime
PewPew is a Next.js gaming community application for browsing external game data, searching games, and providing authenticated user-facing areas such as collections, community, and profile. It runs as a TypeScript Next.js app, deployable on Vercel (vercel.json), with Bun/npm lockfiles present. RAWG is the external game-data provider, configured through .env.example.
Application Entry and Route Structure
The App Router root establishes global document styling and shared application structure in app/layout.tsx, with the landing route at app/page.tsx. Feature routes are server/client page compositions:
• Game discovery and details: app/games/page.tsx, app/games/[games]/page.tsx
• User-oriented areas: app/collections/page.tsx, app/community/page.tsx, app/profile/page.tsx
• Authentication screen: app/(Auth)/login/page.tsx
Shared Shell and Presentation Boundary
components/AppShell.tsx is the likely application-frame boundary around route content. Global navigation, search access, and user state presentation are separated into components/Global/Header.tsx, components/Global/Sidebar.tsx, and components/Global/SearchBar.tsx. Game pages compose focused UI units rather than embedding all rendering in routes: components/Games/GameGrid.tsx, components/Games/GameDetailsClient.tsx, and components/Games/FilterBar.tsx.
Game Data Acquisition and Search
The data layer is centralized under lib, notably lib/Data.ts and lib/types.ts, and should isolate RAWG request/response handling from pages and components. Search is exposed as a server API boundary at app/api/search/route.ts; UI search should call this endpoint rather than directly coupling browser components to RAWG. Game detail routing uses the dynamic segment in app/games/[games]/page.tsx.
Authentication and Identity
Authentication is implemented with NextAuth route handling in app/api/auth/[...nextauth]/route.ts, backed by shared auth definitions in app/auth.ts and lib/auth.ts. A separate registration endpoint exists at app/api/auth/signup/route.ts. Login UI and sign-out presentation are isolated in components/Auth/Login.tsx and components/Auth/SignOut.tsx, keeping credential/session mechanics behind API and auth-module boundaries.
Persistence and Prisma
Prisma is the database integration boundary: schema and migration history live in prisma/schema.prisma and prisma/migrations/20260717155527_add_search_vector/migration.sql; the reusable client is lib/prisma.ts. Generated Prisma code includes identity/session models and a GameSearch model under src/generated/prisma/models/, indicating persisted auth state plus a search-oriented game index. The search-vector migration suggests database-backed search can complement or cache RAWG-derived game information.
Scheduled Synchronization
app/api/cron/sync-games/route.ts is the scheduled ingestion/control point. It likely pulls game data from RAWG and updates the Prisma-backed game-search representation, separating background synchronization from request-time search and page rendering. Deployment scheduling is expected to be coordinated with vercel.json.
Primary Flow
A visitor enters through App Router pages and shared shell navigation. Game browsing either fetches through the data layer or invokes the search API; game details resolve from the dynamic game route. Background sync populates searchable persisted data. Authentication routes establish sessions stored through the Prisma identity models, enabling personalized collections/profile experiences without exposing database or provider logic to UI components.
Main entry points: layout.tsx App Router · prisma.ts Prisma client · page.tsx Game browse & detail · route.ts Game sync cron
Components 19
App UI
- App Router · Page routes compose server and client features.
app/layout.tsx - Landing page
app/page.tsx - Game browse & detail · Browse route and dynamic game detail route.
app/games/[games]/page.tsx - Member areas · Collections, community, and profile pages.
app/collections/page.tsx - Login route
app/(Auth)/login/page.tsx - Application shell · Frames route content and shared navigation.
components/AppShell.tsx - Header, sidebar & search · Global navigation, search entry, and user-state presentation.
components/Global/SearchBar.tsx - Game UI components · Grid, filters, and client-side detail presentation.
components/Games/GameDetailsClient.tsx - Login & sign-out UI
components/Auth/Login.tsx
Server APIs & Data
- Search API · Browser-safe search boundary.
app/api/search/route.ts - Game data layer · Isolates RAWG request and response handling.
lib/Data.ts - Game sync cron · Ingests external games into the local search index.
app/api/cron/sync-games/route.ts - RAWG
Identity & Persistence
- NextAuth handler
app/api/auth/[...nextauth]/route.ts - Signup API
app/api/auth/signup/route.ts - Auth definitions · Shared session and credential configuration.
app/auth.ts - Prisma client
lib/prisma.ts - Prisma database · Stores auth state and the GameSearch index.
prisma/schema.prisma
Other components
- Vercel · Hosts routes and scheduled execution.
vercel.json
Connections 21
- App Router → Landing page: serves
- App Router → Game browse & detail: serves
- App Router → Member areas: serves
- App Router → Login route: serves
- App Router → Application shell: uses
- Application shell → Header, sidebar & search: contains
- Game browse & detail → Game UI components: composes
- Header, sidebar & search → Search API: searches via
- Game browse & detail → Game data layer: loads games
- Search API → Prisma client: queries index
- Game data layer → RAWG: requests
- Game sync cron → Game data layer: fetches through
- Game sync cron → Prisma client: upserts
- Prisma client → Prisma database: persists
- Login route → Login & sign-out UI: renders
- Login & sign-out UI → NextAuth handler: authenticates via
- NextAuth handler → Auth definitions: uses
- Signup API → Prisma client: creates identity
- Auth definitions → Prisma client: stores sessions
- Vercel → App Router: deploys
- Vercel → Game sync cron: schedules