An AI-powered Building Cost & Rent Management System that combines deterministic financial calculations with intelligent document retrieval and natural language understanding.
BuildWise is a proof-of-concept system designed to manage:
- Building and flat information
- Tenant management
- Rent calculations
- Utility bills (electricity, gas, water)
- Property taxes and service charges
- AI-powered query answering using RAG (Retrieval Augmented Generation)
โโโโโโโโโโโโโโโโโโโ
โ React Frontend โ
โ (Port 3000) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โ HTTP REST API
โ
โโโโโโโโโโผโโโโโโโโโ
โ FastAPI Backendโ
โ (Port 8000) โ
โโโโโโโโโโโโโโโโโโโค
โ AI Agent โ
โ โโ Intent โ
โ โโ RAG โ
โ โโ Tools โ
โโโโโโโโโโโโโโโโโโโค
โ Calculations โ
โ (Deterministic)โ
โโโโโโโโโโโโโโโโโโโ
- Hybrid Approach: Deterministic Python functions for all monetary calculations, LLMs only for reasoning and intent classification
- RAG-Based Knowledge: Document retrieval using FAISS for answering policy and rule questions
- Tool-Calling Architecture: LLM classifies intent and calls appropriate calculation functions
- Memory Optimized: Designed to run on 16GB RAM using lightweight models
- Production-Ready: Type hints, validation, error handling, and containerization
- Docker
- Docker Compose
- 16GB RAM minimum
- Linux/WSL2 (Ubuntu 24.04 recommended)
- Clone or navigate to the project directory:
cd /home/pyro/poc/BuildWise- Build and start the containers:
docker compose up --buildThis will:
- Build the backend (FastAPI + AI models)
- Build the frontend (React)
- Start both services
- Backend will be available at
http://localhost:8000 - Frontend will be available at
http://localhost:3000
- Access the application:
- Open your browser to
http://localhost:3000 - The API documentation is at
http://localhost:8000/docs
docker compose downTo remove volumes as well:
docker compose down -v- Create Python virtual environment:
cd backend
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the backend:
uvicorn main:app --reload --host 0.0.0.0 --port 8000The backend will start at http://localhost:8000
- Install Node.js dependencies:
cd frontend
npm install- Start the development server:
npm startThe frontend will start at http://localhost:3000
- Python 3.11: Core language
- FastAPI: Web framework
- Pydantic: Data validation
- PyTorch: Neural network framework
- HuggingFace Transformers: Pre-trained models
- Sentence-Transformers: Text embeddings
- FAISS: Vector similarity search
- React 18: UI framework
- Axios: HTTP client
- Nginx: Production web server
- Docker: Containerization
- Docker Compose: Multi-container orchestration
Retrieval Augmented Generation for answering questions about building policies and rules.
- Embedding Model:
sentence-transformers/all-MiniLM-L6-v2(384 dimensions) - Vector Store: FAISS with L2 distance
- Documents: Pre-loaded with 10 sample policy documents
- Top-K Retrieval: Returns 3 most relevant documents per query
Sample Documents:
- Rent calculation policies
- Utility bill calculation rules
- Property tax guidelines
- Service charge distribution
- Late payment policies
- Deposit and refund rules
Intelligent agent that classifies intent and routes to appropriate tools.
Intent Classification:
calculate_rent: Rent-related calculationscalculate_utility: Utility bill calculationscalculate_tax: Property tax calculationscalculate_service_charge: Service charge calculationsget_information: Policy/rule questions (uses RAG)general_query: General questions
Tool Calling:
- Extracts parameters from natural language queries
- Validates inputs
- Calls deterministic calculation functions
- Returns structured JSON results
Deterministic financial calculations using Python's Decimal for precision.
Available tools:
calculate_rent(): Base rent ร location multiplier + amenitiescalculate_utility_bill(): Units ร rate + fixed charge + taxcalculate_property_tax(): (Value - exemptions) ร tax ratecalculate_service_charge(): Base charge รท flat count + additional servicescalculate_monthly_cost_breakdown(): Total monthly expenses
POST /buildings/- Create a new buildingGET /buildings/- List all buildingsGET /buildings/{id}- Get building details
POST /flats/- Create a new flatGET /flats/- List all flatsGET /flats/{id}- Get flat details
POST /tenants/- Create a new tenantGET /tenants/- List all tenantsGET /tenants/{id}- Get tenant details
POST /utility-bills/- Create a utility billGET /utility-bills/- List all utility billsGET /utility-bills/{id}- Get bill details
POST /taxes/- Create a tax recordGET /taxes/- List all taxesGET /taxes/{id}- Get tax details
POST /ai/query- Ask the AI assistant a question
GET /health- Health check endpoint
Calculate Rent:
Query: "Calculate rent for 1200 sqft with base rent 1000"
Response: Detailed calculation with total rent
Utility Bill:
Query: "Calculate electricity bill for 150 units at 0.15 per unit"
Response: Subtotal, tax, and total amount
Policy Questions:
Query: "What is the late payment policy?"
Response: Retrieved from RAG with source documents
Property Tax:
Query: "Calculate property tax for 500000 at 1.5% rate"
Response: Detailed tax calculation
Create a Building:
curl -X POST http://localhost:8000/buildings/ \
-H "Content-Type: application/json" \
-d '{
"name": "Sunset Towers",
"address": "123 Main Street",
"total_floors": 10,
"total_flats": 40
}'AI Query:
curl -X POST http://localhost:8000/ai/query \
-H "Content-Type: application/json" \
-d '{
"query": "Calculate rent for 1000 sqft with base rent 800"
}'BuildWise/
โโโ backend/
โ โโโ core/
โ โ โโโ __init__.py
โ โ โโโ agent.py # AI agent with tool calling
โ โ โโโ calculations.py # Deterministic calculations
โ โ โโโ rag.py # RAG pipeline
โ โโโ models/
โ โ โโโ __init__.py
โ โ โโโ schemas.py # Pydantic models
โ โโโ data/
โ โ โโโ documents.json # RAG documents
โ โ โโโ faiss_index/ # FAISS vector store
โ โโโ main.py # FastAPI application
โ โโโ database.py # In-memory database
โ โโโ requirements.txt # Python dependencies
โ โโโ Dockerfile
โโโ frontend/
โ โโโ public/
โ โ โโโ index.html
โ โโโ src/
โ โ โโโ App.js # Main React component
โ โ โโโ App.css # Styles
โ โ โโโ index.js # Entry point
โ โ โโโ index.css
โ โโโ package.json
โ โโโ nginx.conf # Nginx configuration
โ โโโ Dockerfile
โโโ docker-compose.yml
โโโ .gitignore
โโโ .env.example
โโโ README.md
โโโ TECHNICAL.md # Technical deep-dive
Copy .env.example to .env and configure:
PYTHONUNBUFFERED=1
API_HOST=0.0.0.0
API_PORT=8000The system is configured for 16GB RAM:
- Uses CPU-only inference (no GPU required)
- Lightweight embedding model (all-MiniLM-L6-v2)
- Simple agent without heavy LLM (can be upgraded to phi-2 or similar)
- FAISS flat index (L2 distance)
To use a full LLM like Phi-2 (uncomment in agent.py):
- Change
SimpleLLMAgenttoLLMAgentinmain.py - Requires additional 3-4GB RAM
- First run will download ~2.7GB model
cd backend
source venv/bin/activate
python -m pytest # If you add testsUse the interactive API docs at http://localhost:8000/docs
cd frontend
npm test- Cold Start: First request takes ~10-30 seconds (model loading)
- RAG Search: ~100-500ms per query
- Calculations: <1ms (deterministic Python)
- Memory Usage: ~2-4GB for base system, 5-8GB with full LLM
Port Already in Use:
docker compose down
sudo lsof -i :8000 # Check what's using port 8000
sudo lsof -i :3000 # Check what's using port 3000Container Won't Start:
docker compose logs backend
docker compose logs frontendModule Not Found:
cd backend
pip install -r requirements.txtFAISS Index Missing: The index is built automatically on first run when RAG pipeline initializes.
Build Fails:
cd frontend
rm -rf node_modules package-lock.json
npm install- No authentication implemented (PoC only)
- No database persistence (in-memory storage)
- CORS enabled for all origins (development only)
- No rate limiting
- No input sanitization beyond Pydantic validation
For Production: Add authentication, persistent database, rate limiting, input sanitization, and HTTPS.
See TECHNICAL.md for a comprehensive guide to the AI/ML concepts used in this project, from basic math to production AI systems.
This is a proof-of-concept project for educational purposes.
This is a PoC project. For improvements:
- Add proper database (PostgreSQL/MongoDB)
- Implement authentication (JWT)
- Add comprehensive test suite
- Improve error handling
- Add logging and monitoring
- Implement caching (Redis)
- Add real-time features (WebSockets)
For issues or questions, refer to the technical documentation or API documentation at /docs.
Built with โค๏ธ using FastAPI, React, and AI