How cisagov/decider works
Main Components
• Web Server / Application Layer:
– Represent the core Python application. This is centered around the “app” directory, where you have configuration files (conf.py, constants.py, env_vars.py), route-handling modules (routes/*), and utility scripts.
– Include the “decider.py” entry-point and “decider.service” files, suggesting service management.
– Note that uWSGI configuration files (uwsgi.ini and docker-specific ones) indicate that the application is served via uWSGI.
• Frontend/UI:
– Identify the static assets stored in “app/static” (CSS, JavaScript, fonts) and HTML templates under “app/templates”. These work together to deliver the responsive, login-less user interface that shows the Question Tree, Search, and other pages.
– Inclusion of third-party libraries (Bootstrap, AlpineJS, jQuery, etc.) is crucial to the frontend’s function.
• Database Layer:
– The project’s “app/utils/db” folder contains subdirectories (actions, create, destroy, read, dumps) which indicate custom scripts to manage and interact with the database (e.g., adding versions, dumping data or tables).
– Docker environment and environment variables (e.g., DB_ADMIN_PASS, DB_KIOSK_PASS) as specified in the README confirm the importance of this layer.
• Configuration & Deployment:
– The presence of multiple environment files (.env.docker, .env.manual) shows that configuration is carefully managed.
– The “config” and “default_config” directories house default parameters, build sources (which include JSON files for ATT&CK content), and certificates.
– Docker Compose files (docker-compose.yaml) and the Docker directory (docker/web with its Dockerfile and entrypoint scripts) indicate deployment via containers.
– CI/CD workflows (inside .github/workflows) suggest automated testing/security checks.
Relationships and Interactions between Components
• The User interacts with the Frontend (browsers load HTML from the “app/templates” and assets from “app/static”).
• The Frontend communicates with the Python Web Server via HTTP routes defined under “app/routes”. These routes serve pages (e.g., admin, auth, search) and possibly API endpoints.
• The Web Server, upon receiving requests, interacts with the Database using the utility scripts (in app/utils/db) for actions like reading, creating, updating, or dumping data.
• Configuration and Environment Variables are injected into the app at startup (via .env files and Docker Compose settings).
• The entire setup is deployed within Docker containers orchestrated by Docker Compose, making sure that changes to the configuration trigger container rebuilds.
Architectural Patterns and Technologies
• MVC / Route-based Pattern: The division between “routes” (controllers/views) and “templates” (views) clearly outlines an MVC-like separation.
• Containerization: With Docker and Docker Compose, the application is designed for containerized environments.
• Modular Database Management: The use of separate scripts for creation, reading, destruction, and dumping tables indicates a modular approach to database management.
• Config & Environment Separation: Utilizing multiple configuration files and environment variables ensures that code remains environment-agnostic.