How ndturng/data_management_ca works
Project type and purpose
• This is a full-stack Django web application (“data_management_CA”) whose purpose is to let users manage police-officer data (CRUD operations, search, file uploads for images/PDFs).
• Key indicators: Django folder structure (manage.py, settings.py, urls.py), a custom “officers” app, a “theme” app for styling, Node-based build files (package.json, Tailwind config), and instructions to use MySQL.
File structure
• Top-level “myapp” contains the Django project configuration (settings, wsgi, asgi, urls).
• Two Django apps:
• “officers”: models.py, views.py, forms.py, templates/officers/*, urls.py, tests.py, utilities.
• “theme”: shared base.html template, static resources (compiled CSS, fonts) and static_src for Tailwind/CSS pipeline.
• Static and static_src folders plus package.json/node_modules: a Node.js pipeline compiles Tailwind CSS and PostCSS into theme/static/css/dist/styles.css.
• Configuration files: .flake8, .prettierrc, Makefile (commands for migrations and runserver).
• requirements.txt / requirements-dev.txt define Python dependencies; package.json defines frontend build dependencies.
README for additional insights
• Architecture is monolithic: one Django server talks to a MySQL database, serves HTML templates, static assets, and handles file uploads.
• Uses Django’s built-in templating plus custom theme, Django admin for data management, and media file handling for images/PDFs.
Main components
a. Client-side (Browser)
• Users access via web browser (HTTP/HTTPS).
b. Web/Load Balancer (optional)
• If deployed to production, could sit behind Nginx or a load balancer.
c. Django Application Layer
• Django’s WSGI/ASGI server (e.g., Gunicorn/Uvicorn).
• “myapp” project router & settings.
• “officers” app (Models → Views → Templates).
• “theme” app (static templates & styling).
d. Static Asset Build Pipeline
• Node.js & npm → Tailwind/PostCSS → compiled CSS + JS in static/css and static/js.
e. Media Storage
• Local file storage (media folder) for uploaded images & PDFs (could be extended to S3).
f. Database
• MySQL database instance (OFFICERS_TABLE) accessed via Django ORM.
g. External Services (if any)
• SMTP/email for notifications (if configured later), external identity providers (optional).
Relationships and interactions
• Browser → HTTP request → Django WSGI/ASGI layer.
• URL router → appropriate app (officers URLs or admin URLs).
• Views invoke Django ORM → MySQL for CRUD.
• Views render templates (templates/officers/*.html or theme/base.html).
• Static assets served either by Django staticfiles or a CDN: CSS, JS, fonts.
• File uploads from browser → Django view → saved to media storage.
• Node build pipeline watches static_src, regenerates compiled CSS/JS.
• Admin user configured via Django admin panel accessing the same ORM cycle.
Architectural patterns & design principles
• MVC (Model-View-Template) pattern in Django.
• Separation of concerns: “officers” app for domain logic, “theme” app for presentation.
• Monolithic deployment but modular code organization (multiple apps).
• Asset pipeline decoupled from runtime server (build step via Node).
Technologies & frameworks to highlight
• Python 3.10 + Django framework.
• Django ORM + MySQL (django.db.backends.mysql).
• Node.js + npm + TailwindCSS/PostCSS for styling.
• Django templating engine.
• Optional WSGI server (Gunicorn) or ASGI (Uvicorn) for async.
• Makefile scripts for common tasks.
Detail
• Folders/files if needed (e.g., “officers/models.py → DB schema”; “officers/templates → HTML views”).
• Essential modules: models, views, forms, utils.