Automated Action 9ca9d35a1a Implement complete Urban Real Estate API backend
- Set up FastAPI project structure with modular architecture
- Create comprehensive database models for users, properties, messages, notifications, and payments
- Implement JWT-based authentication with role-based access control (Seeker, Agent, Landlord, Admin)
- Build property listings CRUD with advanced search and filtering capabilities
- Add dedicated affordable housing endpoints for Nigerian market focus
- Create real-time messaging system between users
- Implement admin dashboard with property approval workflow and analytics
- Add notification system for user alerts
- Integrate Paystack payment gateway for transactions
- Set up SQLite database with Alembic migrations
- Include comprehensive health check and API documentation
- Add proper error handling and validation throughout
- Follow FastAPI best practices with Pydantic schemas and dependency injection
2025-06-27 12:24:06 +00:00

68 lines
1.8 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import os
from app.routers import auth, properties, affordable, messages, notifications, admin, payments
from app.db.session import engine, SessionLocal
from app.db.base import Base
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Urban Real Estate API",
description="Backend API for Urban Real Estate App - Nigerian housing marketplace",
version="1.0.0",
docs_url="/docs",
redoc_url="/redoc",
openapi_url="/openapi.json"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(auth.router)
app.include_router(properties.router)
app.include_router(affordable.router)
app.include_router(messages.router)
app.include_router(notifications.router)
app.include_router(admin.router)
app.include_router(payments.router)
@app.get("/")
async def root():
return {
"title": "Urban Real Estate API",
"description": "Backend API for Urban Real Estate App - Nigerian housing marketplace",
"documentation": "/docs",
"health": "/health",
"version": "1.0.0"
}
@app.get("/health")
async def health_check():
# Check database connection
try:
db = SessionLocal()
db.execute("SELECT 1")
db.close()
db_status = "healthy"
except Exception as e:
db_status = f"unhealthy: {str(e)}"
return {
"status": "healthy",
"service": "Urban Real Estate API",
"version": "1.0.0",
"database": db_status,
"environment": os.getenv("ENVIRONMENT", "development")
}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)