How jenishp619/farm_n_food works
Project Type and Purpose
• This is a full-stack, monolithic Django web application (“Farm_n_Food”) that connects local farmers to consumers.
• It follows Django’s Model-View-Template (MVT) pattern:
• Models (farmfoodapp/models.py) for data
• Views (farmfoodapp/views.py, farmfoodapp/actions.py) for business logic
• Templates (farmfoodapp/templates/…) for presentation
• Static assets (CSS, JS, images) live under /static.
File Structure & Architectural Insights
• Top-level files:
• Procfile, .gitlab-ci.yml: deployment on Heroku/GitLab CI
• manage.py: Django CLI entry point
• requirements.txt: Python dependencies
• db.sqlite3 (or MySQL in production)
• farmfood/: Django project settings (settings.py), URL routing (urls.py), ASGI/WGI adapters
• farmfoodapp/: core application (models, serializers, views, URLs, email helpers) + migrations + templates
• static/: served by Django (in dev) or by a CDN/Nginx (in production)
A. Client Tier
• Web Browser / Mobile WebView
• Renders HTML/CSS/JS (templates + static)
B. Presentation Tier
• Load Balancer (Heroku router or Nginx)
• Gunicorn (WSGI) / Daphne (ASGI) processes
C. Application Tier
• Django project (“farmfood”)
• farmfoodapp application
• URL router → view functions/classes → serializers / actions → models
D. Data Tier
• Relational Database (SQLite for dev, MySQL in production)
• Django ORM (models.py)
• Migrations maintaining schema
E. External Services
• SMTP Email Service (farmfoodapp/send_mail.py)
• Optional: CDN or S3 for static/media files
• 3rd-party analytics (e.g., Chart.js in Charts.html)
Relationships & Interactions
• Static files served either by Django’s staticfiles app or offloaded to Nginx/CDN
Architectural Patterns & Principles
• MVT separation of concerns
• Layered architecture:
• Presentation (templates, static)
• Business logic (views, actions)
• Data access (models, migrations)
• Configuration–Code separation (settings.py, Procfile, .gitlab-ci.yml)
• Twelve-Factor App principles for Heroku deployment
Checklist
• [ ] Clear labels matching file-tree names (e.g., “farmfood/urls.py → URL Dispatcher”)
• [ ] Notes on deployment artifacts (Procfile, .gitlab-ci.yml)