Skip to content

daniseguraf/my-buildings

Repository files navigation

🏒 My Buildings - Building Management System

A modern, fullstack building management platform built with cutting-edge technologies

TypeScript NestJS React Prisma PostgreSQL pnpm

Features β€’ Tech Stack β€’ Getting Started β€’ Architecture β€’ Roadmap

πŸ‘€ Author

Daniel Segura


🎯 Overview

My Buildings is a fullstack building management application designed to simplify property administration. It includes authentication, authorization, and a modern UI, showcasing end-to-end feature delivery and real-world business logic.

Highlights

  • Fullstack TypeScript – React + Node.js with shared types
  • Authentication & RBAC – JWT with role-based access
  • Scalable Architecture – Monorepo structure and clean separation of concerns
  • Modern UI – Responsive interface built with Mantine
  • Production Ready – Deployed on Vercel (frontend) and Railway (backend)
  • Dockerized DB – Easy local setup and deployment

✨ Core Features

  • πŸ” Authentication & Authorization

    • JWT authentication and secure session handling
    • Role-based access (Admin, Manager, Resident)
    • Protected routes and API endpoints
    • Login / Logout flows
  • 🏒 Building Management

    • Full CRUD operations for buildings
    • Property type classification (Residential, Commercial, Mixed)
    • Detailed infor (floors, address, contact data)
    • Role-based permissions for building operations
  • πŸ›οΈ Common Areas

    • CRUD operations for common areas
    • Capacity management and active/inactive status
    • Association with specific buildings
    • Operating hours configuration
  • πŸ“… Reservation System

    • Date and time booking
    • Automatic operating-hours validation
    • Overlap prevention system
    • Maximum duration enforcement
    • Reservation statuses (Confirmed, Cancelled, On Review, Finished)
    • View and manage personal reservations

Next Improvements

  • 🎫 Maintenance ticket system
  • πŸ“Š Analytics dashboard
  • πŸ“§ Email notifications
  • πŸ“„ PDF report generation for buildings and reservations
  • πŸ§ͺ Testing coverage

πŸ“Έ Screenshots

Login Page

Secure authentication with JWT tokens

Login Page

Buildings List

Manage all your buildings in one place

Buildings List

Building Detail View

Detailed common areas list

Building Details

Amenities

Building Details

Building general information

Building Details

Create new building form

Building Details

Create new common area form

Building Details

Reservations Page

Reservations

Reservations Calendar

Reservations

My reservations lists

Reservations

Create reservation form

Reservations

Manage Reservations

Manage Reservations

Dark Theme

Buildings page

Buildings List Dark Theme

Building detail page dark theme

Building Details


πŸ› οΈ Tech Stack

Backend

  • NestJS - Progressive Node.js framework for scalable server-side applications
  • Prisma - Next-generation ORM for type-safe database access
  • PostgreSQL - Advanced open-source relational database
  • pdfmake - Client/server-side PDF printing
  • Swagger/OpenAPI - API documentation and type generation
  • class-validator - Decorator-based validation

Frontend

  • React 19 - Latest React with React Compiler for automatic optimization
  • Mantine UI - Comprehensive React component library
  • TanStack Query - Powerful data synchronization and caching
  • React Router 7 - Modern routing solution
  • Zod - TypeScript-first schema validation
  • Axios - Promise-based HTTP client
  • Vite - Next-generation frontend tooling

DevOps & Tools

  • pnpm - Fast, disk space efficient package manager
  • Docker - Containerization platform
  • TypeScript - Static type checking
  • ESLint - Code quality and consistency
  • Prettier - Code formatting

πŸ—οΈ Architecture

Monorepo Structure

my-buildings/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ backend/                # NestJS API server
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/         # Authentication module (JWT, Guards, Strategies)
β”‚   β”‚   β”‚   β”œβ”€β”€ buildings/    # Buildings CRUD module
β”‚   β”‚   β”‚   β”œβ”€β”€ common-areas/ # Common areas module
β”‚   β”‚   β”‚   β”œβ”€β”€ reservations/ # Reservations system
β”‚   β”‚   β”‚   β”œβ”€β”€ seed/         # Database seeding
β”‚   β”‚   β”‚   β”œβ”€β”€ printer/      # PDF generation service
β”‚   β”‚   β”‚   β”œβ”€β”€ prisma/       # Database service
β”‚   β”‚   β”‚   β”œβ”€β”€ config/       # Environment configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ common/       # Shared decorators & validators
β”‚   β”‚   β”‚   └── main.ts       # Application entry point
β”‚   β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   β”‚   β”œβ”€β”€ schema.prisma # Database schema
β”‚   β”‚   β”‚   └── migrations/   # Database migrations
β”‚   β”‚   β”œβ”€β”€ fonts/            # Fonts for PDF generation
β”‚   β”‚   └── test/             # E2E tests
β”‚   β”‚
β”‚   β”œβ”€β”€ frontend/             # React application
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ app/          # App configuration & routes
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ layouts/  # Layout components
β”‚   β”‚   β”‚   β”‚   └── routes/   # Route definitions
β”‚   β”‚   β”‚   β”œβ”€β”€ features/     # Feature-based modules
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth/     # Authentication (Login, Context)
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ buildings/    # Buildings & Common Areas
β”‚   β”‚   β”‚   β”‚   └── reservations/ # Reservation system
β”‚   β”‚   β”‚   β”œβ”€β”€ components/   # Shared UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ hooks/        # Custom React hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ lib/          # Axios & QueryClient configs
β”‚   β”‚   β”‚   β”œβ”€β”€ utils/        # Helper functions
β”‚   β”‚   β”‚   └── theme.ts      # Mantine theme configuration
β”‚   β”‚   └── public/           # Static assets
β”‚   β”‚
β”‚   └── shared/               # Shared types between FE & BE
β”‚       └── src/
β”‚           └── types/        # Generated TypeScript types
β”‚
β”œβ”€β”€ docs/
β”‚   └── screenshots/          # Application screenshots
β”œβ”€β”€ docker-compose.yaml       # Docker services configuration
└── pnpm-workspace.yaml       # Monorepo workspace config

Design Patterns & Best Practices

  • Module-based architecture in NestJS for separation of concerns
  • Feature-based structure in React for scalability
  • Type generation from OpenAPI specs for type safety across FE/BE
  • Repository pattern with Prisma for data access
  • DTO validation with class-validator decorators
  • Error handling with global exception filters
  • API versioning for backward compatibility
  • Soft deletes for data integrity

πŸš€ Getting Started

Prerequisites

  • Node.js >= 18.x
  • pnpm >= 10.23
  • Docker & Docker Compose (for database)
  • PostgreSQL 14+ (or use Docker)

Installation

  1. Clone the repository
git clone https://github.com/daniseguraf/my-buildings.git
cd my-buildings
  1. Install dependencies
pnpm install
  1. Set up environment variables

Create a .env file in the packages/backend directory:

# Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/my_buildings?schema=public"
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=my_buildings

# Server
PORT=3000
NODE_ENV=development
  1. Start the database
docker-compose up -d
  1. Run database migrations
cd packages/backend
pnpm migrate
  1. Generate Prisma client and types
cd packages/backend
pnpm generate

Running the Application

Development Mode

Run both frontend and backend concurrently:

# From root directory
pnpm dev

Or run them separately:

# Backend only (http://localhost:3000)
pnpm dev:backend

# Frontend only (http://localhost:5173)
pnpm dev:frontend

Production Build

# Build all packages
pnpm build

# Build individually
pnpm build:backend
pnpm build:frontend

# Start production server
cd packages/backend
pnpm start:prod

πŸ“‘ API Documentation

Once the backend is running, access the interactive API documentation:

Key Endpoints

Authentication (/api/v1/auth)

  • POST /auth/register - Register new user
  • POST /auth/login - Login and get JWT token
  • GET /auth/me - Get current user profile
  • GET /auth/check-auth-status - Verify authentication status

