# 🚧 CONTINUE_HERE.md — Handoff to Claude Code

> You are picking up a Django project that was 85% built in a long Claude.ai conversation. The chat hit length limits, so this file tells you exactly what's done and what remains.

## Project: TDK Homes
A Django-based real estate website inspired by tdkhomes.ng with an OAS-style nav (oasconsultingnigeria.com), full property catalog, custom admin dashboard, rule-based chatbot, visitor analytics, lead capture, and cPanel deployment.

---

## ✅ What's Already Done (DO NOT REWRITE)

### Backend (100% complete)
- `config/settings.py` — env-driven, 10 apps registered, middleware wired, dj-database-url, whitenoise, Africa/Lagos TZ
- `config/urls.py`, `wsgi.py`, `asgi.py`, `manage.py`, `requirements.txt`, `.env`, `.env.example`, `.gitignore`
- All 10 apps with full models + views + urls + admin:
  - `core` (SiteSetting, Testimonial, FAQ, TeamMember + home/about/contact/faq/blog views)
  - `properties` (Property + PropertyImage + Category + Location + amenities, list/detail views with filters)
  - `leads` (Lead model with 10 sources/9 statuses + inquiry/contact/popup views)
  - `chatbot` (ChatSession, ChatMessage, ChatbotKnowledge + rule-based fallback service in services.py)
  - `sales_updates` (rich-text content, related properties)
  - `videos` (YouTube/Vimeo/upload sources, embed_url property)
  - `forms` (DownloadableForm + FormDownload — gated downloads create Lead)
  - `newsletter` (Subscriber + Newsletter)
  - `landing_pages` (LandingPage at /p/<slug>/ with M2M to properties, theme color, body_html)
  - `analytics` (PageVisit + VisitorStat + VisitorTrackingMiddleware + **full custom admin dashboard views**)
- Custom admin panel at `/admin-panel/` (separate from `/django-admin/`)

### Templates (100% complete)
- Public: `base.html` (OAS nav), all `core/`, `properties/`, `leads/`, `sales_updates/`, `videos/`, `forms/`, `landing/` pages
- Partials: `chatbot.html`, `exit_popup.html`, `property_card.html`
- Admin panel: `base.html`, `login.html`, `dashboard.html`, all CRUD pages for properties/leads/updates/videos/forms/landing/chatbot_kb/site_settings/subscribers

### Static (100% complete)
- `static/css/style.css` — full public site styles, OAS-inspired green/white palette
- `static/css/admin.css` — admin panel styles
- `static/js/main.js` — chatbot fetch, exit popup, footer newsletter

### Deployment (partial)
- `passenger_wsgi.py` — written ✅

---

## 🎯 What You Need to Do (in order)

### 1. Verify migrations compile (CRITICAL — do this FIRST)
```bash
cd /path/to/tdkhomes
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
```
**If any model errors appear, fix them.** The most likely issues:
- Missing fields referenced in views (check `apps/properties/models.py` Property.LISTING_TYPES, STATUS_CHOICES, `feature_list` property, `price_display` property)
- Missing Lead.SOURCE_CHOICES, STATUS_CHOICES (used in admin/views)
- Missing `landing_page` FK on Lead model (referenced in landing_pages/views.py)
- `ckeditor_uploader` import — if it's not in INSTALLED_APPS, swap `RichTextUploadingField` for `RichTextField` or plain `TextField`

### 2. Create `seed_demo` management command
Path: `apps/core/management/commands/seed_demo.py`

