# abneeeees/pewpew architecture

> Architecture diagram of the GitHub repository abneeeees/pewpew, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abneeeees/pewpew
- Repository: https://github.com/abneeeees/pewpew

## Overview

#### 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: [`app/layout.tsx`](https://github.com/abneeeees/pewpew/blob/main/app/layout.tsx) (App Router), [`lib/prisma.ts`](https://github.com/abneeeees/pewpew/blob/main/lib/prisma.ts) (Prisma client), [`app/games/[games]/page.tsx`](https://github.com/abneeeees/pewpew/blob/main/app/games/%5Bgames%5D/page.tsx) (Game browse & detail), [`app/api/cron/sync-games/route.ts`](https://github.com/abneeeees/pewpew/blob/main/app/api/cron/sync-games/route.ts) (Game sync cron)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["App UI"]
  node_app_router["App Router<br/>Next.js routes<br/>[layout.tsx]"]
  node_landing["Landing page<br/>route<br/>[page.tsx]"]
  node_game_routes["Game browse &amp; detail<br/>dynamic routes<br/>[page.tsx]"]
  node_member_routes["Member areas<br/>routes<br/>[page.tsx]"]
  node_login_route["Login route<br/>[page.tsx]"]
  node_app_shell["Application shell<br/>shared UI<br/>[AppShell.tsx]"]
  node_global_navigation["Header, sidebar &amp; search<br/>shared UI<br/>[SearchBar.tsx]"]
  node_game_ui["Game UI components<br/>feature UI"]
  node_login_ui["Login &amp; sign-out UI<br/>auth UI<br/>[Login.tsx]"]
end

subgraph group_api["Server APIs &amp; Data"]
  node_search_api["Search API<br/>route handler<br/>[route.ts]"]
  node_game_data["Game data layer<br/>data module<br/>[Data.ts]"]
  node_sync_cron["Game sync cron<br/>scheduled route<br/>[route.ts]"]
  node_rawg{{"RAWG<br/>external game provider"}}
end

subgraph group_identity["Identity &amp; Persistence"]
  node_nextauth_api["NextAuth handler<br/>route handler<br/>[route.ts]"]
  node_signup_api["Signup API<br/>route handler<br/>[route.ts]"]
  node_auth_definitions["Auth definitions<br/>auth module<br/>[auth.ts]"]
  node_prisma_client["Prisma client<br/>database access<br/>[prisma.ts]"]
  node_prisma_database[("Prisma database<br/>identity and game index<br/>[schema.prisma]")]
end

node_vercel{{"Vercel<br/>deployment runtime<br/>[vercel.json]"}}

node_app_router -->|"serves"| node_landing
node_app_router -->|"serves"| node_game_routes
node_app_router -->|"serves"| node_member_routes
node_app_router -->|"serves"| node_login_route
node_app_router -->|"uses"| node_app_shell
node_app_shell -->|"contains"| node_global_navigation
node_game_routes -->|"composes"| node_game_ui
node_global_navigation -->|"searches via"| node_search_api
node_game_routes -->|"loads games"| node_game_data
node_search_api -->|"queries index"| node_prisma_client
node_game_data -->|"requests"| node_rawg
node_sync_cron -->|"fetches through"| node_game_data
node_sync_cron -->|"upserts"| node_prisma_client
node_prisma_client -->|"persists"| node_prisma_database
node_login_route -->|"renders"| node_login_ui
node_login_ui -->|"authenticates via"| node_nextauth_api
node_nextauth_api -->|"uses"| node_auth_definitions
node_signup_api -->|"creates identity"| node_prisma_client
node_auth_definitions -->|"stores sessions"| node_prisma_client
node_vercel -->|"deploys"| node_app_router
node_vercel -.->|"schedules"| node_sync_cron

