Skip to content

moiz67932/website_crown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

221 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Real Estate Property Management System

A modern Next.js application for real estate property management with Trestle API integration, advanced search capabilities, and interactive maps.

πŸš€ Features

  • Property Search & Discovery: Advanced search with semantic capabilities
  • Interactive Maps: Leaflet-based maps with drawing tools and property visualization
  • User Authentication: Secure JWT-based authentication system
  • Property Comparison: Side-by-side property comparison functionality
  • Saved Properties & Searches: User profile management with favorites
  • Responsive Design: Mobile-first responsive UI with Tailwind CSS
  • Real-time Updates: Automatic property data synchronization with Trestle API

πŸ“‹ Prerequisites

Before starting development, ensure you have the following installed:

Required Software

  • Node.js (version 18.17 or higher)
  • npm (comes with Node.js) or yarn or pnpm
  • Git for version control

Required API Keys & Services

  • Trestle API Credentials:
    • API ID and Password from CoreLogic Trestle
    • Required for property data integration
  • Google Maps API Key:
    • For maps functionality and street view
    • Enable Maps JavaScript API and Street View Static API

Database

  • SQLite: Automatically handled by better-sqlite3 (no separate installation required)

πŸ› οΈ Installation & Setup

1. Clone the Repository

git clone <your-repository-url>
cd back

2. Install Dependencies

npm install
# or
yarn install
# or
pnpm install

All required packages are listed in requirements.txt and will be installed from package.json.

3. Environment Configuration

Create a .env.local and '.env' file in the root directory and configure the following variables:

# Trestle API Configuration (Required)
TRESTLE_API_ID=your-trestle-api-id
TRESTLE_API_PASSWORD=your-trestle-api-password
TRESTLE_BASE_URL=https://api-trestle.corelogic.com/trestle
TRESTLE_OAUTH_URL=https://api-trestle.corelogic.com/trestle/oidc/connect/token
TRESTLE_UPDATE_INTERVAL=15

# Database Configuration
DATABASE_URL=./data/users.db

# Authentication
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production-make-it-at-least-32-characters-long

# Google Maps (Required for maps functionality)
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your-google-maps-api-key-here

# Application URLs
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_API_BASE_URL=https://api.crowncoastalhomes.com
API_BASE_URL=https://api.crowncoastalhomes.com

# Environment
NODE_ENV=development

4. Database Setup

The application uses SQLite with better-sqlite3. The database will be automatically created when you first run the application.

To populate the database with sample data: --not necessary--

node populate-database.js

5. API Integration Setup ----not necessary--

To test your Trestle API integration:

node test-trestle-api.js

πŸƒβ€β™‚οΈ Running the Application

Development Mode

npm run dev
# or
yarn dev
# or
pnpm dev

The application will start at http://localhost:3000

Production Build

npm run build
npm run start

Linting

npm run lint

πŸ“ Project Structure

back/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                 # Next.js App Router pages
β”‚   β”‚   β”œβ”€β”€ api/            # API routes
β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication pages
β”‚   β”‚   β”œβ”€β”€ properties/     # Property listing pages
β”‚   β”‚   └── map/            # Map interface
β”‚   β”œβ”€β”€ components/         # Reusable React components
β”‚   β”‚   β”œβ”€β”€ ui/            # UI components (buttons, forms, etc.)
β”‚   β”‚   β”œβ”€β”€ filters/       # Search and filter components
β”‚   β”‚   └── map/           # Map-related components
β”‚   β”œβ”€β”€ lib/               # Utility libraries
β”‚   β”‚   β”œβ”€β”€ auth.ts        # Authentication logic
β”‚   β”‚   β”œβ”€β”€ database.ts    # Database operations
β”‚   β”‚   └── trestle-api.ts # Trestle API integration
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   β”œβ”€β”€ types/             # TypeScript type definitions
β”‚   └── styles/            # Global styles
β”œβ”€β”€ data/                  # Database files
β”œβ”€β”€ requirements.txt       # Package dependencies list
└── package.json          # Node.js dependencies

πŸ”§ Development Workflow

1. Before Starting Development

  • Ensure all environment variables are configured
  • Test API connections with provided test scripts
  • Run database population script if needed

2. Key Development Commands

# Start development server with turbopack (faster)
npm run dev

# Generate API client (if API changes)
npm run generate-client

# Run database migrations
node run-migration.js

# Test specific features
node test-properties-api.js
node test-semantic-search.js

3. Testing API Integration

Use the provided test scripts to verify your setup:

  • test-trestle-api.js - Test Trestle API connection
  • test-oauth-method.js - Test OAuth authentication
  • test-properties-api.js - Test property data retrieval

🌐 Key Features Setup

Maps Configuration

  • Ensure Google Maps API key is set in environment variables
  • Enable required Google Maps APIs in Google Cloud Console

Property Search

  • Semantic search requires vector indexing (automatically handled)
  • Property data syncs automatically based on TRESTLE_UPDATE_INTERVAL

User Authentication

  • JWT tokens are used for session management
  • User data is stored in SQLite database

πŸ“š API Documentation

Trestle API Integration

The application integrates with CoreLogic's Trestle API for real estate data. Key endpoints:

  • Property search and filtering
  • Property details and media
  • Market statistics

Internal API Routes

  • /api/properties - Property search and listing
  • /api/auth - Authentication endpoints
  • /api/user - User profile management

πŸš€ Deployment

Environment Variables for Production

Ensure all environment variables are set in your production environment, especially:

  • JWT_SECRET (use a strong, unique secret)
  • NODE_ENV=production
  • Valid API keys and credentials

Build Process

npm run build

πŸ“– Additional Resources

πŸ†˜ Troubleshooting

Common Issues

  1. Trestle API Connection Issues: Verify your API credentials and check test scripts
  2. Maps Not Loading: Ensure Google Maps API key is valid and APIs are enabled
  3. Database Errors: Check file permissions for SQLite database files
  4. Build Errors: Ensure all dependencies are installed and environment variables are set

Test Scripts

Use the comprehensive test scripts in the root directory to diagnose issues:

  • debug-trestle-api.js - Debug Trestle API issues
  • verify-credentials.js - Verify all API credentials

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly using provided test scripts
  5. Submit a pull request

πŸ“„ License

This project is proprietary. Please contact the development team for licensing information.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7

Languages