Skip to content

macielrsf/react-native-clean-arch-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React Native Clean Architecture - DDD & SOLID

This project demonstrates the implementation of Clean Architecture, Domain-Driven Design (DDD) and SOLID principles in React Native with TypeScript.

🌍 Languages / Idiomas


πŸ—οΈ Architecture

Clean Architecture

  • Presentation Layer: React Native components and hooks
  • Domain Layer: Business logic and entities
  • Infrastructure Layer: APIs and external services

Domain-Driven Design (DDD)

  • Entities: Post, User
  • Value Objects: IDs, timestamps
  • Services: postService, postApi
  • Repositories: Abstraction for data access

SOLID Principles

  • Single Responsibility: Each class has a single responsibility
  • Open/Closed: Extensible without modification
  • Liskov Substitution: Well-defined interfaces
  • Interface Segregation: Specific interfaces
  • Dependency Inversion: Inverted dependencies

πŸš€ Technologies

  • React Native - Mobile framework
  • TypeScript - Static typing
  • Tanstack React Query - State management and caching
  • React Navigation - Navigation
  • Lodash - JavaScript utilities

πŸ“ Project Structure

src/
β”œβ”€β”€ components/          # Reusable components
β”‚   β”œβ”€β”€ ui/             # UI components
β”‚   └── layout/         # Layout components
β”œβ”€β”€ domain/             # Domain layer
β”‚   └── Post/           # Post domain
β”‚       β”œβ”€β”€ postApi.ts      # Infrastructure (API)
β”‚       β”œβ”€β”€ postService.ts  # Domain service
β”‚       β”œβ”€β”€ postHooks.ts    # React Query hooks
β”‚       └── postListMock.ts # Mocked data
β”œβ”€β”€ screens/            # Application screens
β”‚   └── app/
β”‚       └── HomeScreen/     # Main screen
β”œβ”€β”€ types/              # TypeScript types
└── utils/              # Utilities and hooks

🎯 Features

Main Screen (HomeScreen)

  • βœ… Infinite scroll post list
  • βœ… Fixed header with title
  • βœ… Loading states
  • βœ… Error handling
  • βœ… Pull to refresh
  • βœ… Smart caching with React Query

Clean Architecture

  • βœ… Clear separation of responsibilities
  • βœ… Dependency inversion
  • βœ… Testability
  • βœ… Maintainability
  • βœ… Scalability

πŸ› οΈ Setup

Installation

npm install

Execution

npx expo start

Development

# Check TypeScript types
npx tsc --noEmit

# Linting (if configured)
npx eslint src/

πŸ“Š Components

Presentational Components

  • PostItem: Displays an individual post
  • LoadingSpinner: Loading indicator
  • ErrorMessage: Displays errors with retry
  • Screen: Base layout with safe area

Smart Components

  • HomeScreen: Manages state and business logic

πŸ”„ Hooks

React Query Hooks

  • usePosts: Fetches all posts
  • usePost: Fetches post by ID
  • usePostsByUser: Fetches posts by user

Utility Hooks

  • useDebounce: Value debouncing
  • useSearchWithDebounce: Search with debounce

🎨 UI/UX

Design System

  • Consistent colors
  • Hierarchical typography
  • Standardized spacing
  • Reusable components

User Experience

  • Informative loading states
  • Friendly error handling
  • Clear visual feedback
  • Optimized performance

πŸ”§ Configuration

TypeScript

  • Path mapping configured
  • Strict mode enabled
  • Well-defined types

React Query

  • Optimized cache
  • Automatic retry
  • Background refetch
  • Configured stale time

πŸ“ˆ Performance

Optimizations

  • React Query for caching
  • Optimized FlatList
  • useCallback for callbacks
  • Component lazy loading

Monitoring

  • Console logs for debugging
  • Performance profiling
  • Memory usage tracking

πŸ§ͺ Testing

Prepared Structure

  • Testable components
  • Isolated hooks
  • Mockable services
  • Abstracted APIs

πŸš€ Deploy

Build

# Android
npx expo build:android

# iOS
npx expo build:ios

πŸ“š Documentation

Documentation Files

  • README.md: Main documentation (English)
  • README_EN.md: Portuguese documentation (PortuguΓͺs)

🀝 Contributing

Patterns

  • Clean Architecture
  • DDD principles
  • SOLID principles
  • TypeScript strict
  • Component composition

Commits

  • Conventional commits
  • Feature branches
  • Code review
  • Documentation updates

πŸ“„ License

This project is an educational example of Clean Architecture implementation in React Native.


Developed with ❀️ following the best software architecture practices.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published