How davidmensahedem/reportly works
Project Type and Purpose
• Reportly is a NodeJS API service built using ExpressJS and Postgres.
• Its main purpose is to allow clients to create and list incident reports. Each report not only captures incident details but also retrieves weather information for the provided location using the Open Weather Map API.
• Given the simplicity of the file tree (just LICENSE and README), most of the architectural decisions are documented in the README, which primarily focuses on the API endpoints and the feature set.
Analyzing the File Structure
• Since there is only a LICENSE and README.md at the top, we can infer that the project might be relatively small or that the file structure details are omitted. However, the README gives us enough cues to outline the backend components.
• The project likely uses separate modules or folders for routing, controller logic, and database interactions even if those details are not explicitly present in the file tree.
Main Components
a. API Gateway / ExpressJS Server:
• NodeJS application hosting the ExpressJS server.
• Endpoints such as GET /incidents, GET /incident/:id, and POST /incident.
b. Database (Postgres):
• Postgres database where incident records are stored.
• That the SQL file provided in the repository (mentioned in the README) is used to import the schema/data.
c. External Weather Service:
• Integration with the Open Weather Map API.
• That when an incident is reported or retrieved, the current weather report for the location is fetched via this external service.
d. (Optional) Middleware/Utilities:
• Usage of packages like morgan (for logging), cors (for cross-origin resource sharing), bcrypt (if used for security/sign-in aspects), and axios (for making HTTP calls to the weather API).
Describing Relationships and Interactions
• ExpressJS component receiving incoming HTTP requests.
• Routing from the API endpoints to the controllers or service logic.
• That upon a request:
• The API server may query or update the Postgres database.
• Simultaneously or sequentially, the API server makes an outgoing request to the Open Weather Map API to gather weather data.
• From the client to the ExpressJS server (HTTP requests).
• From ExpressJS server to Postgres (SQL queries) and back.
• From ExpressJS server to the External Weather Service (HTTP call) and back.
Detailed Architectural Patterns and Design Principles
• Even if the project has a simple architecture, note that modular design is vital. The separation of concerns (routing, business logic, data access, external API integration) should be represented.
• That all components interact through clear APIs and that the system is designed to be scalable (e.g., adding more endpoints or integrating additional external services in the future).