How pregna-care-system/pregna-care-client works
Based on our analysis, this project is a React application built using TypeScript and Vite. Although the README mentions a minimal template with some ESLint configuration guidelines, the file tree reveals a more extensive full-fledged frontend solution. It is structured to support multiple user roles (e.g., Admin and Member), has distinct pages (for blog, community, checkout, etc.), and includes a solid architecture with clear segregation of concerns such as presentation (components and layouts), routing, state management (Redux with sagas), and service layers (API interactions).
Main Components
• Entry Point & Bootstrapping:
• Entry file: src/main.tsx.
• App container: src/App.tsx.
• Presentation Layer:
• Components: Located under src/components (cards, carousel, modal, chat, etc.).
• Layouts: Found under src/layouts (AdminLayout, MainLayout, MemberLayout, NoHeaderLayout).
• Pages: In src/pages (distinct directories for Admin, Blog, Community, Member, etc.) – these represent screens/views.
• Routing & Guards:
• Routing configuration: src/routes/index.tsx.
• Auth and Role Guards: Under src/guards (AdminGuard, AuthGuard, GuestGuard, MemberGuard) ensuring security and access control.
• State Management:
• Redux-related code: src/store (modules, rootReducer.ts, rootSaga.ts, store.ts).
• This layer handles global state, asynchronous actions (sagas), and selectors.
• Business/Service Layer:
• Service files: Inside src/services (adminService, blogService, userService, etc.) that abstract API interaction.
• Utilities & Constants:
• Utility functions and configuration: Under src/utils (axiosClient, helper, configuration of routes, constants, etc.).
• Theming and Styling:
• Theme files: Located in src/theme.
• Global CSS: Including index.css in src and Tailwind configurations.
• Configuration & Build:
• Vite configuration (vite.config.ts) and TypeScript configurations (tsconfig files).
• Dockerfile and .dockerignore indicate containerization support.
• GitHub CI workflows in .github/workflows for building and checks.
Relationships/Interactions
• The entry point (src/main.tsx) initializes the application by rendering the App component.
• App.tsx acts as the high-level container setting up routes via src/routes.
• Each page under src/pages is rendered based on the active route – and pages combine numerous reusable components.
• Layouts wrap pages and enforce structural consistency (for example, AdminLayout for all admin pages).
• Guards (AuthGuard, AdminGuard, etc.) sit in front of route components to control access.
• State flows using Redux: actions and sagas (in src/store) update the global state while pages and components subscribe to the state via selectors.
• The Services layer abstracts and handles external API calls, which are then used by Redux sagas or directly in components.
• Utility modules (e.g., axiosClient) support external API interactions, while constants and helper functions facilitate application-wide behaviors.
• The external build and configuration files (Dockerfile, Vite config, ESLint and Prettier settings) support development, testing, and deployment pipelines.
Architectural Patterns/Design Principles
• Component-Based Architecture: Separation into reusable UI components (cards, modals, charts, etc.).
• Container-Presenter Paradigm: Pages and layouts serve as containers that orchestrate state and routing, while components focus on rendering.
• Redux for State Management: The store, reducers, sagas, and selectors provide a clear data flow and predictable state container.
• Separation of Concerns: Distinct folders for services, hooks, helpers, and types keep logic modular.
• Role-based Access/Guarding: The use of guard components enforces user authentication and role-specific access.