Skip to content
CAI
Software that uses CAICheck a score

alan-nascimento/react-clean-architecture

32.3

Weak · 9 November 2026

1.5k

lines of production code

TypeScript

with JavaScript

6

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a React-based web application for managing programmer surveys, built using Clean Architecture principles. It enables users to register, authenticate, and view a list of available surveys, as well as load and save detailed survey results. The application handles user state via Recoil, manages data persistence through local storage, and communicates with a remote backend via HTTP for all account and survey operations.

Features

Add Calendar and Icon presentation components

This change introduces two new UI components to the presentation layer. The Calendar component renders a date display (day, month, year) with specific styling, while the Icon component displays thumb-up or thumb-down indicators with color-coded backgrounds (green for valid, red for invalid). These components are now available for use in the application's interface.

src/presentation/components/calendar · high confidence

Add Error display component with retry action

A new Error component has been added to the presentation layer, providing a styled container that displays an error message and a 'Try again' button. Users can now view specific error details and trigger a reload action via the provided callback, with styling applied through a dedicated SCSS file.

src/presentation/components/error · high confidence

Add Header component with logout and username display

The Header component now displays the current user's name and provides a logout link. It uses Recoil for state management to retrieve the account information and a custom \useLogout\ hook to handle the logout action, which clears the current account and redirects the user to the login page. The component includes specific styling for the header layout, username display, and logout link, with responsive adjustments for smaller screens.

src/presentation/components/header · high confidence

Add MinLengthValidation for field length checks

A new MinLengthValidation component has been introduced to enforce minimum character counts on input fields. When a field's value is shorter than the specified threshold, the validator returns an InvalidFieldError; otherwise, validation passes. This change includes the implementation logic and corresponding unit tests to verify correct behavior for valid, invalid, and missing fields.

src/validation/validators/min-length · high confidence

Add Survey List page with error handling and reload capability

The Survey List page now displays a list of surveys, initially showing four empty items while loading. It includes robust error handling: if an unexpected error occurs, an error component is displayed with a reload button; if an access denied error occurs, the user is automatically logged out and redirected to the login page. The page also supports manual reloading of the survey data via a dedicated reload action.

src/presentation/pages/survey-list · high confidence

Add data model for remote survey results

Introduced the RemoteSurveyResultModel and RemoteSurveyResultAnswerModel types to define the structure of survey data retrieved from remote sources. These models capture question text, dates, and detailed answer metrics including counts, percentages, and flags for the current account's response, enabling downstream components to process and display survey analytics.

src/data/models · high confidence

Add domain models for account and survey results

New domain models have been introduced to define the structure of account data and survey results. The AccountModel now includes a name field alongside the access token, and new SurveyResultModel and SurveyResultAnswerModel types define the schema for survey questions, dates, and answer details including counts and percentages. These models are exported via the domain models index for use across the application.

src/domain/models · high confidence

Add factory for AuthorizeHttpClientDecorator

A new factory function, makeAuthorizeHttpClientDecorator, has been added to the decorators module. This factory constructs an HttpClient by wrapping the standard Axios HTTP client with an AuthorizeHttpClientDecorator, using a local storage adapter for authorization data. The factory is now exported from the decorators index, making it available for dependency injection or client creation in other parts of the application.

src/main/factories/decorators · high confidence

Add factory for remote survey list loading

A new factory function, makeRemoteLoadSurveyList, has been added to construct the remote implementation of the LoadSurveyList use case. This factory wires together the API URL for the /surveys endpoint and an authorization HTTP client decorator, providing a standardized way to instantiate the remote data layer for survey list retrieval.

src/main/factories/usecases/load-survey-list · high confidence

Add local storage adapter factory

A new factory function, makeLocalStorageAdapter, has been added to the cache module to instantiate the LocalStorageAdapter. This allows other parts of the application to easily create and access the local storage caching mechanism.

src/main/factories/cache · high confidence

Add remote data loading for survey results

Users can now load survey results from the remote server via the new RemoteLoadSurveyResult use case. This implementation fetches data using an HTTP GET request and maps the response to the domain model, including converting the result date to a Date object. It handles server responses by returning the survey result on success (200), throwing an AccessDeniedError on forbidden (403), and throwing an UnexpectedError for other failures (404, 500).

