How unfoldadmin/formula works
Project type and purpose
• This is a monolithic, full-stack Django application whose sole purpose is to demonstrate the Unfold admin theme and custom dashboard widgets.
• It provides an admin UI for viewing sample Formula 1 data (drivers, races, standings, etc.) loaded from fixtures.
File structure
• Top-level artifacts:
• Dockerfile & docker-compose.yml → containerized deployment
• pyproject.toml → Python/Poetry deps
• package.json → Node/Tailwind build scripts
• manage.py → Django CLI entrypoint
• “formula/” directory: the Django project & app code (settings, URLs, WSGI/ASGI, models, views, templates, static CSS, fixtures, migrations).
• Templates & static: custom admin/index.html + components under templates/admin/components, plus formula/styles.css for Tailwind extensions.
• Fixtures folder contains JSON data for initial load (users, constructors, races, etc.).
README for additional insights
• Confirms Unfold theme integration via UNFOLD → STYLES in settings.py.
• Describes custom dashboard override: admin index.html + components.
• Shows asset pipeline: npm scripts for tailwind:build and tailwind:watch.
Main components & their relationships
a. Client (Browser/Admin UI)
– Sends HTTP requests; renders HTML/CSS (Unfold + custom Tailwind).
b. Web/Application Layer (Docker “web” service)
– Django app (“formula” package) behind WSGI/ASGI server.
– Loads fixtures on startup; runs migrations.
c. Database (Docker “db” service, e.g. PostgreSQL)
– Stores domain tables (drivers, circuits, standings).
d. Static Asset Pipeline (Local or CI)
– Node.js + TailwindCSS generates compiled CSS from templates & styles.css.
– Output served as Django static files (via Whitenoise or Nginx).
e. Docker Compose orchestration
– Defines and networks web and db services; mounts volumes.
f. Development tooling
– GitHub (repo, Dependabot), pre-commit hooks, Docker registry.
Architectural patterns & design principles
• Monolithic MVC:
• Models layer (“formula/models.py”)
• Views & forms (views.py, forms.py)
• Templates (formula/templates)
• Layered separation: presentation (templates), application logic (views/forms), domain (models), infrastructure (settings, Docker).
• Theme plug-in pattern: UNFOLD settings + context processors feeding into admin templates.
• External asset pipeline: decoupled CSS build via npm.