Skip to content

Commit 1104428

Browse files
committed
feat: Complete alsetmaps platform with smart search, property management, and deployment configuration
- Add comprehensive property search with Mapbox integration - Implement smart search functionality with AI-powered suggestions - Add property pin management and search history tracking - Set up marketplace intents for buyers, sellers, and refinance - Configure authentication with Supabase Auth - Add credit system for premium features - Set up GitHub Actions CI/CD workflow - Configure Vercel deployment settings - Clean up deprecated code and optimize structure - Add comprehensive documentation and setup guides
1 parent 9e9791d commit 1104428

File tree

156 files changed

+9792
-22203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+9792
-22203
lines changed

.github/workflows/deploy.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy to Vercel
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Run linting
27+
run: npm run lint
28+
29+
- name: Run type checking
30+
run: npm run type-check
31+
32+
- name: Build application
33+
run: npm run build
34+
env:
35+
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
36+
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
37+
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ secrets.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN }}
38+
NEXT_PUBLIC_RAPIDAPI_KEY: ${{ secrets.NEXT_PUBLIC_RAPIDAPI_KEY }}
39+
NEXT_PUBLIC_APP_URL: ${{ secrets.NEXT_PUBLIC_APP_URL }}
40+
41+
- name: Deploy to Vercel
42+
uses: amondnet/vercel-action@v25
43+
with:
44+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
45+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
46+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
47+
vercel-args: '--prod'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ coverage/
117117
# Misc
118118
*.tgz
119119
*.tar.gz
120+
.vercel

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Thank you for your interest in contributing to Alset! This document provides gui
3434
### Prerequisites
3535

3636
- Node.js 18+
37-
- npm, yarn, or bun
37+
- npm or yarn
3838
- Git
3939

4040
### Local Development

