Skip to content

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

BuildOps Backend

Overview

BuildOps Backend is an enterprise-grade facility maintenance management platform designed to streamline operations in multi-tenant buildings. By providing a centralized system for complaint reporting, task assignment, and real-time tracking, BuildOps eliminates the inefficiencies of manual follow-ups and scattered communication channels. Building owners, office staff, and maintenance workers can collaborate seamlessly to ensure facilities run smoothly.

Features

  • Multi-Tenant Architecture: Single database deployment with strict per-tenant data isolation using discriminator columns (tenantId), enabling cost-effective scalability while maintaining data security.
  • Role-Based Access Control (RBAC):
    • Admins: Full system control including tenant management, user administration, and system configuration.
    • Office Staff: Submit maintenance complaints, track request status, and view resolution history.
    • Workers: Access assigned tasks, update work progress, and mark completion status.
  • Complaint Management: Comprehensive lifecycle tracking from submission through resolution with audit trails and status updates.
  • Task Scheduling & Notifications: Intelligent worker assignment with automated email notifications via Resend API for task updates and deadlines.
  • RESTful API Architecture: Well-structured endpoints following REST principles for seamless integration with frontend applications.
  • Technology Stack:
    • Backend Framework: NestJS - Enterprise-ready Node.js framework
    • ORM: Prisma - Type-safe database client with migrations
    • Database: PostgreSQL - Robust relational database
    • Authentication: JWT-based token authentication (ACCESS_TOKEN)
    • Email Service: Resend API for transactional notifications

Requirements

Ensure you have the following installed and properly configured:

  • Node.js (version 16 or later)
  • PostgreSQL (version 12 or later, configured and running)
  • npm or yarn (Package Manager)

Installation

  1. Clone the repository:
   git clone https://github.com/your-repo/buildops-backend.git
   cd buildops-backend
  1. Install dependencies:
   npm install
  1. Configure environment variables: Create a .env file in the root directory with the following:
   # Database
   DATABASE_URL=postgresql://username:password@localhost:5432/buildops

   # Authentication
   ACCESS_TOKEN=your_secure_jwt_secret
   JWT_EXPIRATION=7d

   # Email Service
   RESEND_API_KEY=your_resend_api_key

   # Application
   PORT=3000
   NODE_ENV=development
  1. Generate Prisma client:
   npx prisma generate
  1. Run database migrations:
   npx prisma migrate dev
  1. Seed initial data (optional):
   npm run seed

Running the Application

Development Mode

npm run start:dev

Production Mode

npm run build
npm run start:prod

Watch Mode

npm run start:debug

The server runs on port 3000 by default (configurable via .env).

API Documentation

Once the server is running, access the API documentation at:

  • Swagger UI: http://localhost:3000/api/docs

Key Endpoints

  • Authentication: /auth/login, /auth/register
  • Tenants: /tenants (Admin only)
  • Users: /users (Tenant-scoped)
  • Complaints: /complaints (Create, track, update)
  • Tasks: /tasks (Worker assignments and status)

Note: All API requests require:

  • Valid JWT token in Authorization header: Bearer <token>
  • Valid tenantId in request context for proper data isolation

Project Structure

src/
├── auth/              # Authentication module
├── tenants/           # Tenant management
├── users/             # User management with RBAC
├── complaints/        # Complaint lifecycle management
├── tasks/             # Task assignment and tracking
├── common/            # Shared utilities, guards, decorators
├── prisma/            # Database schema and migrations
└── main.ts            # Application entry point

Testing

# Unit tests
npm run test

# E2E tests
npm run test:e2e

# Test coverage
npm run test:cov

Database Management

# Create new migration
npx prisma migrate dev --name migration_name

# Reset database (⚠️ destroys data)
npx prisma migrate reset

# Open Prisma Studio (Database GUI)
npx prisma studio

Security Features

  • JWT-based authentication with secure token generation
  • Password hashing using bcrypt
  • Tenant data isolation at database query level
  • Role-based authorization guards
  • Input validation using class-validator
  • SQL injection prevention via Prisma parameterized queries

Contributing

We welcome contributions! Follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature-name
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to your branch: git push origin feature/your-feature-name
  5. Open a pull request

Please ensure your code:

  • Follows the existing code style
  • Includes appropriate tests
  • Updates documentation as needed

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For issues, questions, or feature requests:


Built with ❤️ using NestJS

About

Multi-tenant facility maintenance platform. Complaints, task assignments, and real-time tracking across roles (Admin, Staff, Worker). Built with NestJS, Prisma and PostgreSQL, with JWT auth, RBAC, and automated email notifications via Resend.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages