AssetManagementPlatform

Property Management Platform

TypeScript Node.js React PostgreSQL Docker Express.js

A comprehensive Property Management Platform built with modern web technologies. Features a complete React frontend with TypeScript, Node.js/Express backend with layered architecture, PostgreSQL database, Google OAuth authentication, and comprehensive API documentation for managing rental properties, tenants, leases, and rent payments.

πŸš€ Free Hosting Deployment

Deploy your Asset Management Platform using GitHub’s free services!

🎯 What’s Free

πŸš€ Quick Deploy

  1. Enable GitHub Pages:
    • Go to Settings β†’ Pages
    • Set source to β€œGitHub Actions”
  2. Deploy Frontend (automatic on push to main):
    • Frontend deploys to: https://yourusername.github.io/repository-name
  3. Deploy Backend (choose one free service):
    • πŸš€ Render: render.com - 750 hours/month free
    • πŸƒ Railway: railway.app - $5/month credit
    • πŸͺΆ Fly.io: fly.io - 3 shared CPUs free

πŸ“‹ Setup Steps

  1. GitHub Pages: Automatic via GitHub Actions
  2. Backend: Connect your repo to chosen hosting service
  3. Database: Automatic with backend deployment
  4. Environment Variables: Set in hosting service dashboard

🌐 Live Demo URLs

For detailed instructions, see DEPLOYMENT.md.

πŸš€ Features

πŸ—οΈ Architecture

Backend Architecture (Layered Pattern with DI)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Controllers   β”‚ ← HTTP Layer (Express routes)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Services     β”‚ ← Business Logic Layer
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Repositories   β”‚ ← Data Access Layer
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Database     β”‚ ← PostgreSQL with pg library
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       ↑
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Dependency      β”‚
β”‚   Container     β”‚ ← Singleton DI container
β”‚  (Interfaces)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Frontend Architecture (Layered React Pattern)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Components    β”‚ ← UI Layer (Reusable components)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     Pages       β”‚ ← Route-level components
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     Hooks       β”‚ ← Business Logic Layer
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Services     β”‚ ← API Communication Layer
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Contexts     β”‚ ← Global State Management
β”‚                 β”‚
β”‚  Types & Utils  β”‚ ← Supporting Infrastructure
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Architectural Patterns

πŸ› οΈ Tech Stack

Frontend

Backend

DevOps & Tools

πŸ“ Project Structure

PropertyManagementPlatform/
β”œβ”€β”€ frontend/                 # React application with industrial-grade architecture
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/         # Authentication components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ PublicRoute.tsx
β”‚   β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ common/       # Generic components (Button, Input, Card, GoogleOAuthButton)
β”‚   β”‚   β”‚   β”œβ”€β”€ forms/        # Form components (LoginForm, RegisterForm, etc.)
β”‚   β”‚   β”‚   └── ui/           # UI-specific components
β”‚   β”‚   β”œβ”€β”€ pages/            # Route-level page components
β”‚   β”‚   β”‚   └── Dashboard.tsx # Main dashboard with property overview
β”‚   β”‚   β”œβ”€β”€ hooks/            # Custom React hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ useApi.ts     # API communication hook
β”‚   β”‚   β”‚   β”œβ”€β”€ useProperties.ts # Property management hook
β”‚   β”‚   β”‚   β”œβ”€β”€ useUsers.ts   # User management hook
β”‚   β”‚   β”‚   └── useGoogleOAuth.ts # Google OAuth integration hook
β”‚   β”‚   β”œβ”€β”€ services/         # API service functions
β”‚   β”‚   β”‚   β”œβ”€β”€ apiClient.ts  # Centralized API client
β”‚   β”‚   β”‚   β”œβ”€β”€ propertyService.ts # Property API operations
β”‚   β”‚   β”‚   β”œβ”€β”€ authService.ts # Authentication API operations
β”‚   β”‚   β”‚   └── userService.ts # User API operations
β”‚   β”‚   β”œβ”€β”€ contexts/         # React contexts for global state
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx     # Authentication state management
β”‚   β”‚   β”‚   β”œβ”€β”€ ThemeContext.tsx    # Theme management
β”‚   β”‚   β”‚   β”œβ”€β”€ NotificationContext.tsx # Notification system
β”‚   β”‚   β”‚   └── index.ts      # Context exports
β”‚   β”‚   β”œβ”€β”€ types/            # TypeScript type definitions
β”‚   β”‚   β”‚   β”œβ”€β”€ property.ts   # Property-related types
β”‚   β”‚   β”‚   β”œβ”€β”€ user.ts       # User-related types
β”‚   β”‚   β”‚   β”œβ”€β”€ api.ts        # API response types
β”‚   β”‚   β”‚   β”œβ”€β”€ common.ts     # Common/shared types
β”‚   β”‚   β”‚   └── index.ts      # Type exports
β”‚   β”‚   β”œβ”€β”€ constants/        # Configuration constants
β”‚   β”‚   β”œβ”€β”€ utils/            # Utility functions
β”‚   β”‚   β”œβ”€β”€ App.tsx           # Main app component with context providers
β”‚   β”‚   └── main.tsx          # Application entry point
β”‚   β”œβ”€β”€ public/               # Static assets
β”‚   └── package.json
β”œβ”€β”€ backend/                  # Express API server with layered architecture
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/      # HTTP request handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ propertyController.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ tenantController.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ unitController.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ leaseController.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ rentPaymentController.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ unitTenantController.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ userController.ts
β”‚   β”‚   β”‚   └── authController.ts
β”‚   β”‚   β”œβ”€β”€ services/         # Business logic layer
β”‚   β”‚   β”‚   β”œβ”€β”€ PropertyService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ TenantService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ UnitService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ LeaseService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ RentPaymentService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ UnitTenantService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ UserService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthService.ts
β”‚   β”‚   β”‚   └── PasswordResetService.ts
β”‚   β”‚   β”œβ”€β”€ repositories/     # Data access layer
β”‚   β”‚   β”‚   β”œβ”€β”€ PropertyRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ TenantRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ UnitRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ LeaseRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ RentPaymentRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ UnitTenantRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ UserRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ PasswordResetMethodRepository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ RecoveryCodeRepository.ts
β”‚   β”‚   β”‚   └── SecurityQuestionRepository.ts
β”‚   β”‚   β”œβ”€β”€ interfaces/       # TypeScript interfaces for DI
β”‚   β”‚   β”‚   β”œβ”€β”€ repositories/
β”‚   β”‚   β”‚   └── services/
β”‚   β”‚   β”œβ”€β”€ models/           # Data transfer objects
β”‚   β”‚   β”‚   β”œβ”€β”€ Property.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ Tenant.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ Unit.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ Lease.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ RentPayment.ts
β”‚   β”‚   β”‚   └── User.ts
β”‚   β”‚   β”œβ”€β”€ routes/           # API route definitions
β”‚   β”‚   β”œβ”€β”€ utils/            # Backend utilities
β”‚   β”‚   β”œβ”€β”€ constants/        # Configuration constants
β”‚   β”‚   β”œβ”€β”€ middlewares/      # Express middlewares
β”‚   β”‚   β”‚   β”œβ”€β”€ authMiddleware.ts
β”‚   β”‚   β”‚   └── validationMiddleware.ts
β”‚   β”‚   └── server.ts         # Application entry point
β”‚   β”œβ”€β”€ tests/                # Test suites
β”‚   └── package.json
β”œβ”€β”€ docker/                   # Docker configurations
β”œβ”€β”€ docs/                     # API documentation
β”œβ”€β”€ scripts/                  # Build and deployment scripts
β”œβ”€β”€ docker-compose.yml        # Multi-container setup
└── package.json             # Root workspace configuration

πŸš€ Quick Start

Prerequisites

1. Clone and Setup

# Clone the repository
git clone <repository-url>
cd PropertyManagementPlatform

# Install dependencies for all workspaces
npm install

2. Environment Configuration

# Copy environment template
cp .env.example .env

# Edit .env with your configuration
# Required: DATABASE_URL, JWT_SECRET, GOOGLE_CLIENT_ID, etc.

3. Database Setup

For the fastest setup, use the single-command pipeline:

# Complete database setup in one command (interactive)
python3 setup_database.py

This runs the 3-step pipeline with confirmation before each step:

  1. πŸ“Š Create Excel seed data file (asks: Continue? y/N)
  2. πŸ—„οΈ Seed database with sample data (asks: Continue? y/N)
  3. βœ… Verify database integrity (asks: Continue? y/N)

Test Credentials:

Manual Setup

# Start PostgreSQL with Docker Compose
docker-compose up -d postgres