GOOGLE_OAUTH_SETUP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@ com.yourapp://auth/callback
123123
- [Supabase Auth Documentation](https://supabase.com/docs/guides/auth)
124124
- [Google OAuth 2.0 Documentation](https://developers.google.com/identity/protocols/oauth2)
125125
- [Next.js Authentication](https://nextjs.org/docs/authentication)
126+

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A comprehensive real estate platform built with Next.js, Supabase, and modern we
2626
## 📋 Prerequisites
2727

2828
- Node.js 18+
29-
- npm, yarn, or bun
29+
- npm or yarn
3030
- Supabase account
3131
- Mapbox account
3232
- Stripe account (for payments)
@@ -49,7 +49,7 @@ npm install
4949
# or
5050
yarn install
5151
# or
52-
bun install
52+
npm install
5353
```
5454

5555
### 3. Environment Setup
@@ -115,7 +115,7 @@ npm run dev
115115
# or
116116
yarn dev
117117
# or
118-
bun dev
118+
npm run dev
119119
```
120120

121121
Open [http://localhost:3000](http://localhost:3000) in your browser.

SMART_SEARCH_SETUP.md

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
# 🏠 Smart Search System Setup Guide
2+
3+
## Overview
4+
The Smart Search system now integrates with the real Zillow API to provide enhanced property data. Basic searches remain free, while smart searches cost 1 credit and return comprehensive property information.
5+
6+
## 🚀 Quick Start
7+
8+
### 1. Database Setup
9+
Run the following SQL script to add the `smart_data` column:
10+
11+
```sql
12+
-- Run this in your Supabase SQL editor
13+
ALTER TABLE public.search_history
14+
ADD COLUMN smart_data JSONB;
15+
16+
-- Add a comment to document the column purpose
17+
COMMENT ON COLUMN public.search_history.smart_data IS 'Stores the full API response data from Zillow for smart searches. NULL for basic searches.';
18+
19+
-- Create an index on the smart_data column for better query performance
20+
CREATE INDEX idx_search_history_smart_data ON public.search_history USING GIN (smart_data);
21+
```
22+
23+
### 2. Environment Variables
24+
Add your RapidAPI key to your `.env.local` file:
25+
26+
```bash
27+
# RapidAPI Configuration
28+
NEXT_PUBLIC_RAPIDAPI_KEY=f4a7d42741mshbc2b95a8fd24074p1cf1a6jsn44343abb32e8
29+
```
30+
31+
**Note**: The system includes a fallback API key for testing, but you should use your own for production.
32+
33+
### 3. Test the System
34+
1. Go to `/` and perform a search
35+
2. Toggle between "Basic" and "Smart" search types
36+
3. View your search history at `/search-history`
37+
38+
## 🔧 How It Works
39+
40+
### Search Types
41+
42+
#### Basic Search (Free)
43+
- No credits required
44+
- Basic property information
45+
- Minimal data stored
46+
47+
#### Smart Search (1 Credit)
48+
- Requires 1 credit
49+
- Calls real Zillow API
50+
- Stores full API response in `smart_data` column
51+
- Enhanced property insights
52+
53+
### Data Flow
54+
```
55+
User Input → Address Selection → Search Type Selection → API Call → Credit Deduction → Data Storage → Results Display
56+
```
57+
58+
### Credit System
59+
- **Basic searches**: 0 credits (free)
60+
- **Smart searches**: 1 credit
61+
- Credits are automatically deducted from user's account
62+
- Insufficient credits prevent smart searches
63+
64+
## 📊 Database Schema
65+
66+
### `search_history` Table
67+
```sql
68+
CREATE TABLE public.search_history (
69+
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
70+
user_id UUID REFERENCES public.accounts(id),
71+
search_address TEXT NOT NULL,
72+
search_type TEXT CHECK (search_type IN ('basic', 'smart')),
73+
credits_used INTEGER DEFAULT 0,
74+
created_at TIMESTAMPTZ DEFAULT NOW(),
75+
smart_data JSONB -- NEW: Stores Zillow API response
76+
);
77+
```
78+
79+
### `credits` Table
80+
```sql
81+
CREATE TABLE public.credits (
82+
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
83+
user_id UUID REFERENCES public.accounts(id),
84+
available_credits INTEGER DEFAULT 10,
85+
created_at TIMESTAMPTZ DEFAULT NOW(),
86+
updated_at TIMESTAMPTZ DEFAULT NOW()
87+
);
88+
```
89+
90+
## 🎯 API Integration
91+
92+
### Zillow API Endpoint
93+
```
94+
GET https://zillow56.p.rapidapi.com/search_address
95+
```
96+
97+
### Headers
98+
```
99+
x-rapidapi-host: zillow56.p.rapidapi.com
100+
x-rapidapi-key: YOUR_RAPIDAPI_KEY
101+
```
102+
103+
### Example Response Storage
104+
The full Zillow API response is stored in the `smart_data` column as JSON:
105+
106+
```json
107+
{
108+
"type": "smart",
109+
"address": "1161 Natchez Dr College Station Texas 77845",
110+
"timestamp": "2025-01-02T21:38:02.000Z",
111+
"zillowData": {
112+
// Full Zillow API response here
113+
},
114+
"message": "Smart search completed with real Zillow data"
115+
}
116+
```
117+
118+
## 🧪 Testing
119+
120+
### Test Basic Search
121+
1. Select "Basic" search type
122+
2. Enter an address
123+
3. Verify: No credits deducted, minimal data stored
124+
125+
### Test Smart Search
126+
1. Select "Smart" search type
127+
2. Enter an address
128+
3. Verify: 1 credit deducted, full Zillow data stored
129+
4. Check `/search-history` for stored data
130+
131+
### Test Credit System
132+
1. Perform multiple smart searches
133+
2. Monitor credit balance
134+
3. Verify credits are properly deducted
135+
136+
## 🔍 Search History Page
137+
138+
### Features
139+
- **Stats Dashboard**: Total searches, basic/smart counts, credits used
140+
- **Search Details**: Address, type, credits, timestamp
141+
- **Smart Data Display**: Full Zillow API response for smart searches
142+
- **Responsive Design**: Works on all devices
143+
144+
### Navigation
145+
- Main nav: "Search History" link
146+
- SmartSearch component: "View Your Search History" link
147+
- Direct URL: `/search-history`
148+
149+
## 🚨 Troubleshooting
150+
151+
### Common Issues
152+
153+
#### "Insufficient credits for smart search"
154+
- User doesn't have enough credits
155+
- Check `credits.available_credits` in database
156+
- Add credits via database or admin interface
157+
158+
#### "Zillow API error"
159+
- Check RapidAPI key validity
160+
- Verify API endpoint accessibility
161+
- Check network connectivity
162+
163+
#### "Smart data not available"
164+
- Smart search may have failed
165+
- Check browser console for errors
166+
- Verify `smart_data` column exists
167+
168+
### Debug Steps
169+
1. Check browser console for errors
170+
2. Verify environment variables
171+
3. Check Supabase logs
172+
4. Verify database schema
173+
5. Test API endpoint directly
174+
175+
## 🔒 Security Considerations
176+
177+
### Row Level Security (RLS)
178+
- Users can only see their own search history
179+
- `smart_data` is protected by existing RLS policies
180+
- No additional policies needed
181+
182+
### API Key Security
183+
- RapidAPI key is exposed to client (required for frontend calls)
184+
- Consider rate limiting for production use
185+
- Monitor API usage and costs
186+
187+
## 📈 Production Considerations
188+
189+
### Rate Limiting
190+
- Implement rate limiting for smart searches
191+
- Monitor credit usage patterns
192+
- Set reasonable limits per user
193+
194+
### Cost Management
195+
- Monitor RapidAPI usage costs
196+
- Implement credit purchase system
197+
- Set credit limits and expiration
198+
199+
### Performance
200+
- `smart_data` column is indexed for fast queries
201+
- Consider archiving old search data
202+
- Monitor database size growth
203+
204+
## 🎉 Success Metrics
205+
206+
### User Experience
207+
- ✅ Basic searches work without credits
208+
- ✅ Smart searches provide enhanced data
209+
- ✅ Credit system functions correctly
210+
- ✅ Search history is comprehensive
211+
212+
### Technical
213+
- ✅ Zillow API integration working
214+
- ✅ Data storage in `smart_data` column
215+
- ✅ Credit deduction system operational
216+
- ✅ Search history page functional
217+
218+
## 📞 Support
219+
220+
For issues or questions:
221+
1. Check this documentation
222+
2. Review browser console errors
223+
3. Check Supabase logs
224+
4. Verify database schema
225+
5. Test API endpoints directly
226+
227+
---
228+
229+
**Happy Searching! 🏠✨**

0 commit comments

Comments
 (0)