A comprehensive wealth management and property analysis platform built with Next.js, Prisma, and modern web technologies.
Create a .env
file in the root directory with the following variables:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/wealth_map"
# Authentication
NEXTAUTH_URL="http://localhost:3000"
AUTH_SECRET="your-secret-key"
# Redis Cache
REDIS_URL="redis://localhost:6379"
# AI Services
GOOGLE_AI_API_KEY="your-google-ai-key"
GROQ_API_KEY="your-groq-key"
# Map Services
MAPTILER_API_KEY="your-maptiler-key"
# Email (Optional for email-based features)
RESEND_API_KEY="your-resend-api-key"
EMAIL_FROM="no-reply@your-domain.com"
git clone https://github.com/yourusername/wealth-map.git
cd wealth-map
npm install
npx prisma generate
npx prisma migrate dev
npm run seed
npm run dev
http://localhost:3000
admin@example.com
password123
wealth-map/
├── prisma/ # Database schema and migrations
├── public/ # Static assets
├── src/
│ ├── app/ # Next.js App Router components
│ │ ├── api/ # API routes
│ │ ├── app/ # Main application routes
│ │ │ ├── employee/ # Employee-specific pages
│ │ │ ├── company-admin/ # Company admin pages
│ │ │ └── super-admin/ # Super admin pages
│ │ └── auth/ # Authentication pages
│ ├── components/ # React components
│ │ ├── custom-components/ # Application-specific components
│ │ └── ui/ # UI component library
│ ├── hooks/ # React hooks
│ ├── lib/ # Utility functions and libraries
│ ├── Models/ # TypeScript models and interfaces
│ ├── services/ # API service classes
│ ├── stores/ # Global state management
│ ├── types/ # TypeScript type definitions
│ └── middleware.ts # Next.js middleware for auth and routing
Component | Purpose | Key Features |
---|---|---|
AppSidebar |
Main navigation | • Role-based navigation items • Collapsible UI • User profile integration |
PropertyExport |
Property data export | • Multi-format export • Field selection • Preview functionality |
InteractiveMap |
Property visualization | • MapTiler integration • Property filtering • Custom markers |
HomePage |
Employee dashboard | • Property search • Saved views • Analytics dashboard |
// Example API endpoints
POST /api/reports/export
GET /api/reports/export
DELETE /api/reports/export?id={id}
// Component template
export default function ComponentName() {
// 1. Hooks and state
const [state, setState] = useState()
// 2. Helper functions
const helperFunction = () => {}
// 3. Event handlers
const handleEvent = () => {}
// 4. Render
return (
<div>
{/* JSX */}
</div>
)
}
// Always wrap permission-dependent components
<WithPermission permission="required:permission">
<Component />
</WithPermission>
useState
for component-level stateuseReducer
for complex state logictry {
const response = await fetch('/api/endpoint')
if (!response.ok) {
throw new Error('API Error')
}
} catch (error) {
toast({
title: "Error",
description: "User-friendly message",
variant: "destructive"
})
}
// Input validation
const validateInput = (input: string) => {
if (!input) {
throw new Error('Required field')
}
}
Role | Description | Key Capabilities |
---|---|---|
SUPER_ADMIN | System-level access | • Manage all companies and users • Access all features and settings • Create system-wide roles • Override any permission |
COMPANY_ADMIN | Company-level access | • Manage company employees • Access company properties and reports • Create company-specific roles • Manage company settings |
EMPLOYEE | Basic access | • Access assigned properties • View permitted reports • Customizable permissions • Role-based access |
Category | Permission | Description | SUPER_ADMIN | COMPANY_ADMIN | EMPLOYEE |
---|---|---|---|---|---|
System | system:* |
Full system access | ✓ | - | - |
system:settings |
View/modify settings | ✓ | - | - | |
system:maintenance |
Maintenance controls | ✓ | - | - | |
system:logs |
Access system logs | ✓ | - | - | |
Property | property:* |
Full property access | ✓ | ✓ | - |
property:view |
View properties | ✓ | ✓ | ✓ | |
property:search |
Search properties | ✓ | ✓ | ✓ | |
property:create |
Create properties | ✓ | ✓ | - | |
property:edit |
Edit properties | ✓ | ✓ | - | |
property:delete |
Delete properties | ✓ | ✓ | - | |
property:bookmark |
Bookmark properties | ✓ | ✓ | ✓ | |
Reports | reports:* |
Full report access | ✓ | ✓ | - |
reports:view |
View reports | ✓ | ✓ | ✓ | |
reports:create |
Create reports | ✓ | ✓ | ✓ | |
reports:edit |
Edit reports | ✓ | ✓ | - | |
reports:delete |
Delete reports | ✓ | ✓ | - | |
reports:export |
Export reports | ✓ | ✓ | ✓ | |
reports:schedule |
Schedule reports | ✓ | ✓ | - | |
Users | users:* |
Full user management | ✓ | - | - |
users:view |
View users | ✓ | ✓ | - | |
users:create |
Create users | ✓ | ✓ | - | |
users:edit |
Edit users | ✓ | ✓ | - | |
users:delete |
Delete users | ✓ | - | - | |
users:roles |
Manage roles | ✓ | ✓ | - | |
Company | company:* |
Full company access | ✓ | ✓ | - |
company:view |
View company info | ✓ | ✓ | - | |
company:edit |
Edit company | ✓ | ✓ | - | |
company:employees |
Manage employees | ✓ | ✓ | - | |
company:roles |
Manage roles | ✓ | ✓ | - |
// Example permission check in API route
const hasPermission = user.roles.some(role =>
role.permissions.some(p => p.name === "property:view")
);
// Example permission check in React component
<WithPermission permission="reports:create">
<ExportButton />
</WithPermission>
// Example conditional rendering
{hasPermission("property:edit") && (
<EditPropertyButton />
)}
# Test database connection
npx prisma db pull
# Check Prisma database connection
npx prisma db pull
# Reset database (development only)
npx prisma migrate reset
# Validate environment variables
node -e "console.log(process.env.DATABASE_URL)"
# Check for TypeScript errors
npx tsc --noEmit
# Build the application
npm run build
# Start the production server
npm run start
For CI/CD setup, you can use services like Vercel, Netlify, or a custom pipeline:
# Build Docker image
docker build -t wealth-map .
# Run Docker container
docker run -p 3000:3000 --env-file .env.production wealth-map
# Apply migrations to production database
npx prisma migrate deploy
# If needed, seed production data
NODE_ENV=production npm run seed