# Or use the full stack
docker-compose up -d

Database Management Scripts

The project includes comprehensive Python scripts for database management:

# First-time setup (migration + test data)
./scripts/db_manage.sh setup

# Or run individual commands
./scripts/db_manage.sh migrate    # Convert IDs to UUID
./scripts/db_manage.sh seed       # Add test data
./scripts/db_manage.sh clean      # Remove test data
./scripts/db_manage.sh test       # Test connection

End-to-End Setup

For complete system setup from scratch, use the end-to-end script:

# Complete setup (database + services + tests)
./scripts/e2e_setup.sh

# Quick setup (skip build and tests)
./scripts/e2e_setup.sh --skip-build --skip-tests

# Show help
./scripts/e2e_setup.sh --help

What the end-to-end script does:

  1. βœ… Checks system dependencies (Docker, Node.js, Python)
  2. βœ… Validates environment configuration
  3. βœ… Sets up database infrastructure
  4. βœ… Runs UUID migration
  5. βœ… Seeds test data
  6. βœ… Installs all dependencies
  7. βœ… Builds frontend and backend
  8. βœ… Starts all services with Docker
  9. βœ… Runs health checks
  10. βœ… Executes comprehensive API tests

Test Credentials:

See scripts/python/README.md for detailed database documentation.

4. Development

# Start both frontend and backend in development mode
npm run dev

# Or run workspaces separately
npm run dev --workspace=frontend
npm run dev --workspace=backend

5. Access the Application

οΏ½ Authentication

Google OAuth Integration

The platform supports seamless Google OAuth authentication:

  1. Frontend: Uses Google Identity Services API for secure authentication
  2. Backend: Verifies Google JWT tokens and creates/manages user accounts
  3. Database: Stores Google user data with proper indexing

Traditional Authentication

πŸ“š API Documentation

Authentication Endpoints

Google OAuth

POST /api/auth/google
Content-Type: application/json

{
  "credential": "google-jwt-token"
}

Traditional Login

POST /api/auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "securePassword123"
}

User Registration

POST /api/auth/register
Content-Type: application/json

{
  "username": "john.doe",
  "email": "john@example.com",
  "password": "securePassword123"
}

Properties API

List Properties

GET /api/properties
Authorization: Bearer <token>

Response:

{
  "success": true,
  "data": [
    {
      "id": "uuid-string",
      "name": "Sunset Apartments",
      "description": "Luxury apartment complex",
      "address": "123 Main St, City, State 12345",
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 1
  }
}

Create Property

POST /api/properties
Authorization: Bearer <token>
Content-Type: application/json

{
  "name": "Riverside Condos",
  "description": "Modern condominium complex",
  "address": "456 River Rd, City, State 12345"
}

Update/Delete Properties

PUT /api/properties/:id
DELETE /api/properties/:id
Authorization: Bearer <token>

πŸ§ͺ Testing

# Run all tests
npm test

# Run backend tests only
npm test --workspace=backend

# Run with coverage
npm run test:coverage

🚒 Deployment

Docker Deployment

# Build and run with Docker Compose
docker-compose up --build

# Or build manually
npm run build
docker build -t property-management .
docker run -p 5000:5000 property-management

Environment Variables

Variable Description Default
NODE_ENV Environment mode development
PORT Server port 5000
DATABASE_URL PostgreSQL connection string Required
JWT_SECRET JWT signing secret Required
JWT_EXPIRE JWT expiration time 1h
REFRESH_TOKEN_EXPIRE Refresh token expiration 7d
BCRYPT_ROUNDS Password hashing rounds 12
GOOGLE_CLIENT_ID Google OAuth client ID Required

πŸ”§ Development Guidelines

Code Style

Architecture Rules

Security Best Practices

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Workflow

# 1. Create feature branch
git checkout -b feature/new-feature

# 2. Make changes and run tests
npm test

# 3. Lint and format code
npm run lint
npm run format

# 4. Commit with conventional format
git commit -m "feat: add new property filtering"

# 5. Push and create PR
git push origin feature/new-feature

πŸ“ˆ Current Status

βœ… Completed Features

πŸ”„ In Progress

πŸ“‹ Planned Features

πŸ“„ License

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

πŸ‘₯ Authors

πŸ™ Acknowledgments


Built with ❀️ using React, TypeScript, Node.js, Express, and PostgreSQL