src/data/usecases/load-survey-result · high confidence

Add reusable Spinner component

A new Spinner component has been added to the presentation layer, providing a visual loading indicator for users. The component renders four animated dots and supports an optional 'isNegative' prop to invert the color scheme for use on dark backgrounds.

src/presentation/components/spinner · high confidence

Add survey list UI components

The survey list page now includes the presentation components for rendering individual survey items, an empty state placeholder, and the list container itself. The SurveyItem component displays the survey question, date, and a status icon, and links to the survey results page. The List component renders these items or shows the empty state when no surveys are available.

src/presentation/pages/survey-list/components · high confidence

Added HTTP client authorization decorator

Introduced the AuthorizeHttpClientDecorator, which automatically injects the user's access token into the 'x-access-token' header of outgoing HTTP requests. This decorator retrieves the token from the account storage and merges it with any existing request headers, ensuring authenticated requests are handled transparently by the HTTP client layer.

src/main/decorators · high confidence

Added ValidationBuilder for chaining field validations

A new ValidationBuilder class has been introduced in the validation module, providing a fluent API to construct field validation rules. Users can now chain methods such as required(), email(), min(length), and sameAs(field) to define multiple constraints on a single field, which are then returned as a list of validation objects via the build() method.

src/validation/validators/builder · high confidence

Added domain use-case interfaces for account management and surveys

New use-case interfaces have been introduced in the domain layer to define the contract for account registration, authentication, and survey operations. Specifically, \AddAccount\ and \Authentication\ interfaces now specify the parameters and return models for user sign-up and login flows. Additionally, \LoadSurveyList\, \LoadSurveyResult\, and \SaveSurveyResult\ interfaces define the capabilities for retrieving survey lists and results, as well as submitting survey answers. These interfaces standardize the input/output shapes for these features within the application's architecture.

src/domain/usecases · high confidence

Added field comparison validation

A new CompareFieldsValidation component has been introduced to the validation suite, allowing users to ensure that two specified fields in a form contain identical values. This validator checks the equality of the primary field against a target field and returns an InvalidFieldError if they do not match, supporting use cases such as password confirmation.

src/validation/validators/compare-fields · high confidence

Added remote data layer and UI loading component for survey results

This change introduces the infrastructure to save and load survey results via remote APIs, along with a new UI component to indicate loading states. Specifically, it adds the \RemoteSaveSurveyResult\ and \RemoteLoadSurveyResult\ use-case implementations that communicate with the backend via HTTP PUT and GET requests respectively, handling success and error responses (403, 404, 500). Factory functions are provided to wire these use cases with the appropriate API URLs and authorization decorators. Additionally, a new \Loading\ component is added to the presentation layer, which displays a centered overlay with a spinner and 'Wait...' text during asynchronous operations.

(repo-wide) · high confidence

Added required field validation logic and tests

The validation module now includes a new RequiredFieldValidation component that checks if a specified field is present and non-empty in the input object. If the field is missing or empty, it returns a RequiredFieldError; otherwise, validation passes. Corresponding unit tests verify this behavior.

src/validation/validators/required-field · high confidence

Added validation error classes for invalid and required fields

The validation module now exports specific error classes, InvalidFieldError and RequiredFieldError, to provide distinct error types for field validation failures. These classes are re-exported from the errors index, allowing consumers to catch and handle these specific validation scenarios separately from generic errors.

src/validation/errors · high confidence

Initial project scaffolding and build configuration

The repository has been initialized with a complete development environment, including TypeScript configuration, ESLint rules, and Webpack build setups for both development and production modes. This change introduces the core infrastructure for the application, such as the HTML templates, a Node.js server for serving static files, and configuration for testing tools like Jest and Cypress, as well as CI/CD integration with Travis CI and Heroku deployment.

(repo-wide) · high confidence

Introduce AxiosHttpClient for HTTP requests

Added a new AxiosHttpClient implementation in src/infra/http that wraps the Axios library to handle HTTP requests. The client maps HttpRequest objects to Axios calls and returns standardized HttpResponse objects, including logic to catch errors and extract the response status and body. This provides a concrete HTTP client implementation for the application's infrastructure layer.

src/infra/http · high confidence

