Real Estate Data Platform (DVF)
Web platform for consulting and analyzing official French real estate transaction data (Demande de Valeurs Foncières)
Technical Architecture
Backend
- Framework: Django
- Database: SQLite with optimizations (WAL mode, cache_size, mmap_size)
- Cache: Redis with django-redis for caching frequent queries
- Asynchronous tasks: Celery with Celery Beat for scheduled tasks
- File storage: MinIO/S3 via django-storages for media files
- REST API: Django REST Framework for API endpoints
Frontend
- CSS Framework: Tailwind CSS compiled via django-tailwind
- Interactivity: HTMX for dynamic interactions without page reload
- Templates: Django template system with inheritance and includes
- JavaScript: Vanilla JavaScript for autocomplete and charts
Main Features
Smart City Search
- Multi-criteria search system with real-time autocomplete
- Search by name, INSEE code, postal code with result prioritization
- Query normalization (removing multiple spaces, case handling)
- Multi-keyword search with logical AND combination
- Suggestions displayed via JSON API and dynamic HTML injection
Geographic Navigation
- Hierarchy: Regions → Departments → Cities → Streets
- SEO-friendly URLs with normalized slugs
- Geographic relationship validation to avoid 404 errors
- Optimized pagination for large lists (cities, streets, transactions)
Real Estate Data Display
- Pre-calculated statistics: Statistics stored in dedicated models for optimal performance
- Data by property type: Houses, apartments, commercial properties
- Indicators: Average/median price per m², number of sales, percentage evolution
- Price evolution charts: Temporal price visualization with monthly/quarterly data
- Recent transactions: Display of the last 20 transactions with complete details
- Street-level statistics: Sales aggregation by street/avenue with optimized ORM calculations
DVF Data Models
- Dynamic models by year (DVF2020, DVF2021, DVF2022, DVF2023, DVF2024, DVF2025)
- Factory function to retrieve the appropriate model based on year
- Indexing on code_insee, code_commune, voie_slug for performance
- Automatic price per m² calculation on query side and pre-calculation for statistics
Statistical Calculations
- Global statistics: Aggregation for each city, department, region
- Temporal evolution: Year N vs Year N-1 comparison with percentage calculation
- Median prices: Median calculation to avoid bias from extreme values
- Optimizations: Use of select_related, prefetch_related, only() to limit queries
- ORM aggregation: Use of annotate() and aggregate() for database calculations
Nearby Cities
- Geographic detection via GPS coordinates (latitude/longitude)
- Distance calculation using Haversine formula
- Configurable search radius (default 20km)
- Display of comparative statistics of nearby cities
Integrated Blog System
- Content management: Articles with categories, tags, authors
- HTMX search: Dynamic search without page reload in the blog
- Media management: Optimized images with Pillow, S3 storage
- SEO: Dynamic meta tags, estimated reading time
- Pagination: Pagination system for article lists
Real Estate Tools
- ROI calculator: Calculation tool for real estate investments
- Loan simulator: Real estate loan monthly payment calculation
- Price comparator: Comparison between different geographic areas
Optimizations and Performance
Cache
- Page cache with cache_page() for the homepage (1 hour)
- Redis for distributed cache in production
- Cache of frequent queries (popular cities, statistics)
Query Optimization
- select_related() for ForeignKey joins
- prefetch_related() for ManyToMany and reverse ForeignKey relations
- only() and defer() to limit loaded fields
- Indexing on frequently searched fields
- Database aggregation rather than in Python
Database
- WAL mode (Write-Ahead Logging) for better read/write concurrent performance
- SQLite cache configuration (cache_size=2000 pages)
- MMap for large databases (mmap_size=128MB)
- Composite indexes on frequent field combinations
Asynchronous Tasks (Celery)
- DVF data import: Scheduled task to import new data (every 6 months)
- Statistics calculation: Automatic calculation of city statistics
- Information retrieval: Update of geographic data for cities and departments
- Social media publishing: Automatic generation and publication of posts (Twitter/Bluesky)
Security and Production
- HTTPS: SSL configuration with SECURE_SSL_REDIRECT
- HSTS: HTTP Strict Transport Security enabled
- Secure cookies: CSRF and Session cookies in secure mode
- Security headers: X_FRAME_OPTIONS for clickjacking protection
- Log management: Structured logging system with colorlog
SEO and Accessibility
- Schema.org: Structured data FAQPage and WebSite with SearchAction
- Dynamic meta tags: Custom title, description, Open Graph, Twitter Cards per page
- Sitemap: Automatic XML sitemap generation
- Optimized URLs: Normalized slugs, clear hierarchical structure
- Robots.txt: Configuration for search engines
Data and Volume
- 35,000+ cities: Complete coverage of mainland France and overseas territories
- 5 years of data: Complete history from 2020 to 2024
- Millions of transactions: Database containing all official DVF transactions
- Pre-calculated statistics: StatistiqueCommune model for fast access
- Geographic data: GPS coordinates, GeoJSON contours, administrative information
Modular Architecture
- mainSite: Main application for real estate data consultation
- blog: Blog module with articles, categories, tags, authors
- outils: Real estate calculation tool modules
- api: REST API for programmatic data access
- theme: Tailwind CSS configuration
Technologies and Libraries
- Backend: Django, Celery, Redis, django-redis, django-celery-beat
- API: Django REST Framework
- Frontend: Tailwind CSS, HTMX
- Storage: django-storages, boto3
- Images: Pillow for image processing
- Visualization: Matplotlib for chart generation
- Logging: colorlog for colored logs in development