Implement API with authentication and weather integration#288
Open
re-nanashi wants to merge 1 commit into
Open
Implement API with authentication and weather integration#288re-nanashi wants to merge 1 commit into
re-nanashi wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Weather API Implementation
For my assessment, I implemented a Weather API service using a modular monolith architecture with a pragmatic approach to Domain-Driven Design (DDD) and Clean Architecture principles.
Architecture
The system is structured into clear layers: API, Application, Domain, and Infrastructure. The API layer handles controllers and DTOs for request and response processing, the Application layer contains business logic and use-case orchestration, the Domain layer defines core business rules and models, and the Infrastructure layer manages external integrations such as persistence concerns.
This layered approach promotes high modularity, clear separation of concerns, and allows the system to be easily evolved into a microservices architecture in the future if needed.
Authentication and Authorization
The system uses JWT-based authentication for secure access control. It also implements basic Role-Based Access Control (RBAC) to manage user permissions and includes simple ownership-based checks to enforce resource-level security where applicable.
Features Implemented
Authentication endpoints include user registration and login, while the weather module provides a protected endpoint to retrieve weather data from an external API.
Performance Enhancements
The weather module includes caching to reduce redundant external API calls and improve response time. Rate limiting is also applied to the weather endpoint to prevent abuse and ensure system stability.
Environment Configuration
The application requires a
.envfile in the root directory with the following configuration:Design Philosophy
I usually start from monoliths on my projects therefore this system also follows a modular monolith-first approach where each module is self-contained but loosely coupled. This allows for fast development without the overhead of microservices while maintaining clean boundaries between modules.