How rubenperezm/robda works
Project type and purpose
• This is a full-stack web application (“roBDa”), a quiz-based learning platform.
• The back end is a Django REST API (“api/”), structured as a monolithic Django project with multiple “apps” (base, eventos, partidas, preguntas, stats, users).
• The front end is a Next.js React application (“web/”), using both server-rendered pages and Next.js API routes as a BFF layer.
File structure
Top level:
• api/ – Django project
– api/api/ – Django settings, URLs, WSGI/ASGI
– api/apps/… – Six Django apps, each with models, serializers, viewsets, routers, migrations
– manage.py, requirements.txt, media/ (uploaded images)
• web/ – Next.js front-end
– public/ – static assets (logos, flags, avatars)
– src/pages/ – page components and Next.js API routes under pages/api
– src/components, sections, layouts, utils, hooks, contexts, theme – React UI code, HOCs, context providers
– .env.example, package.json, next.config.js
• robda-venv/ – Python virtual environment
README for additional insights
• Two main modes: “Modo repaso” (infinite personalized quiz) and “Modo online” (competitions + duels).
• Competitions have three phases: question creation, quiz play, reporting/voting.
• Real-time play with friends (“Jugar con Amigos”) vs. solo study.
Main components
a. Client browser (Users)
b. Next.js front-end server
• Static/SSR pages for UI
• Next.js API routes (“pages/api/*”) as BFF (handles authentication, token refresh, session, and proxies to Django)
c. Django REST API server
• Django project entrypoint (WSGI/ASGI)
• Apps:
– users (authentication, registration, password, profiles)
– eventos (manage quiz events)
– partidas (duels, rapid-play logic)
– preguntas (question bank, topics, images)
– stats (aggregation endpoints)
– base (shared models, pagination, permissions)
• Media storage (/media for question images)
d. Database (relational, e.g., PostgreSQL or SQLite in dev)
e. External services (if applicable – email SMTP for password reset, file storage for images)
Relationships and interactions
• Browser ↔ Next.js pages (HTTP/HTTPS): user navigates to UI, SSR or SSG pages render React components.
• Browser ↔ Next.js API routes (XHR/Fetch): login, refresh, quiz start, etc.
• Next.js API routes ↔ Django REST API (HTTP/REST + JSON): the BFF layer routes traffic to the appropriate API endpoints.
• Django REST API ↔ Database (ORM calls): storing users, questions, stats, events.
• Django REST API ↔ Media storage (file I/O or object store): store/retrieve question images.
• Optional: Django REST API ↔ Email service for notifications/reporting.
Architectural patterns and design principles
• BFF (Backend For Frontend) with Next.js API routes
• MVC pattern in Django (models, serializers, viewsets, routers)
• Component-based UI in React, using HOCs and React Context for auth and theming
• Separation of concerns: authentication, question management, gameplay logic, reporting, statistics each live in their own Django app
• Use of environment variables (.env files) for config in both layers