How yatharth0045/12-factor-app works
Project Components
• Main Microservice: Represented by the primary app.py at the project root, built from the Dockerfile in the root directory and launched via docker run on port 8080.
• Admin Microservice: Located under the “admin” directory (with its own Dockerfile and app.py) and deployed separately on port 8081.
• Fluentd Logging Service: Found under the “fluentd” directory (with its Dockerfile and fluent.conf). This service is used to collect logs from the microservices and is connected to external logging systems.
• Redis: A backing service which the applications link to as an external dependency (running on port 6379).
• Elasticsearch and Kibana: Although they are not directly part of the codebase, the README instructs running these services for log searching and visualization (ports 9200 for Elasticsearch and 5601 for Kibana).
Component Relationships and Data Flow
• The main microservice and admin service connect to Redis (through the use of --link in docker commands) for caching or session management.
• Both the main service and the admin service are configured to push logs to Fluentd via the log-driver and log-opt parameters.
• Fluentd then aggregates the logs and forwards them to Elasticsearch (and optionally to stdout) for indexing and logstash formatting.
• Kibana is connected to Elasticsearch to provide a user interface for log analysis.
Architectural Patterns and Design Principles
• 12 Factor Methodology: Emphasize the stateless, isolated deployment of microservices.
• Containerization: Each major component (main service, admin service, Fluentd) is containerized. Represents the principle of dependencies being isolated within each container.
• Dependency Injection: Configurations are passed in via environment variables (.env files) and external service links, ensuring that the codebase does not hard code configurations.