How justin-a18/clinic-administrator works
Main Components
• User Interface (UI) / Presentation Layer:
• Located in the src/app folder, which contains pages (organized under admin and other sections) and shared UI components (e.g., headers, footers, data-tables, modals).
• Sub-components such as _components, _hooks, and context providers are responsible for UI interactions and state management.
• Business Logic / Core Layer:
• Found inside the src/core folder, which holds domain entities (e.g., doctor.entity.ts, patient.entity.ts) and use-cases for each functionality (appointment, doctor, package, patient, service).
• This layer encapsulates the actual business rules and operations (e.g., creating or deleting records).
• Infrastructure & Adapters:
• Located in src/infrastructure and src/config, these directories contain interfaces, mappers, HTTP adapters, and API-related configuration files that allow the UI and business logic to communicate with external systems or services.
• Configuration & Helpers:
• The src/config folder includes environment configurations, adapters, and helper functions, ensuring that external API interactions and global constants are centrally managed.
Relationships and Interactions
• Data Flow:
• Users interact with the UI (pages and components) that use custom React hooks (_hooks) to invoke business logic.
• These hooks call the core use-case functions, which interact with domain entities and perform operations such as creating, updating, or deleting records.
• The core layer uses infrastructure adapters (HTTP adapters and mappers) from the config and infrastructure layers to communicate with external APIs or data sources.
• Dependency Flow:
• UI → Hooks/Context Providers (State Management) → Core Use-Cases → Infrastructure (Adapters/HTTP).
• Clean Architecture:
Important Architectural Patterns and Design Principles
• Clean Architecture: Separates concerns into distinct layers (Presentation, Core/Business Logic, Infrastructure) ensuring modularity and independence of frameworks.
• Adapter Pattern: Used in the config/adapters directory to abstract and encapsulate the external API calls.
• Use-Case Driven: The business operations are implemented as discrete use-case modules within the src/core/use-cases directory, reflecting user actions (e.g., create-appointment, login-user, etc.).
• Separation of Concerns: Each directory and file type (e.g., _components for UI, _hooks for stateful logic, providers for context and store) is neatly separated for clarity and reuse.
Relevant Technologies and Frameworks
• Next.js: The base framework for the SPA and routing (using the src/app organization).
• React: Underlying component structure and hooks.
• Tailwind CSS: Indicated by tailwind.config.ts for styling.
• TypeScript: All files use TypeScript (.ts and .tsx extensions), providing type safety.
• Zustand (implied by the store files): For state management.
Detailed Component Relationships
• UI/Presentation Layer:
• src/app – Contains the overall layout (layout.tsx) and specific pages (e.g., admin routes).
• _components – Organizes modular React components by functionality (doctors, patients, shared UI elements).
• _hooks – Custom hooks wrapping common operations (e.g., useCreateDoctorMutation, useUserLoginMutation) that interface with the core layer.
• Core/Business Logic Layer:
• src/core/entities – Domain models that capture the business objects (doctor, patient, etc.).
• src/core/use-cases – Logic for each operation; each module (appointments, doctors, etc.) encapsulates related business processes.
• Infrastructure:
• src/infrastructure/interfaces – Contracts for interacting with external services.
• src/config/adapters – HTTP and API adapters serving as bridges between core logic and external systems.
• src/infrastructure/mappers – Data mappers for transforming external API responses into internal entity formats.