How aztfirespell/frogmiearhquake works
Project Overview and Type
• This project is a full-stack application made for a technical evaluation. It combines a Ruby on Rails backend with a React frontend.
• The backend (built with RoR) serves as an API provider exposing endpoints to retrieve earthquake data and related comments. It also includes a scheduled task (FetchAndSaveDataJob) to fetch and store earthquake records.
• The frontend (located in the ‘client’ folder) is a React application that consumes these API endpoints, enabling users to view earthquake information and interact with the system.
Main Components
a. Frontend Client:
• React-based application (inside the “client” directory).
• Components like AppRoutes and NavBar, along with feature-specific components for listing earthquakes and comments.
• Communication via HTTP calls (fetching data) to the backend API.
b. Backend Server:
• Ruby on Rails application (root and “app” folder) with standard MVC architecture.
• API Controllers (located under app/controllers/api/v1) handling endpoints (features, comments etc.).
• Background jobs such as FetchAndSaveDataJob which fetch external earthquake data and write to the database.
• Models for Earthquake and Comment with associations.
• Additional layers like channels (for ActionCable), initializers, and mailers (if needed).
c. Database:
• SQLite database used for storing earthquake data and comments.
• Schema and migrations (under “db/migrate” and db/schema.rb) that define how data is structured and maintained.
d. External API Integration:
• Although not fully detailed, there is clear functionality to fetch earthquake data from an external API (triggered by the Rails runner command).
e. Containerization & Deployment:
• Docker configuration (Dockerfile, docker-compose.yml, and related files in the “client” and root) are in place to build and run the application in containers.
Relationships and Data Flows
• The React frontend interacts with the Rails backend through well-defined API endpoints (documented in the README).
• The backend exposes RESTful endpoints to get a list of earthquakes, single earthquake details, filtered queries, and comment functionality.
• A background job (FetchAndSaveDataJob) periodically (or via manual trigger) fetches data from an external earthquake data service and persists it to the SQLite database.
• The database acts as the persistent store for both earthquakes and user-generated comments.
• The Rails application may also include real-time features via ActionCable (as hinted by the “app/channels” structure).
Architectural Patterns and Design Principles
• MVC (Model-View-Controller) pattern in the backend.
• Separation of concerns: The client folder exclusively handles the React user interface while the server folder deals with API endpoints and business logic.
• Containerization using Docker to ensure consistency across development and production environments.
• RESTful API design for clear and standardized endpoints.
• Use of job scheduling (or manual trigger) to handle batch processing of external API data.