click node_app_router "https://github.com/abneeeees/pewpew/blob/main/app/layout.tsx"
click node_landing "https://github.com/abneeeees/pewpew/blob/main/app/page.tsx"
click node_game_routes "https://github.com/abneeeees/pewpew/blob/main/app/games/%5Bgames%5D/page.tsx"
click node_member_routes "https://github.com/abneeeees/pewpew/blob/main/app/collections/page.tsx"
click node_login_route "https://github.com/abneeeees/pewpew/blob/main/app/(Auth)/login/page.tsx"
click node_app_shell "https://github.com/abneeeees/pewpew/blob/main/components/AppShell.tsx"
click node_global_navigation "https://github.com/abneeeees/pewpew/blob/main/components/Global/SearchBar.tsx"
click node_game_ui "https://github.com/abneeeees/pewpew/blob/main/components/Games/GameDetailsClient.tsx"
click node_login_ui "https://github.com/abneeeees/pewpew/blob/main/components/Auth/Login.tsx"
click node_search_api "https://github.com/abneeeees/pewpew/blob/main/app/api/search/route.ts"
click node_game_data "https://github.com/abneeeees/pewpew/blob/main/lib/Data.ts"
click node_sync_cron "https://github.com/abneeeees/pewpew/blob/main/app/api/cron/sync-games/route.ts"
click node_nextauth_api "https://github.com/abneeeees/pewpew/blob/main/app/api/auth/%5B...nextauth%5D/route.ts"
click node_signup_api "https://github.com/abneeeees/pewpew/blob/main/app/api/auth/signup/route.ts"
click node_auth_definitions "https://github.com/abneeeees/pewpew/blob/main/app/auth.ts"
click node_prisma_client "https://github.com/abneeeees/pewpew/blob/main/lib/prisma.ts"
click node_prisma_database "https://github.com/abneeeees/pewpew/blob/main/prisma/schema.prisma"
click node_vercel "https://github.com/abneeeees/pewpew/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_router,node_landing,node_game_routes,node_member_routes,node_login_route,node_app_shell,node_global_navigation,node_game_ui,node_login_ui toneBlue
class node_search_api,node_game_data,node_sync_cron,node_rawg toneAmber
class node_nextauth_api,node_signup_api,node_auth_definitions,node_prisma_client,node_prisma_database toneMint
class node_vercel toneNeutral
```

## Components

### App UI

- [App Router](https://github.com/abneeeees/pewpew/blob/main/app/layout.tsx): Next.js routes · Page routes compose server and client features. · `app/layout.tsx`
- [Landing page](https://github.com/abneeeees/pewpew/blob/main/app/page.tsx): route · `app/page.tsx`
- [Game browse & detail](https://github.com/abneeeees/pewpew/blob/main/app/games/%5Bgames%5D/page.tsx): dynamic routes · Browse route and dynamic game detail route. · `app/games/[games]/page.tsx`
- [Member areas](https://github.com/abneeeees/pewpew/blob/main/app/collections/page.tsx): routes · Collections, community, and profile pages. · `app/collections/page.tsx`
- [Login route](https://github.com/abneeeees/pewpew/blob/main/app/(Auth)/login/page.tsx): route · `app/(Auth)/login/page.tsx`
- [Application shell](https://github.com/abneeeees/pewpew/blob/main/components/AppShell.tsx): shared UI · Frames route content and shared navigation. · `components/AppShell.tsx`
- [Header, sidebar & search](https://github.com/abneeeees/pewpew/blob/main/components/Global/SearchBar.tsx): shared UI · Global navigation, search entry, and user-state presentation. · `components/Global/SearchBar.tsx`
- [Game UI components](https://github.com/abneeeees/pewpew/blob/main/components/Games/GameDetailsClient.tsx): feature UI · Grid, filters, and client-side detail presentation. · `components/Games/GameDetailsClient.tsx`
- [Login & sign-out UI](https://github.com/abneeeees/pewpew/blob/main/components/Auth/Login.tsx): auth UI · `components/Auth/Login.tsx`

### Server APIs & Data

- [Search API](https://github.com/abneeeees/pewpew/blob/main/app/api/search/route.ts): route handler · Browser-safe search boundary. · `app/api/search/route.ts`
- [Game data layer](https://github.com/abneeeees/pewpew/blob/main/lib/Data.ts): data module · Isolates RAWG request and response handling. · `lib/Data.ts`
- [Game sync cron](https://github.com/abneeeees/pewpew/blob/main/app/api/cron/sync-games/route.ts): scheduled route · Ingests external games into the local search index. · `app/api/cron/sync-games/route.ts`
- **RAWG**: external game provider

### Identity & Persistence

- [NextAuth handler](https://github.com/abneeeees/pewpew/blob/main/app/api/auth/%5B...nextauth%5D/route.ts): route handler · `app/api/auth/[...nextauth]/route.ts`
- [Signup API](https://github.com/abneeeees/pewpew/blob/main/app/api/auth/signup/route.ts): route handler · `app/api/auth/signup/route.ts`
- [Auth definitions](https://github.com/abneeeees/pewpew/blob/main/app/auth.ts): auth module · Shared session and credential configuration. · `app/auth.ts`
- [Prisma client](https://github.com/abneeeees/pewpew/blob/main/lib/prisma.ts): database access · `lib/prisma.ts`
- [Prisma database](https://github.com/abneeeees/pewpew/blob/main/prisma/schema.prisma): identity and game index · Stores auth state and the GameSearch index. · `prisma/schema.prisma`

### Other components

- [Vercel](https://github.com/abneeeees/pewpew/blob/main/vercel.json): deployment runtime · Hosts routes and scheduled execution. · `vercel.json`

## Connections

- 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