Buildings (/api/v1/buildings)

  • GET /buildings - List all buildings (with filters)
  • POST /buildings - Create a new building (Admin/Manager)
  • GET /buildings/:id - Get building details
  • PATCH /buildings/:id - Update building (Admin/Manager)
  • DELETE /buildings/:id - Soft delete building (Admin)
  • PATCH /buildings/:id/restore - Restore deleted building (Admin)

Common Areas (/api/v1/common-areas)

  • GET /common-areas/building/:buildingId - List areas by building
  • POST /common-areas - Create common area (Manager)
  • GET /common-areas/:id - Get area details
  • PATCH /common-areas/:id - Update common area (Manager)
  • DELETE /common-areas/:id - Delete common area (Manager)

Reservations (/api/v1/reservations)

  • POST /reservations - Create new reservation (Resident)
  • GET /reservations/building - Get reservations by resident's building
  • DELETE /reservations/:id - Cancel reservation (Resident/Admin)

Seed (/api/v1/seed)

  • GET /seed - Populate database with test data (Development only)

πŸ“ˆ Database Schema

The application uses PostgreSQL with Prisma ORM. The schema includes:

Core Entities

  • User: Application users with role-based access (Admin, Manager, Resident)

    • Authentication credentials (email, password)
    • Role assignment and building association
    • Relationship with reservations and managed buildings
  • Building: Core entity for property management

    • Property information (name, address, type, year built)
    • Soft delete support with deletedAt field
    • Amenities (parking, security, elevator, etc.)
  • CommonArea: Shared spaces within buildings

    • Type classification (Gym, Pool, Event Room, etc.)
    • Capacity and availability management
    • Operating hours and days configuration
    • Maximum reservation duration rules
  • Reservation: Booking system for common areas

    • Time slot management with overlap prevention
    • Status tracking (In Review, Confirmed, Cancelled, Finished)
    • User and common area associations
    • Attendees count and notes

Key Relationships

User (Manager) ──< manages >── Building
User (Resident) ──< lives in >── Building
Building ──< has >── CommonArea
User ──< makes >── Reservation
CommonArea ──< has >── Reservation

For detailed schema, see packages/backend/prisma/schema.prisma


πŸ—ΊοΈ Roadmap

See ROADMAP.md for detailed development plan.

Upcoming Features:


🎯 What This Project Demonstrates

Backend Skills

  • βœ… NestJS with modular architecture and dependency injection
  • βœ… Prisma ORM with complex relationships and migrations
  • βœ… Complete JWT authentication (Strategy, Guards, Decorators)
  • βœ… Complex business validations (no-overlapping reservations)
  • βœ… DTOs with class-validator for request validation
  • βœ… RESTful API design with proper HTTP methods
  • βœ… Proper error handling with custom exceptions
  • βœ… Database seeders for test data
  • βœ… Soft deletes for data integrity
  • βœ… Role-based authorization at endpoint level

Frontend Skills

  • βœ… React 19 with TypeScript and strict type checking
  • βœ… Context API for global state management
  • βœ… TanStack Query for data fetching, caching, and mutations
  • βœ… Mantine UI for modern component library
  • βœ… Complex forms with real-time validation
  • βœ… Protected routes with role-based access control
  • βœ… Axios interceptors for authentication
  • βœ… Feature-based scalable architecture
  • βœ… Custom hooks for reusable logic
  • βœ… Loading states, error handling, and empty states

DevOps Skills

  • βœ… Monorepo structure with pnpm workspaces
  • βœ… Docker Compose for local development
  • βœ… Deployment on Railway (backend + PostgreSQL)
  • βœ… Deployment on Vercel (frontend)
  • βœ… Environment variables per environment
  • βœ… Automatic CI/CD with GitHub integration
  • βœ… CORS configuration for production
  • βœ… Database migrations in production

Releases

No releases published

Packages

 
 
 

Contributors