Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ type Mutation {

---

## Running the project

- **Frontend:** see [`frontend/README.md`](frontend/README.md).
- **Backend:** see [`server/README.md`](server/README.md) (GraphQL API, dataset import, tests).

---

## Accessibility

Expand Down
3 changes: 2 additions & 1 deletion docs/ai-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ This file documents how we use AI tools in the project.

| Tool | Used for | How we checked the output |
| --- | --- | --- |
| Claude (Anthropic) / Opus 5.5 (medium)| Refactoring our written specification into a structured README format. | The group wrote the content and made all decisions: app idea, dataset, data model, functionality and tech stack. We reviewed the result against our own notes and the project requirements, and corrected inconsistencies before committing. |
| Claude (Anthropic) / Opus 5.5 (medium)| Refactoring our written specification into a structured README format. | The group wrote the content and made all decisions: app idea, dataset, data model, functionality and tech stack. We reviewed the result against our own notes and the project requirements, and corrected inconsistencies before committing. |
| Claude (Anthropic) / Sonnet 5 | Scaffolding the backend (`server/`): project setup, Mongoose schema/index design, the `averageScore`/`reviewCount` recompute strategy for ratings, the CSV ingestion script, GraphQL resolvers, and integration tests. Database choice (MongoDB) was decided by the group. | We reviewed the generated code against the README's data model and functionality requirements, checked proposed package versions for compatibility, and verified behavior by running the backend locally against Apollo Sandbox and the automated test suite before committing. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PORT=3001
MONGODB_URI=mongodb://127.0.0.1:27017/game-review-dev
NODE_ENV=development
28 changes: 28 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*

node_modules
dist
*.local

# Env
.env

# Dataset (user-downloaded, not committed)
data/raw/*.csv

# Test coverage
coverage

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Empty file added server/.prettierignore
Empty file.
1 change: 1 addition & 0 deletions server/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
55 changes: 55 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Backend - NTNU Game Review

GraphQL API (Apollo Server + Node/TypeScript) backed by MongoDB. See the root [README](../README.md) for the full project spec.

## Setup

1. Install dependencies: `npm install`
2. Copy the env file: `cp .env.example .env` (defaults already work with a local MongoDB on the default port)
3. Make sure MongoDB is running locally (`mongod`), or point `MONGODB_URI` in `.env` at a MongoDB Atlas free-tier cluster instead.

## Dataset import

The Kaggle ["100,000 Video Game Dataset"](https://www.kaggle.com/datasets/onlypythondatasheet/100000-video-game-dataset-with-records) CSV is not committed to the repo (too large, and gitignored). To seed the database:

1. Download the CSV from Kaggle.
2. Place it at `server/data/raw/games.csv`.
3. Run `npm run import`. This clears the `Game` collection first by default (pass `--no-fresh` to append instead) and logs a summary of rows inserted/dropped.

## Running

- `npm run dev` - start the dev server with auto-reload (`tsx watch`), listening on `PORT` (default `3001`).
- `npm run build` / `npm start` - compile and run the production build.

Once running, open the printed URL (Apollo Sandbox) and try:

```graphql
query {
games(search: "mario", limit: 5) {
games { id name averageScore }
totalCount
hasMore
}
}
```

```graphql
mutation {
rateGame(gameId: "<a real id from the query above>", userId: "test-user-1", score: 8) {
averageScore
reviewCount
}
}
```

Call `rateGame` again with the same `userId` and a different `score` - it should update the existing review rather than create a second one (confirm via `myReviews(userId: "test-user-1")`, which should return exactly one result).

## Tests

`npm test` runs integration tests against an in-memory MongoDB (`mongodb-memory-server`), covering the `games` query (search/sort/pagination) and the `rateGame` mutation (create, update-in-place, multi-user averaging, input validation).

If you already have MongoDB installed locally, set `MONGOMS_SYSTEM_BINARY` to its `mongod` binary path to skip `mongodb-memory-server`'s first-run binary download.

## Not yet in scope

Production deployment (Apache reverse proxy to port 3001, MongoDB installed directly on the VM) is a later step and not covered by this backend bootstrap.
16 changes: 16 additions & 0 deletions server/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import prettier from 'eslint-config-prettier'
import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.ts'],
extends: [js.configs.recommended, tseslint.configs.recommended, prettier],
languageOptions: {
globals: globals.node,
},
},
])
Loading