Skip to content

george-taschina/nest-nuxt-demo

Repository files navigation

Nuxt 3 + NestJS Monorepo Project

A full-stack application with Nuxt 3 frontend and NestJS backend in a monorepo setup.

🚀 Prerequisites

  • Docker
  • Node.js >20.x
  • npm (version compatible with Node 20+)
  • Make (optional, but recommended for command shortcuts)

⚙️ Environment Setup

  1. Clone the repository

  2. Copy environment files:

    cp packages/backend/.env.example packages/backend/.env
    cp packages/frontend/.env.example packages/frontend/.env
  3. Update the environment variables in both .env files as needed

  4. run npm install

🛠️ Getting Started

Initial Setup

make setup       # Install dependencies and build Docker images
make start       # Start all services in Docker containers
make create-db   # Create and initialize database

Development Modes

Option 1: Docker Containers (Production-like)

Warning

The version of nuxt/image package used in this project has some problems while running in containers or production build, for development it is advisable to use Local Development approach

Run the following commands to start the env in the containers:

make start-api-dev
make start-fe-dev
  • Access application at http://localhost:8000
  • API available at http://localhost:3000

Option 2: Local Development

npm run backend:start:dev     # Start NestJS in dev mode
npm run frontend:start:dev    # Start Nuxt 3 in dev mode
  • Frontend: http://localhost:8000
  • Backend: http://localhost:3000

📚 API Documentation

When running the backend in development mode, Swagger UI is automatically available at:
http://localhost:3000/docs

Warning

The docs page could render blank, if that's the case copy the json from http://localhost:3000/docs-json and paste it in https://editor.swagger.io/ to view the documentation

This interactive documentation provides:

  • All available API endpoints
  • Request/response schemas
  • Direct testing capabilities for endpoints

Note: Swagger is only enabled in development mode. To access it:

  1. Ensure you're running the backend with npm run backend:start:dev
  2. Open the Swagger UI in your browser at the provided URL

📜 Architecture Decision Records (ADR)

You can find the Architecture Decision Records (ADR) for this project in the /docs/adr directory. These documents provide insights into the architectural decisions made throughout the project.

🧪 Testing

Unit Tests

npm run backend:test
npm run frontend:test

E2E Tests

make create-db              # Ensure clean database
npm run backend:test:e2e    # Run end-to-end tests

📂 Project Structure

.
├── packages
│ ├── backend #NestJs Application
│ │ ├── apps
│ │ │ └── api #EntryPoint Backend
│ │ ├── libs
│ │ │ ├── core #Main module containing configs, loggers and database module
│ │ │ └── tour #Module containing the booking logic
│ │ │ ├── test #Backend Tests
│ │ ├── migrations #Migrations
│ │ ├── mikro-orm.config.ts #Config useful for mikro-orm CLI
│ │ ├── seeders #Seeders, also used for the env of e2e test
│ ├── frontend # Nuxt 3 Application
│ │ ├── components #Components
│ │ │ └── george #Basic components like buttons or inputs
│ │ ├── composables
│ │ ├── layouts
│ │ ├── pages
│ │ ├── stores
│ │ └── utils
│ └── shared # Shared directory for types of api calls

🛠️ Common Commands

Make Commands

make setup # Install dependencies and build containers
make start # Start all services
make create-db # Initialize database

NPM Scripts

# Frontend
npm run frontend:start:dev
npm run frontend:build
npm run frontend:start:prod

# Backend
npm run backend:start:dev
npm run backend:build
npm run backend:start:prod

# Testing
npm run backend:test
npm run frontend:test
npm run backend:test:e2e

🔧 Troubleshooting

  • Port Conflicts: Ensure Docker containers are stopped before running local dev servers
  • Database Issues: Run make create-db to reset the database
  • Docker Cleanup: Use make clean if encountering container issues

📄 License

MIT - See the LICENSE file for details


Note: For production deployment, ensure to build both applications and configure proper environment variables

About

A full-stack monorepo project using Nuxt 3 for the frontend and NestJS for the backend. It features Docker support, Swagger UI for API documentation, unit and E2E testing, and a well-structured codebase for both applications. Architecture Decision Records (ADR) are included to document key decisions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors