{"id":29230171,"url":"https://github.com/harunou/frontend-clean-architecture-react-tanstack-react-query","last_synced_at":"2025-07-24T06:33:50.107Z","repository":{"id":279973767,"uuid":"940615636","full_name":"harunou/frontend-clean-architecture-react-tanstack-react-query","owner":"harunou","description":"Frontend application build with Clean Architecture in mind. Slick. Simple. Effective.","archived":false,"fork":false,"pushed_at":"2025-07-02T11:22:51.000Z","size":584,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-02T11:32:02.929Z","etag":null,"topics":["clean-architecture","frontend","react","tanstack-react-query","typescript","zustand"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harunou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yaml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"buy_me_a_coffee":"harunou"}},"created_at":"2025-02-28T13:46:15.000Z","updated_at":"2025-07-01T09:58:17.000Z","dependencies_parsed_at":"2025-02-28T19:51:13.979Z","dependency_job_id":"861af802-9ece-4c63-8659-78851eedb94f","html_url":"https://github.com/harunou/frontend-clean-architecture-react-tanstack-react-query","commit_stats":null,"previous_names":["harunou/react-tanstack-react-query-clean-architecture","harunou/frontend-clean-architecture-react-tanstack-react-query"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harunou/frontend-clean-architecture-react-tanstack-react-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunou%2Ffrontend-clean-architecture-react-tanstack-react-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunou%2Ffrontend-clean-architecture-react-tanstack-react-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunou%2Ffrontend-clean-architecture-react-tanstack-react-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunou%2Ffrontend-clean-architecture-react-tanstack-react-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harunou","download_url":"https://codeload.github.com/harunou/frontend-clean-architecture-react-tanstack-react-query/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunou%2Ffrontend-clean-architecture-react-tanstack-react-query/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263331778,"owners_count":23450157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","frontend","react","tanstack-react-query","typescript","zustand"],"created_at":"2025-07-03T13:08:16.227Z","updated_at":"2025-07-24T06:33:50.096Z","avatar_url":"https://github.com/harunou.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/harunou"],"categories":[],"sub_categories":[],"readme":"# Frontend Clean Architecture\n\nThis repository showcases a frontend application built using the principles of\n[Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).\n\nIt demonstrates that applying Clean Architecture in frontend development doesn't\nhave to lead to unnecessary complexity or over-engineering. Instead, it can\nsimplify the development process while providing the full benefits of this\narchitectural style.\n\n## Clean Architecture Implementation\n\nA basic implementation of Clean Architecture for a typical frontend application\nwith a store and API integration is as follows:\n\n![fe-ca-basic-diagram](docs/fe-ca-diagram.svg)\n\nThis implementation is framework-agnostic and can be used with any modern\nreactive frontend framework, like React, Vue, Svelte, or Angular.\n\nFor more context, you can read these articles:\n\n- [Frontend Clean Architecture: Practical Insights and Pitfalls](https://dev.to/harunou/clean-architecture-practical-insights-and-pitfalls-1mdj)\n- [Clean Architecture for Frontend Applications](https://dev.to/harunou/clean-architecture-in-frontend-applications-overview-4o89)\n\n### Implementation with TanStack React Query\n\nThis application, however, uses TanStack React Query for server state management\nand synchronization states, which fits naturally into a repository unit.\n\nThe following diagram illustrates an extended Clean Architecture implementation\nthat includes a repository unit, which this application follows.\n\n![fe-ca-diagram-repository](docs/ca-fe-diagram-repository.svg)\n\n- The **Repository unit** is responsible for managing server state, handling\n  synchronization, and providing a consistent data interface to the rest of the\n  application.\n- The **Gateway unit** abstracts communication with the API, transforming data\n  into a format suitable for the repository. Using a gateway is recommended when\n  an application deals with multiple API endpoints or stores data in various\n  locations (e.g., in-memory, on a server, or in browser storage).\n\n## Dependency Graph\n\nHere is the dependency graph:\n\n![dependency overview](dependency-graph.svg)\n\n## File Structure of the Orders Module\n\n```console\n./src/features/orders\n├── cli\n│   ├── cli.tsx\n│   ├── commands\n│   │   ├── DeleteOrder\n│   │   │   ├── DeleteOrder.tsx\n│   │   │   ├── DeleteOrder.types.tsx\n│   │   │   ├── hooks\n│   │   │   │   ├── index.ts\n│   │   │   │   ├── useController.ts\n│   │   │   │   └── usePresenter.ts\n│   │   │   └── index.ts\n│   │   ├── index.ts\n│   │   ├── PrintAvailableOrderIds.tsx\n│   │   ├── PrintOrdersResource.tsx\n│   │   └── SwitchOrdersResource.tsx\n│   ├── hooks\n│   │   └── useConsoleRenderer.ts\n│   └── index.ts\n├── externalResources\n│   ├── httpClient\n│   │   ├── httpClient.ts\n│   │   └── index.ts\n│   ├── index.ts\n│   ├── OrdersApi\n│   │   ├── index.ts\n│   │   ├── OrdersApi.factory.ts\n│   │   ├── OrdersApi.ts\n│   │   └── OrdersApi.types.ts\n│   └── types.ts\n├── index.ts\n├── repositories\n│   ├── index.ts\n│   └── ordersRepository\n│       ├── hooks\n│       │   ├── index.ts\n│       │   ├── useGatewayResource.ts\n│       │   └── useOrdersGateway.ts\n│       ├── index.ts\n│       ├── OrdersGateway\n│       │   ├── index.ts\n│       │   ├── InMemoryOrdersGateway\n│       │   │   ├── index.ts\n│       │   │   ├── InMemoryOrdersGateway.spec.ts\n│       │   │   └── InMemoryOrdersGateway.ts\n│       │   ├── makeOrderEntities.ts\n│       │   ├── OrdersGateway.types.ts\n│       │   └── RemoteOrdersGateway\n│       │       ├── index.ts\n│       │       ├── mappers.ts\n│       │       ├── RemoteOrdersGateway.spec.ts\n│       │       └── RemoteOrdersGateway.ts\n│       ├── ordersRepositoryKeys.ts\n│       ├── ordersRepository.ts\n│       └── ordersRepository.utils.ts\n├── selectors\n│   ├── index.ts\n│   ├── useIsLastItemIdSelector\n│   │   ├── index.ts\n│   │   ├── useIsLastItemIdSelector.spec.ts\n│   │   └── useIsLastItemIdSelector.ts\n│   ├── useIsLastOrderIdSelector.ts\n│   ├── useIsOrdersProcessingSelector\n│   │   ├── index.ts\n│   │   ├── useIsOrdersProcessingSelector.spec.tsx\n│   │   └── useIsOrdersProcessingSelector.ts\n│   ├── useItemByIdSelector.ts\n│   ├── useOrderByIdSelector\n│   │   ├── index.ts\n│   │   ├── integration.spec.tsx\n│   │   ├── useOrderByIdSelector.spec.tsx\n│   │   └── useOrderByIdSelector.ts\n│   ├── useOrderIdsSelector\n│   │   ├── index.ts\n│   │   ├── useOrderIdsSelector.spec.tsx\n│   │   └── useOrderIdsSelector.ts\n│   ├── useOrdersResourceSelector.ts\n│   └── useTotalItemsQuantitySelector\n│       ├── index.ts\n│       ├── integration.spec.tsx\n│       ├── useTotalItemsQuantitySelector.spec.tsx\n│       └── useTotalItemsQuantitySelector.ts\n├── stores\n│   ├── hooks\n│   │   ├── index.ts\n│   │   └── useOrdersPresentationStore.ts\n│   ├── index.ts\n│   └── ordersPresentationStore.ts\n├── types\n│   ├── entities\n│   │   ├── index.ts\n│   │   ├── ItemEntity\n│   │   │   ├── index.ts\n│   │   │   └── ItemEntity.ts\n│   │   ├── OrderEntity\n│   │   │   ├── index.ts\n│   │   │   └── OrderEntity.ts\n│   │   └── OrdersPresentationEntity.ts\n│   ├── index.ts\n│   ├── OrdersResource.ts\n│   └── repositories\n│       ├── index.ts\n│       └── OrdersRepository.ts\n├── useCases\n│   ├── index.ts\n│   └── useDeleteOrderUseCase\n│       ├── index.ts\n│       ├── useDeleteOrderUseCase.spec.tsx\n│       └── useDeleteOrderUseCase.ts\n├── utils\n│   ├── index.ts\n│   └── testing\n│       ├── index.ts\n│       ├── itemEntityFactory.ts\n│       ├── makeComponentFixture.tsx\n│       ├── makeOrderEntities.ts\n│       ├── mockUseOrdersGateway.ts\n│       └── orderEntityFactory.ts\n└── views\n    ├── containers\n    │   ├── index.ts\n    │   ├── Order\n    │   │   ├── hooks\n    │   │   │   ├── index.ts\n    │   │   │   ├── useController.ts\n    │   │   │   └── usePresenter\n    │   │   │       ├── index.ts\n    │   │   │       ├── usePresenter.spec.ts\n    │   │   │       └── usePresenter.ts\n    │   │   ├── index.ts\n    │   │   ├── Order.tsx\n    │   │   └── Order.types.ts\n    │   ├── OrderItem\n    │   │   ├── hooks\n    │   │   │   ├── index.ts\n    │   │   │   ├── useController\n    │   │   │   │   ├── index.ts\n    │   │   │   │   ├── useController.spec.tsx\n    │   │   │   │   └── useController.ts\n    │   │   │   └── usePresenter.ts\n    │   │   ├── index.ts\n    │   │   ├── OrderItem.tsx\n    │   │   └── OrderItem.types.ts\n    │   ├── Orders\n    │   │   ├── hooks\n    │   │   │   ├── index.ts\n    │   │   │   ├── useController.ts\n    │   │   │   └── usePresenter.ts\n    │   │   ├── index.ts\n    │   │   ├── integration.spec.tsx\n    │   │   ├── Orders.spec.tsx\n    │   │   ├── Orders.tsx\n    │   │   └── Orders.types.ts\n    │   └── OrdersResourcePicker\n    │       ├── index.ts\n    │       └── OrdersResourcePicker.tsx\n    ├── index.ts\n    └── testIds.ts\n\n43 directories, 115 files\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharunou%2Ffrontend-clean-architecture-react-tanstack-react-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharunou%2Ffrontend-clean-architecture-react-tanstack-react-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharunou%2Ffrontend-clean-architecture-react-tanstack-react-query/lists"}