How staciax/django-book-store works
Project type and purpose
• This is a full‑stack Django web application serving an academic e‑commerce platform for novels, anime, and comic books.
• It uses:
• Django for the backend (MVC pattern with apps “store” and “user”)
• A Next.js‑style file‑based router under store/routes for server‑side rendered pages
• Tailwind CSS and vanilla JS for frontend styling and interactive widgets
• PostgreSQL as the relational database
• A Docker Compose setup for containerized deployment
File structure
• Top‐level: Docker config (Dockerfile, docker-compose.yaml, .env.example, entrypoint.sh), Makefile, Python/Node configuration.
• app/: Django project configuration (settings, ASGI/WSGI, URLs).
• store/: Main shop app containing:
• models/, migrations/ (data layer)
• views/, routes/ (presentation and routing layer)
• templates/, static/ (static assets and HTML templates)
• forms/, admin/, context_processors/ (auxiliary modules)
• core/routers.py implements the custom “page.py” render logic
• user/: Authentication models and admin
• Node tooling: package.json, Tailwind config, ESLint, Prettier
README insights
• Describes features: membership, search, cart, payment, order history
• Emphasizes environment variables for Django, payment (PromptPay), and Postgres
• Explains file‑based routing like Next.js under store/routes
Main components
a. Client
• Browser requests HTML pages, CSS, JS assets
• Interacts (via forms, AJAX) with backend APIs for cart, login, checkout
b. Reverse Proxy / Web Server (optional)
• Nginx or Gunicorn/ Daphne container in front of Django
• Serves static assets, routes dynamic requests to Django ASGI/WSGI
c. Django Backend
• app/ project: global settings, URL dispatcher
• store/ app:
• Models (products, users, orders, payments, etc.)
• Views & routers (views/ + routes/), template rendering
• Admin interface (admin/)
• user/ app: user model and authentication
d. Database
• PostgreSQL container managed via Docker Compose
e. Static‑build Tooling
• Node container for Tailwind CSS (npm run dev), ESLint, Prettier
f. External Services
• PromptPay payment API
Relationships and interactions
• Client → Web Server
• GET/POST requests for pages, form submits, API calls
• Web Server ↔ Django ASGI/WSGI
• Django handles routing (app/urls.py + store/routes) and view logic
• Django → PostgreSQL
• ORM queries/transactions for products, users, orders
• Django → PromptPay API
• Payment initiation and callback handling
• Node/Tailwind process → Static assets
• Generates CSS and JS which are served by Web Server
Architectural patterns and principles
• MVC:
• Models in store/models and user/models
• Views/Controllers in store/views and store/routes
• Templates in store/templates
• File‑based routing inspired by Next.js under store/routes
• Modular Django apps (separation of store vs. user)
• Containerization and environment‑driven configuration
Important details to capture
• Django’s custom router layer (store/core/routers.py) for auto‑detecting templates
• The split between template‑based pages (.html) and their corresponding page.py handlers
• The administrative interface (/admin/) backed by store/admin/*.py
• Environment variables driving secrets, DB connections, and payment credentials
• The Docker Compose relationship between Django, Postgres, and Node/Tailwind