How naughtycomputer/naughty-be-django works
Project type and purpose
• From the file tree and README, this is a Django-based backend service (“Naughty-BE-Djaongo”) for a 2025 graduation project.
• Its primary function is to power a chat system with GPT integration and Retrieval-Augmented Generation (RAG) modules for financial/annuity information.
File structure
• Top-level:
• Pipfile / Pipfile.lock + requirements.txt – Python dependencies
• .github/workflows/django-ci.yml – CI pipeline for testing
• naughtyDjango/manage.py – Django CLI entrypoint
• Project package “naughtyDjango/” contains two main parts:
a) chat app under “naughtyDjango/chat/”
– models.py, views.py, urls.py, admin.py, tests.py
– gpt_service.py – interfaces with OpenAI or another LLM
– rag/ folder with annuity_rag.py and financial_product_rag.py
b) core Django config under “naughtyDjango/naughtyDjango/”
– settings.py, urls.py, wsgi.py, asgi.py
– db_routers.py – multi-DB routing logic?
– utils/ (custom exception handler, response wrapper)
– constants/ (error and success codes)
• Migrations folder for database schema.
Key insights from README
• Very brief, confirming it’s strictly the Django backend layer.
• No explicit mention of frontend or additional microservices.
Main components
a. API Layer (Django REST endpoints)
– HTTP(S) Ingress → django.urls routing → chat.views
b. Business Logic Layer
– ChatView / ChatService
– gpt_service.py – orchestrates prompt construction and calls to external LLM API
– RAG modules (annuity_rag.py, financial_product_rag.py) – retrieval + augmentation
c. Data Access Layer
– Django ORM models in chat/models.py and core models.py
– Database(s) behind db_routers.py (could be one or more Postgres/MySQL instances)
d. Utilities
– custom_exception_handler & custom_response for uniform error/success wrappers
– constants for standardizing response codes
e. External Services
– OpenAI API (or another GPT provider)
– Potential document store for RAG (if referenced) or internal tables
f. CI Pipeline
– .github/workflows/django-ci.yml runs tests and linting on push/PR
Relationships & interactions
• Client → Django API endpoints
• Endpoint handler → invokes business logic (views → gpt_service + RAG)
• Business logic → reads/writes from Database via ORM
• Business logic → external GPT API over HTTPS
• custom_exception_handler applied globally to catch and format errors
• db_routers route certain models to specific databases if configured
Architectural patterns & principles
• Layered architecture: Presentation (URLs/Views), Service (GPT/RAG), Data (ORM)
• Separation of concerns: RAG modules decoupled from core chat logic
• Config-driven DB routing for sharding/multi-tenant if needed
• Utility modules for cross-cutting concerns (errors, responses)
Final recommendations
• Detail external dependencies (GPT API, CI pipeline, DB instances).