Introduce FieldValidation protocol interface

Added a new FieldValidation interface in src/validation/protocols that defines the contract for field-level validation, specifying a field name and a validate method that returns an Error. This protocol is now exported from the protocols index, establishing a standard interface for validation implementations within this module.

src/validation/protocols · high confidence

Introduce Login page with form validation and authentication flow

The login page now allows users to sign in with email and password, featuring real-time field validation that disables the submit button until the form is valid. Upon successful authentication, the user is redirected to the main page and their account state is updated via Recoil, while authentication failures display an error message. The implementation uses Recoil for state management and includes specific components for input handling, form status, and submission.

src/presentation/pages/login · high confidence

Introduce application entry point and account registration capability

The application now initializes via a new entry point in src/main/index.tsx that renders the main Router component, establishing the navigation structure. Additionally, a factory for the remote add-account use case has been added in src/main/factories/usecases/add-account/remote-add-account-factory.ts, enabling the creation of account registration requests by wiring the RemoteAddAccount implementation with the API URL and HTTP client.

src/main · high confidence

Introduce centralized validation module exports

The src/validation/validators/index.ts file has been added to serve as the public entry point for the validation library. It re-exports the ValidationBuilder, CompareFieldsValidation, EmailValidator, MinLengthValidation, RequiredFieldValidation, and ValidationComposite, allowing consumers to import these components from a single location.

src/validation/validators · high confidence

Introduce core data protocol interfaces for HTTP and local storage

The \src/data/protocols\ directory now exposes standardized interfaces for data access, enabling consistent integration with external services. This includes an \HttpClient\ protocol defining HTTP methods, status codes, and request/response structures, as well as \GetStorage\ and \SetStorage\ interfaces for local storage operations. These protocols serve as the abstraction layer for data fetching and caching within the application.

src/data/protocols · high confidence

Introduces page composition factories for Login, Signup, Survey List, and Survey Result

This change adds factory functions in the \src/main/factories/pages\ directory to wire up presentation components with their underlying use cases and validation logic. Specifically, it provides \makeLogin\, \makeSignUp\, \makeSurveyList\, and \makeSurveyResult\ components that inject dependencies such as remote authentication, account creation, survey loading/saving, and field-specific validation rules (e.g., email format, password length). This establishes the wiring layer for these core user flows.

src/main/factories/pages · high confidence

Introduction of Validation Protocol Interface

The presentation layer now exposes a new \Validation\ protocol interface, defining a standard contract for validation logic with a \validate\ method that accepts a field name and input object. This interface is exported via the \src/presentation/protocols\ module, establishing a reusable abstraction for validation requirements across the application.

src/presentation/protocols · high confidence

Introduction of global styling, color variables, and input animations

The presentation layer now includes foundational style definitions. A new color palette is established in colors.scss, defining primary, background, and state-specific colors (valid/invalid/disabled). Global styles in global.scss apply a Roboto font, reset box models, and style form inputs and buttons, including specific disabled states for buttons. Additionally, a shimmer animation keyframe is defined in animations.scss to support visual feedback effects.

src/presentation/styles · high confidence

Introduction of shared presentation components

The presentation layer now exposes a standardized set of reusable UI components, including a Logo, Error display, Footer, Header, Input, Loading spinner, PrivateRoute guard, and SubmitButton. These components are centralized in the components index for consistent usage across the application.

src/presentation/components · high confidence

New FormStatus component for displaying loading and error states

A new FormStatus component has been added to the presentation layer to handle the visual display of form submission states. This component renders a spinner when the form is loading and displays error messages when a main error occurs, utilizing specific SCSS styles for layout and color. This change introduces a dedicated UI element for status feedback, replacing or abstracting previous inline status handling within the login flow.

src/presentation/components/form-status · high confidence

New Input component with animated label and validation styling

A new Input component has been added to the presentation layer, featuring an animated floating label that moves up when the field is focused or contains text. The component visually indicates validation status by changing the bottom border color (green for valid, red for invalid) and includes a transition effect on focus. It manages its own state via props and ensures accessibility by focusing the input when the label is clicked.

src/presentation/components/input · high confidence

New LocalStorageAdapter for cache operations

