Skip to main content

Component Architecture

EducaStream uses a component-based architecture built with React, organizing components into reusable, modular units. The application follows a clear separation between presentational components and page-level views.

Directory Structure

The component architecture is organized into two main directories:
src/
├── Components/       # Reusable UI components
│   ├── Button/
│   ├── Card/
│   ├── CardContainer/
│   ├── CardLayout/
│   ├── Carrousel/
│   ├── Cart/
│   ├── Footer/
│   ├── NavBar/
│   └── Loader/
└── views/           # Page-level components
    ├── Courses/
    ├── DetailCourse/
    ├── Student/
    ├── Instructor/
    ├── Layout/
    └── dashboard/

Component Categories

UI Components

Reusable components located in src/Components/ that handle specific UI functionality:
Button ComponentA reusable button component with consistent styling and scroll-to-top functionality.
import Button from "./Components/Button/Button";

<Button 
  text="Click Me" 
  onClick={() => console.log('clicked')} 
/>
Props:
  • text (string) - Button label text
  • onClick (function) - Click handler function

Layout Components

CardContainer ComponentWrapper component for individual course cards.
import CardContainer from "./Components/CardContainer/CardContainer";

<CardContainer course={courseData} />

Utility Components

Loader ComponentLoading spinner for async operations.
import Loader from "./Components/Loader/Loader";

{isLoading && <Loader />}

Page-Level Views

Views are located in src/views/ and represent full pages:
  • Layout - Home page layout with course listings
  • Courses - Course catalog with filtering and pagination
  • DetailCourse - Individual course detail page
  • Student - Student dashboard
  • Instructor - Instructor dashboard
  • Dashboard - Admin dashboard
  • Login - Authentication page

Context Usage

Components utilize React Context for state management:
import { userContext } from "../../App";
import { useContext } from "react";

const MyComponent = () => {
  const userData = useContext(userContext);
  // Access user data across components
};
The userContext provides:
  • User authentication state
  • User profile information
  • Course purchase history
  • Role-based permissions

Component Communication

Props Down

Parent components pass data to children via props

Context

Global state shared via React Context

Cart Context

Shopping cart state managed separately

Navigation

React Router for page navigation

Best Practices

When creating new components in EducaStream:
  1. Place reusable UI components in src/Components/
  2. Create a dedicated folder for each component
  3. Include a matching CSS module file
  4. Export component as default
  5. Use context for global state access
  6. Implement prop validation where appropriate
Always use CSS modules for component styling to avoid naming conflicts. Each component should import its own .module.css file.

Build docs developers (and LLMs) love