How sivagirivisakan/trail-app works
Main Components
• Frontend: This includes all static assets (CSS, JavaScript, fonts, images) and HTML templates. Notice the "static" folder for assets and the "templates" folder which holds various layout and page files.
• Backend (Flask Application): The core of the app is built using Flask. The main application is defined in app.py with additional business logic split across directories such as "controllers", "views", and "helpers".
• Controllers and Views: The “controllers” directory houses the API endpoints (e.g., API, auth, organisation) which handle incoming requests. The “views” directory further handles the routing for dashboards, organisations, and projects.
• Database Layer: There are dual database components:
• MySQL – for general application data and mutable records.
• ClickHouse – for logging and analytics; especially dealing with immutable and high-query-frequency data.
• Caching: Redis is used to provide a caching layer, as noted in the README.
• Configuration & Environment: Configurations are handled from config.py, .flaskenv, and Docker-related files (Dockerfile, docker-compose.yml) indicate the deployment strategy.
• User actions (e.g., log-in, page interaction) send requests to the Flask server.
• Flask processes these requests with controllers (ex: controllers/api.py for event tracking and controllers/auth.py for authentication) that then interact with controllers/views.
• The backend makes calls to helper modules (e.g., helpers/db.py) to handle business logic related to database interactions.
• Data Storage and Analytics:
• MySQL handles mutable data such as user details or organisational configurations.
• ClickHouse is used for writing and querying high-volume event logs, as per the README explanation (capturing immutable data for analytics).
• Redis acts as a caching layer to improve performance in real-time dashboard updates.
Architectural Patterns and Design Principles
• MVC / Separation of Concerns: The code is separated into controllers, views, and templates for clear responsibilities.
• API-Driven Design: Controllers handle API routes (especially for event tracking) that update databases.
• Layered Architecture: Distinguish between presentation (templates & static), application logic (Flask app, controllers, views), and data layers (MySQL, ClickHouse, Redis).
Technologies and Frameworks
• Flask as the web framework.
• MySQL and ClickHouse as databases differentiated by use case (OLTP vs. OLAP).
• Redis for caching.
• Frontend frameworks and libraries: Argon Dashboard assets, Bootstrap, and custom JS/CSS are used for the UI.
• Docker for containerization and orchestration, as evidenced by Dockerfile, .dockerignore, and docker-compose.yml.