A new LocalStorageAdapter has been introduced in the infrastructure cache layer to handle data persistence using the browser's localStorage. This adapter implements the SetStorage and GetStorage protocols, ensuring that values are correctly serialized to JSON when stored and deserialized when retrieved. It also includes logic to automatically remove a key from storage if the value being set is undefined or null, providing a cleaner cache management experience.

src/infra/cache · high confidence

New authentication and error-handling hooks

Added the useLogout and useErrorHandler hooks to the presentation layer. useLogout clears the current account state via Recoil and redirects the user to the login page, while useErrorHandler automatically triggers logout when an AccessDeniedError occurs, otherwise delegating to a provided callback.

src/presentation/hooks · high confidence

New domain error classes for authentication scenarios

The application now exposes specific error types for common authentication failures, including AccessDeniedError, EmailInUseError, InvalidCredentialsError, and UnexpectedError. These classes are exported from the domain errors module, allowing consumers to handle distinct error conditions more precisely rather than relying on generic error handling.

src/domain/errors · high confidence

New presentation pages for authentication and survey results

The application now exposes new UI components for user authentication and survey data visualization. Users can access the Login and SignUp pages for account management, as well as SurveyList and SurveyResult pages to view and manage survey outcomes. These components are now centrally exported from the presentation layer's index file, making them available for routing and integration within the application.

src/presentation/pages · high confidence

New user registration page with form validation and account creation

A new SignUp page has been added, allowing users to create an account by entering their name, email, and password. The form includes real-time validation for all fields, enabling the submit button only when the data is valid, and displays a loading spinner during submission. Upon successful registration, the new account is set as the current user and the user is redirected to the home page; errors during the process are displayed to the user. The implementation uses Recoil for state management and integrates with the domain's AddAccount use case.

src/presentation/pages/signup · high confidence

Remote survey list loading with HTTP error handling

The RemoteLoadSurveyList use case now fetches survey data via an HTTP GET request and maps the response to the domain model, converting date strings to Date objects. It handles specific HTTP status codes: returning the list on 200, an empty list on 204, throwing AccessDeniedError on 403, and throwing UnexpectedError on other errors like 404 or 500.

src/data/usecases/load-survey-list · high confidence

RemoteAddAccount now handles HTTP errors and returns account data

The RemoteAddAccount use case now implements the AddAccount interface by making a POST request via HttpClient. On a successful 200 response, it returns the account model. If the server returns a 403 Forbidden status, it throws an EmailInUseError. Any other non-200 status code (such as 400, 404, or 500) results in an UnexpectedError being thrown.

src/data/usecases/add-account · high confidence

Behavioural changes

Centralized export of survey and account use cases

The src/data/usecases/index.ts file now serves as the central entry point for data use cases, explicitly exporting RemoteAddAccount, RemoteAuthentication, RemoteLoadSurveyList, RemoteLoadSurveyResult, and RemoteSaveSurveyResult. This change consolidates the public API for these specific data-layer operations, making them easier to import and manage within the application.

src/data/usecases · high confidence

Email validation allows empty values and rejects invalid formats

The new EmailValidation validator now permits empty email fields to pass validation (returning no error) while strictly rejecting invalid email formats with an InvalidFieldError. Valid email addresses continue to pass without error, ensuring that users are not blocked by empty inputs but are guided when providing malformed addresses.

src/validation/validators/email · high confidence

Extract HTTP factories into dedicated modules

The HTTP factory logic has been reorganized into specific files: \api-url-factory.ts\ now provides a \makeApiUrl\ function that constructs URLs by combining the \API\_URL\ environment variable with a provided path, and \axios-http-client-factory.ts\ provides a \makeAxiosHttpClient\ function to instantiate the HTTP client. These are re-exported via the \index.ts\ file for easier consumption.

src/main/factories/http · high confidence

The presentation layer now includes separate, memoized components for the page footer and the login header. The Footer component renders a minimal footer element with a primary background color, while the LoginHeader component displays the application logo and the '4Dev - Survey for Programmers' title, styled with a distinct top border and centered layout. These changes isolate the markup and styling for these specific UI sections into their own files.

src/presentation/components/footer, src/presentation/components/login-header · high confidence

Migrate current account state management to Recoil

