How jacekong/borderless-api works
Project Type & Purpose
• This is a full-stack, monolithic Django web application (with Django REST Framework) that serves:
– Blog posting (CRUD via REST endpoints)
– Real-time messaging (WebSockets via Django Channels)
– Friend management (REST endpoints)
– User authentication/registration (including OAuth and email)
– Static HTML/JS/CSS frontend plus optional Flutter mobile client
• It also includes a “Spatialite Tools” folder containing geospatial utilities (EXIF loader, raster tools, etc.).
File Structure
Top level:
• Spatialite Tools (GPL/MPL-licensed geospatial command-line tools)
• borderlessApi/ (Django project directory with settings.py, asgi.py, celery.py, wsgi.py)
• api/, chat/, friend/, notification/, tracking/, users/ (six Django “apps” each encapsulating one domain)
• static/ & templates/ (server-rendered assets, CSS/JS pipelines, Tailwind config)
• manage.py, package.json (front-end build), requirements.txt, Redis config hint
Key Runtime Components
• ASGI Server (e.g., Daphne or Uvicorn)
• Django Apps
– api (blog endpoints + optional feed templates)
– chat (WebSocket consumers for realtime messaging)
– friend (REST for friend requests)
– notification (REST + WebSocket consumer for push notifications)
– users (user profile + serializers)
– tracking (middleware for analytics, optional background tasks)
• Django REST Framework (serializers + viewsets)
• Django Channels
– Channel Layer backed by Redis
– WebSocket routing in chat/routing.py & api/routing.py
• Celery Worker (background task queue, broker = Redis)
• Relational Database (SQLite for dev, PostgreSQL in prod)
• Redis (channel layer & Celery broker)
• Static/File Server (WhiteNoise or Nginx) serving CSS/JS/images
• External Services
– OAuth Provider (Google login via allauth)
– SMTP Email Service (password reset)
A. Components
1. Clients (Web Browser & Flutter Mobile App)
• Them issuing both HTTP(S) and WebSocket requests
2. Reverse Proxy / Load Balancer
• (Optional) Nginx or Cloud Load Balancer in front of ASGI
3. ASGI Application Server
• Single rectangle labeled “Django ASGI Server (borderlessApi)”
• Inside, group six app-modules: api, chat, friend, notification, users, tracking
• Django Channels consumers next to chat & notification modules
4. REST API Layer
• As a boundary around DRF viewsets/serializers in each app
5. WebSocket Layer
• Ws/chat/<user_id>/ and ws/notifications/ endpoints
6. Channel Layer (Redis)
7. Celery Worker
• Separate rectangle connected to Redis broker for background jobs (e.g., email notifications)
8. Database
9. Static Asset Server
10. External OAuth & Email Services
B. Data Flows & Relationships
– Celery: ASGI or apps enqueue tasks → Redis broker → Celery worker → (optional) DB or external services
– OAuth flow: ASGI → Google OAuth → callback → ASGI
– Email flow: Celery worker → SMTP → user inbox
C. Architectural Patterns & Principles
– Modular “Django app” decomposition by domain
– RESTful endpoints for CRUD on posts, friends, users, notifications
– Event-driven, real-time messaging via Channels (pub/sub pattern)
– Asynchronous background processing (Celery)
– Static asset pipeline (Tailwind, Webpack) for efficient client payloads
Don’t Overthink—Be Detailed
• Both REST & WebSocket layers
• Runtime dependencies (DB, Redis, Celery, external OAuth/email)