How codaqui/tutor works
Project Type and Purpose
• Full-stack, multi-service intranet application.
• Core web interface built on Django (Python) with multiple reusable “apps” (modules).
• Supplementary microservices for WhatsApp integration (Node/Express + Baileys & FastAPI), AI (Ollama), reverse-proxy (NGINX), and databases (Postgres, MongoDB).
File Structure
Top-level containers:
– Django monolith (“codaqui” project folder) orchestrating the intranet logic.
– Additional services:
• whatsapp_api (Node.js + Express + Baileys)
• whatsapp_app (Python + FastAPI business logic + Ollama API calls)
• ollama (AI model runner)
• nginx (reverse proxy configuration)
– Configuration files: Dockerfile, docker-compose.yml (dev & prod), env examples, GitHub workflows.
Inside the Django monolith:
• Six Django “apps”: core, users, student, wallet, github_service, whatsapp_messages.
• Shared templates directory.
• URL routing modules, models, views, forms, tests in each app.
• Standard MVC pattern (Models → Views → Templates).
Extract Insights from README
– External user → CloudFlare → NGINX → Django app
– Django app → Postgres
– Django (whatsapp_messages) → FastAPI whatsapp_app → Ollama (ACL)
– FastAPI → whatsapp_api (pooling messages via Baileys) → WhatsApp and MongoDB session store
• Features: GitHub OAuth & team membership validation, student profile, wallet/points ledger, GitHub issue management.
Main Components & Interactions
a. Components (group by container/service):
1. Client / Web Browser
2. NGINX (reverse proxy)
3. Django Intranet Service
– Sub-components: core, users, student, wallet, github_service, whatsapp_messages
4. Postgres Database
5. GitHub REST API (external)
6. whatsapp_app (FastAPI)
7. Ollama (local AI model service)
8. whatsapp_api (Express + Baileys)
9. MongoDB (session/auth state for Baileys)
10. WhatsApp Network (external)
b. Interactions & Dataflow:
• User → NGINX: incoming HTTP/HTTPS requests (serving static & dynamic content).
• NGINX → Django: proxies to Django’s WSGI/ASGI interface.
• Django → Postgres: ORM-based CRUD operations.
• Django (github_service) → GitHub API: OAuth token exchanges, issue fetch/creation.
• Django (whatsapp_messages) → whatsapp_app: POST/GET messages & webhooks.
• whatsapp_app → Ollama: AI completions, ACL requests.
• whatsapp_app → whatsapp_api: queueing outbound messages or handling inbound events.
• whatsapp_api ↔ WhatsApp: long-polling or WebSocket via Baileys; uses MongoDB for auth/session.
c. Architectural Patterns & Principles:
– Clear layer separation: Web/API (Django) vs. message-processing microservices.
– Modular design: each Django “app” addresses a bounded context (students, wallet, GitHub, etc.).
– Service-oriented approach for messaging and AI.
– Containerization & infrastructure as code (Docker Compose, GitHub Actions).
Final Checklist
[ ] Container boundaries drawn (NGINX, Django, Microservices, Databases).
[ ] Intra-container subcomponents identified (six Django apps).
[ ] Deployment artifacts indicated (Docker Compose, GitHub Actions CI/CD).