Database

This project uses MongoDB with Mongoose ODM for data storage.

Connection

The database connection is established using the MONGODB_URI environment variable.

MONGODB_URI="mongodb://localhost:27017/shipquick"

Mongoose Models

Models are defined using Mongoose schemas. We have pre-configured models for common SaaS requirements.

For detailed documentation on the available models, see Database Models.

Available Models

  • User: Handles authentication and user profile data.
  • Subscription: Manages billing and access control (integrated with Polar.sh).

Usage

You can use these models in your API routes or server functions:

import { User } from '@/lib/db/models/User';

// Find a user
const user = await User.findOne({ email: 'test@example.com' });

// Create a user
await User.create({
  email: 'new@example.com',
  name: 'New User',
});

Seeding Data

A seed script is available to populate your database with initial data.

pnpm run seed

See scripts/seed.ts for the implementation.