A modern web application built with Next.js, tRPC, Tailwind CSS, and MongoDB for data persistence.
- Next.js - React framework with App Router
- tRPC - End-to-end typesafe APIs
- Tailwind CSS - Utility-first CSS framework
- MongoDB - Document database with Mongoose ODM
- TypeScript - Type safety across the stack
- Bun - Fast JavaScript runtime and package manager
-
Install dependencies:
bun install
-
Set up environment variables:
- Configure your MongoDB connection string in
.env
- Configure your MongoDB connection string in
-
Start the development server:
bun run dev
-
Seed the database (optional):
bun run seed
The application will be available at http://localhost:3000.
This setup includes MongoDB and handles all dependencies automatically.
-
Start all services:
bun run docker:up
-
Seed the database:
bun run docker:seed
-
Stop all services:
bun run docker:stop
The application will be available at http://localhost:3001.
bun run dev- Start development server with Turbobun run build- Build the application for productionbun run start- Start production serverbun run preview- Build and start production server
bun run seed- Seed the database with sample data
bun run docker:up- Start MongoDB and web servicesbun run docker:seed- Run database seeding in Dockerbun run docker:dev- Start all services including seedingbun run docker:stop- Stop all Docker services
bun run lint- Run ESLintbun run lint:fix- Fix ESLint issues automaticallybun run typecheck- Run TypeScript type checkingbun run format:check- Check code formattingbun run format:write- Format code with Prettier
bun run test- Run Playwright testsbun run test:ui- Run Playwright tests with UI
├── src/
│ ├── app/ # Next.js App Router pages
│ ├── components/ # Reusable React components
│ ├── lib/ # Utility functions and configurations
│ ├── models/ # MongoDB/Mongoose models
│ ├── server/ # tRPC server setup and routers
│ └── env.js # Environment variable validation
├── scripts/
│ ├── seed.ts # Database seeding script
│ └── metrics-seed-data.json
├── docker-compose.yml
├── Dockerfile # Production build
└── Dockerfile.seed # Database seeding container
Create a .env file in the root directory with the following variables:
# Database Connection (Required)
MONGODB_URI="mongodb://admin:password@localhost:27017/asm2?authSource=admin"
# Application Environment (Required)
NODE_ENV="development"# MongoDB Configuration (Used by Docker Compose)
MONGODB_USER="admin"
MONGODB_PASSWORD="password"
MONGODB_DATABASE="asm2"
# Development Settings
SKIP_ENV_VALIDATION="false"- MONGODB_URI: Complete MongoDB connection string. Required for database connectivity.
- NODE_ENV: Application environment (
development,test, orproduction). Required. - MONGODB_USER: MongoDB username. Used by Docker Compose setup (defaults to
admin). - MONGODB_PASSWORD: MongoDB password. Used by Docker Compose setup (defaults to
password). - MONGODB_DATABASE: MongoDB database name. Used by Docker Compose setup (defaults to
asm2). - SKIP_ENV_VALIDATION: Skip environment variable validation during build. Useful for Docker builds (defaults to
false).
MONGODB_URI="mongodb://localhost:27017/asm2"
NODE_ENV="development"MONGODB_USER="admin"
MONGODB_PASSWORD="your-secure-password"
MONGODB_DATABASE="asm2"
NODE_ENV="development"The project includes two Docker setups:
- Main Application (
Dockerfile): Optimized production build with standalone output - Database Seeding (
Dockerfile.seed): Separate container for running database migrations and seeding
The docker-compose setup automatically:
- Starts MongoDB with persistent data
- Builds and runs the Next.js application
- Configures networking between services
- Provides health checks for reliable startup