```python
from django.core.management.base import BaseCommand
from apps.core.models import SiteSetting, Testimonial, FAQ
from apps.properties.models import PropertyCategory, Location, Property
from apps.chatbot.models import ChatbotKnowledge

class Command(BaseCommand):
    help = "Seed demo data for first-time setup"
    def handle(self, *args, **opts):
        site = SiteSetting.get()
        if not site.site_name:
            site.site_name = "TDK Homes"
            site.tagline = "Your Trusted Real Estate Partner"
            site.phone = "+234 (0) 816-553-5147"
            site.email = "info@tdkhomes.ng"
            site.whatsapp_number = "2348165535147"
            site.address = "Abuja, FCT, Nigeria"
            site.hero_title = "Find Your Dream Home in Nigeria"
            site.hero_subtitle = "Premium properties, verified lands, and trusted investments."
            site.about_short = "TDK Homes helps clients buy, sell, and rent verified properties across Nigeria."
            site.clients_count = 500
            site.properties_sold = 200
            site.years_experience = 10
            site.locations_covered = 15
            site.popup_enabled = True
            site.popup_title = "Wait! Don't Miss Out"
            site.popup_subtitle = "Subscribe for exclusive property deals."
            site.popup_cta = "Send Me Deals"
            site.chatbot_enabled = True
            site.chatbot_name = "TDK Assistant"
            site.chatbot_greeting = "Hi! How can I help you today?"
            site.save()
            self.stdout.write(self.style.SUCCESS("✓ Site settings"))

        for name in ["Bungalow", "Duplex", "Apartment", "Land", "Commercial"]:
            PropertyCategory.objects.get_or_create(name=name)
        self.stdout.write(self.style.SUCCESS("✓ Categories"))

        for n, s in [("Lekki","Lagos"), ("Ikoyi","Lagos"), ("Maitama","FCT"), ("Wuse 2","FCT"), ("Asokoro","FCT")]:
            Location.objects.get_or_create(name=n, defaults={"state": s})
        self.stdout.write(self.style.SUCCESS("✓ Locations"))

        faqs = [
            ("How do I schedule a property viewing?", "Submit an inquiry on any property page or call us directly. We'll arrange a convenient time within 24-48 hours."),
            ("Are your properties verified?", "Yes — every listing is vetted with verified title documents (C of O, Governor's Consent, or Deed of Assignment)."),
            ("Do you offer payment plans?", "Many properties offer flexible payment plans. Contact us for specific terms on any listing."),
            ("What documents do I need to buy?", "Typically: valid ID, proof of address, and proof of funds. We'll guide you through the full process."),
        ]
        for q, a in faqs:
            FAQ.objects.get_or_create(question=q, defaults={"answer": a})
        self.stdout.write(self.style.SUCCESS("✓ FAQs"))

        kb = [
            ("Pricing", "Property prices vary by location and type. Browse listings or tell me your budget and I'll suggest options.", "price,cost,how much,budget,afford"),
            ("Land for sale", "We have verified land listings across Lagos, FCT, and other states. All come with proper title documentation.", "land,plot,acre,buy land"),
            ("Mortgage", "We work with several mortgage providers. Tell me your budget and I'll connect you with the right financing option.", "mortgage,finance,loan,payment plan"),
            ("Schedule viewing", "Sure! Share your contact details and an agent will reach out within 24 hours to arrange a viewing.", "viewing,inspection,visit,tour,schedule"),
        ]
        for q, a, k in kb:
            ChatbotKnowledge.objects.get_or_create(question=q, defaults={"answer": a, "keywords": k})
        self.stdout.write(self.style.SUCCESS("✓ Chatbot KB"))
        self.stdout.write(self.style.SUCCESS("\n✅ Demo data seeded! Run python manage.py createsuperuser then runserver."))
```
Don't forget `apps/core/management/__init__.py` and `apps/core/management/commands/__init__.py` (empty files).

### 3. Create cPanel deployment files

**`.htaccess`** (project root):
```apache
# cPanel Passenger handles Python — these are for static/media
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^static/(.*)$ /static/$1 [L]
  RewriteRule ^media/(.*)$ /media/$1 [L]
</IfModule>
```