The application now uses Recoil for managing the current account state in the presentation layer, replacing the previous React Context implementation. This change introduces a new \currentAccountState\ atom in the atoms component library to hold account data and provides a dedicated adapter layer (\current-account-adapter\) that persists and retrieves the account information via local storage, ensuring the UI state is synchronized with the user's session.

src/main/adapters, src/presentation/components/atoms · high confidence

Migrate state management to Recoil and secure survey routes

The application's routing layer now wraps the router in a RecoilRoot to manage the current account state, replacing the previous context-based approach. Additionally, the survey list and survey result pages are now protected by PrivateRoute, ensuring that access is granted only when a valid authentication token is present.

src/main/routes · high confidence

New remote authentication factory with configurable URL path

A new factory function, makeRemoteAuthentication, has been added to the authentication module. This factory constructs a RemoteAuthentication use case by combining an HTTP client with an API URL factory that now accepts a specific path parameter ('/login'), allowing the authentication endpoint to be explicitly defined rather than hardcoded.

src/main/factories/usecases/authentication · high confidence

PrivateRoute now uses Recoil for authentication state and enforces login redirects

The PrivateRoute component has been updated to check for an access token via the Recoil store (currentAccountState) instead of previous mechanisms. If a valid token is present, the protected component renders as expected; if the token is missing or empty, the user is automatically redirected to the /login page. This change also introduces unit tests to verify both the successful rendering and the redirect behavior.

src/presentation/components/private-route · high confidence

Remote authentication now handles HTTP error responses

The RemoteAuthentication use case now explicitly handles HTTP error responses from the server. If the authentication request returns a 401 Unauthorized status, it throws an InvalidCredentialsError. For other error statuses (400, 404, 500), it throws an UnexpectedError. This ensures that users receive appropriate feedback when authentication fails due to invalid credentials or other server-side issues.

src/data/usecases/authentication · high confidence

Survey result page now uses Recoil for state management

The survey result page has been refactored to replace React Context with Recoil for managing application state. This change introduces new state atoms to handle the survey result data (loading, error, and result content) and the user's answer interaction, ensuring consistent state sharing between the main page component and the nested answer/result sub-components.

src/presentation/pages/survey-result · high confidence

Updated test configuration and added TypeScript support for SCSS modules

The test environment now includes @testing-library/jest-dom to enhance assertion capabilities in tests, and TypeScript definitions have been added to allow importing .scss files as modules without type errors.

src/main/config · high confidence

ValidationComposite returns the first validation error

The ValidationComposite now aggregates multiple field validators and returns the error message from the first validator that fails, or a falsy value if all validations pass. This ensures that users receive immediate feedback on the first issue encountered during input validation.

src/validation/validators/validation-composite · high confidence

Test coverage

Added Axios HTTP client mocks for testing; Added Cypress integration tests for authentication and survey features; Added test mocks and spies for domain use cases; Added test utilities for HTTP and survey data mocking; Added test utilities for field validation; Added test utilities for form validation, rendering, and state mocking.

Dependencies

Upgrade to React Clean Architecture v3.0.0 with TypeScript and Testing Infrastructure

The project has been upgraded to version 3.0.0, introducing a comprehensive development and testing stack. This includes migrating to TypeScript, adding Jest for unit testing with React Testing Library, and integrating Cypress for end-to-end testing. The dependency list now features React 16.13.1, Axios, and Recoil for state management, alongside build tools like Webpack 4 and ESLint with TypeScript support. The license has also been updated to MIT.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 31 → 32 (+1.2)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 65 → 65 (+0.0)
  • Architecture 69 → 69 (+0.0)
  • Maturity 43 → 43 (+0.0)
  • Readiness 23 → 23 (+0.0)
  • Security 35 → 45 (+9.3)
  • Accessibility 27 → 27 (+0.0)
  • Performance 100 → 100 (+0.0)

Resolved (7)

  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • Medium CVE: [GHSA redacted] (package-lock.json)

New (8)

  • Documentation: no build, run or usage example (README.md)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • Low CVE: [GHSA redacted] (package-lock.json)

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

alan-nascimento/react-clean-architecture was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 9 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 5d23da8c4afdbde3beef0f7b2a9c6ab4669e18ff — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-bb0cb800cd0f.