Orange County Lettings — Architecture¶
This page describes the high-level architecture of the project: Django apps, URL routing, request flow, templates/static assets, configuration, and logging/monitoring.
Overview¶
Project package:
oc_lettings_siteApplications:
lettings,profilesTemplates: shared in
templates/and app-specific under each appStatic assets:
static/served by WhiteNoise in productionDatabase: SQLite (default). See
oc_lettings_site/settings.py
Components¶
oc_lettings_site¶
Purpose: site-level configuration, root URLs, index page, error handlers, Sentry setup.
Key modules:
oc_lettings_site/urls.py: includes app URLs and error handlersoc_lettings_site/views.py:index,custom_404,custom_500,sentry_debugoc_lettings_site/apps.py: app config and pluralization tweaks
lettings¶
Purpose: manage lettings (list and detail display)
URLs (mounted under
/lettings/):/lettings/,/lettings/<letting_id>/Key modules:
lettings/urls.py,lettings/views.py,lettings/models.py
profiles¶
Purpose: manage user profiles
URLs (mounted under
/profiles/):/profiles/,/profiles/<username>/Key modules:
profiles/urls.py,profiles/views.py,profiles/models.py
Request flow¶
Incoming HTTP request reaches the root URLconf (
oc_lettings_site/urls.py)Request is routed to a view function in the target app (
lettingsorprofiles)The view optionally fetches data via Django ORM and renders a template
A rendered HTTP response is returned
When
DEBUG=Falseand an error occurs: - 404 errors are handled bycustom_404(logs a warning and may send a Sentry message) - 500 errors are handled bycustom_500(logs an error)
URL routing¶
Root URL configuration includes app URLs and admin:
from django.contrib import admin
from django.urls import path, include
from oc_lettings_site import views
urlpatterns = [
path("", views.index, name="index"),
path("lettings/", include("lettings.urls")),
path("profiles/", include("profiles.urls")),
path("admin/", admin.site.urls),
path("sentry-debug/", views.sentry_debug, name="sentry-debug"),
]
Custom error handlers (active when DEBUG=False):
handler404 = "oc_lettings_site.views.custom_404"handler500 = "oc_lettings_site.views.custom_500"
Settings highlights¶
ENV_MODEcontrolsDEBUGandALLOWED_HOSTSStatic files:
STATIC_URL,STATICFILES_DIRS,STATIC_ROOT(WhiteNoise in production)Logging configured with console handlers and per-module loggers
Optional Sentry instrumentation via
SENTRY_DSN
Templates and static assets¶
Base templates in
templates/:index.html,404.html,500.html,base.htmlApp templates in
lettings/templates/lettings/andprofiles/templates/profiles/Static assets in
static/(CSS, JS, fonts, images)
Data model (brief)¶
profiles.Profile: user profile withfavorite_citylettings.Addressandlettings.Letting: normalized address linked One-to-One to a lettingSee Orange County Lettings — Models for details
Logging and monitoring¶
Console logging with standard formatters and per-module loggers
Sentry integration (if
SENTRY_DSNis provided) with Django and logging integrations
Environments and configuration¶
ENV_MODE:devorprodDJANGO_SECRET_KEY: required in productionALLOWED_HOSTS: configured for productionSENTRY_DSN: optional, enables error reporting and tracing
Deployment¶
The app can be containerized (see Orange County Lettings - Docker) and deployed following Deployment & Ops
Static files are served by WhiteNoise; database is SQLite by default
Orange County Lettings