How gustavo210/be-the-hero works
Main Components
• Backend API Server: This is located in the “backend” folder. It handles HTTP requests, contains controllers for ONGs, profiles, sessions, and incidents, and also deals with database interactions (via migrations and connection setup using Knex).
• Database: The backend uses SQLite (configured via Knex in the migrations). This component should be represented as a persistent storage layer.
• Web Frontend: Found in the “frontend” folder, it includes pages such as Logon, New Incident, Profile, Register, and is responsible for interfacing with the backend API via the defined routes.
• Mobile App: Present in the “mobile” folder, which is built with React Native (using Expo) and has similar pages (Incidents, Detail) as the web client. It also interacts with the backend API.
• API Communication Layer: Both web and mobile clients use an “api.js” service to define endpoints and make HTTP calls to the backend. This layer is implicitly a part of the client applications.
• Integration & Testing: There’s a unit and integration test structure in the backend (shown in backend/tests) that verifies the functionality of components like unique ID generation and endpoint integrations.
Relationships and Interactions
• The Web and Mobile clients send HTTP requests (e.g., POST /ongs, GET /incidents, etc.) to the Backend API.
• The Backend processes these requests via controllers, interacts with the SQLite database (using Knex for queries and migrations), and then returns responses to the clients.
• Data flows from the clients to the server (and vice versa) through clearly defined REST endpoints.
• Separation of concerns: Controllers handle routing logic, while the database layer manages persistence.
Important Architectural Patterns
• Separation of Concerns: Frontend (presentation logic), Backend (API and business logic), and Database (data persistence) are separately managed.
• RESTful Design: Several endpoints are provided for different resources (ONGs, sessions, incidents) that use common HTTP verbs.
• Modular Structure: Within the backend, code is modularly divided into controllers, routes, database, and utility functions.
Final Touches
• Every component is clearly labeled.
• To highlight the use of technologies like Node.js, Express, React, React Native, Knex, and SQLite.