Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/igorek05m/daily-geogame/llms.txt

Use this file to discover all available pages before exploring further.

Environment variables

Daily GeoGame uses environment variables to configure the application. Create a .env.local file in the root directory of your project:
touch .env.local

Required variables

MONGODB_URI

The MongoDB connection string is the only required environment variable:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database?retryWrites=true&w=majority
Never commit your .env.local file to version control. It should be listed in .gitignore.

MongoDB Atlas setup

Daily GeoGame uses MongoDB Atlas for data storage. Follow these steps to set up your database:
1

Create a MongoDB Atlas account

Sign up for a free account at MongoDB Atlas.
2

Create a new cluster

Create a new cluster (the free M0 tier is sufficient for development and small deployments).
3

Configure network access

Add your IP address to the IP Access List, or allow access from anywhere (0.0.0.0/0) for development.
For production, restrict access to specific IP addresses or use VPC peering.
4

Create database user

Create a database user with read and write permissions. Save the username and password.
5

Get connection string

Click “Connect” on your cluster, choose “Connect your application”, and copy the connection string. Replace <password> with your database user password.
6

Add to .env.local

Paste the connection string into your .env.local file:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/geogame?retryWrites=true&w=majority

MongoDB connection handling

The application handles MongoDB connections through app/lib/mongodb.ts:
import { MongoClient } from 'mongodb';

const uri = process.env.MONGODB_URI;

let client: MongoClient;
let clientPromise: Promise<MongoClient>;

if (!uri) {
  console.warn("WARN: Missing MONGODB_URI environment variable");
  clientPromise = Promise.reject(new Error("Missing MONGODB_URI"));
} else {
  try {
    client = new MongoClient(uri);
    clientPromise = client.connect();
  } catch (e) {
    console.error('Failed to initialize MongoDB client', e);
    clientPromise = Promise.reject(e);
  }
}

export default clientPromise;
If MONGODB_URI is missing, the application will log a warning but won’t crash. However, database-dependent features won’t work.

Next.js configuration

The Next.js configuration is minimal by default (next.config.ts):
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
};

export default nextConfig;
You can customize this file to add:
  • Image optimization domains
  • Custom headers
  • Redirects and rewrites
  • Experimental features

TypeScript configuration

The project uses strict TypeScript settings (tsconfig.json):
{
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}
Key features:
  • Strict mode enabled for better type safety
  • Path alias @/* for cleaner imports
  • ES2017 target for modern JavaScript features

Development vs production settings

Development

For local development:
.env.local
MONGODB_URI=mongodb+srv://dev-user:password@dev-cluster.mongodb.net/geogame-dev?retryWrites=true&w=majority
  • Use a separate development database
  • Allow broader network access (0.0.0.0/0)
  • Enable detailed error messages

Production

For production deployment:
MONGODB_URI=mongodb+srv://prod-user:password@prod-cluster.mongodb.net/geogame?retryWrites=true&w=majority
  • Use a dedicated production database
  • Restrict network access to your deployment platform’s IP ranges
  • Use strong, unique passwords
  • Enable MongoDB Atlas monitoring and alerts
Consider using different MongoDB clusters for development and production to avoid accidental data corruption.

Environment variable validation

To ensure your environment is configured correctly:
  1. Start the development server
  2. Check the console for warnings:
    • WARN: Missing MONGODB_URI environment variable - Add the variable to .env.local
    • Failed to initialize MongoDB client - Check your connection string format

Next steps

After configuration, you can:
  • Start developing locally with pnpm dev
  • Proceed to Deployment when ready to go live

Build docs developers (and LLMs) love