### 4. Create `README.md` (project root)
A user-facing readme covering:
- Local setup: clone → venv → pip install → cp .env.example .env → migrate → seed_demo → createsuperuser → runserver
- URLs: `/` (public), `/admin-panel/` (custom dash), `/django-admin/` (Django admin), `/p/<slug>/` (landing pages)
- cPanel deployment steps:
  1. Push to Git (GitHub/GitLab/Bitbucket)
  2. cPanel → Git Version Control → Clone repo into `~/repositories/tdkhomes/`
  3. cPanel → Setup Python App → Create app:
     - Python version: 3.10+
     - App root: `repositories/tdkhomes`
     - App URL: your domain
     - Startup file: `passenger_wsgi.py`
     - Entry point: `application`
  4. In the cPanel Python App page, add env vars: `DJANGO_SECRET_KEY`, `DEBUG=False`, `ALLOWED_HOSTS=yourdomain.com`, `DATABASE_URL=postgres://...` (from cPanel → PostgreSQL Databases)
  5. Run pip install: cPanel → Run Pip Install → it auto-uses requirements.txt
  6. Open Terminal in cPanel → `source ~/virtualenv/repositories/tdkhomes/3.10/bin/activate` → `cd ~/repositories/tdkhomes` → `python manage.py migrate` → `python manage.py collectstatic --noinput` → `python manage.py createsuperuser` → `python manage.py seed_demo`
  7. Restart Python App from cPanel
  8. Add `.htaccess` rules for static/media if needed (often handled automatically)

### 5. Run a smoke test
```bash
python manage.py check          # should report 0 errors
python manage.py runserver
```
Open http://127.0.0.1:8000/ — should show homepage with hero, search widget, trust indicators, etc.
Open http://127.0.0.1:8000/admin-panel/ — should show login.

### 6. Common issues to watch for
- **CKEditor not installed** → either add `'ckeditor', 'ckeditor_uploader'` to INSTALLED_APPS and `path('ckeditor/', include('ckeditor_uploader.urls'))` to config/urls.py, OR swap `RichTextUploadingField` for plain `TextField` in models.
- **Missing migrations** → just re-run `makemigrations` for the affected app.
- **TEMPLATES dir** → ensure settings.py has `'DIRS': [BASE_DIR / 'templates']`.
- **STATICFILES_DIRS** → ensure `[BASE_DIR / 'static']` is set.
- **Lead.STATUS_CHOICES / SOURCE_CHOICES** must exist as class attributes (not just on fields) for admin views to import them.
- **Property.LISTING_TYPES / STATUS_CHOICES** same — class-level tuples.
- **`feature_list` property on Property** — should split `self.features` by newlines.

### 7. After everything works locally
```bash
git init
git add .
git commit -m "Initial: TDK Homes Django build (85% from Claude, completed in Claude Code)"
git remote add origin <your-repo-url>
git push -u origin main
```

Then follow the cPanel deployment steps in the README.

---

## 📁 File Tree Reference
```
tdkhomes/
├── apps/
│   ├── analytics/      (custom admin dashboard + visitor tracking)
│   ├── chatbot/        (rule-based bot + KB)
│   ├── core/           (SiteSetting, FAQ, Testimonial, Team)
│   ├── forms/          (downloadable PDF forms with lead gating)
│   ├── landing_pages/  (custom landing pages at /p/<slug>/)
│   ├── leads/          (lead capture from all sources)
│   ├── newsletter/     (email subscribers)
│   ├── properties/     (main property catalog)
│   ├── sales_updates/  (blog/news posts)
│   └── videos/         (property tours)
├── config/             (settings, urls, wsgi, asgi)
├── static/css/         (style.css public, admin.css panel)
├── static/js/          (main.js)
├── templates/          (all HTML templates)
├── media/              (user uploads, gitignored)
├── manage.py
├── requirements.txt
├── passenger_wsgi.py   (cPanel entry point)
├── .env / .env.example / .gitignore
└── README.md           ← YOU CREATE THIS
```

## 🎨 Design Notes (already implemented in CSS)
- Primary color: `#1a8754` (forest green, OAS-inspired)
- Accent: `#ffc107` (gold)
- Dark: `#1a2e35`
- Fonts: Inter (body), Playfair Display (headings)
- Bootstrap 5.3.3 + Bootstrap Icons via CDN

## ⚠️ Important Decisions (already made, don't change)
- **Chatbot**: Rule-based only (no API key). Code falls back automatically when `ANTHROPIC_API_KEY` is empty.
- **DB**: SQLite for dev, PostgreSQL for prod (via `DATABASE_URL` env var).
- **Deployment**: cPanel via Passenger WSGI (NOT Render/Railway/Heroku).

---

**You've got this. The hard part (130+ files of models, views, templates, CSS) is done. You just need to verify it boots, write the seed command + README, and ship it.**
