# ewanbrinkman/sfu-course-api-wrapper architecture

> Architecture diagram of the GitHub repository ewanbrinkman/sfu-course-api-wrapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ewanbrinkman/sfu-course-api-wrapper
- Repository: https://github.com/ewanbrinkman/sfu-course-api-wrapper

## Overview

##### Main Components

a. Client Application Layer
- As the topmost layer where developers would implement this wrapper
- To the Wrapper Interface layer

b. Wrapper Interface Layer (src/index.ts)
- Main entry point for the API
- Primary wrapper functions (course, courseSection, etc.)

c. Core API Classes Layer (src/api/)
- Main classes: Course, CourseSection, Department, Instructor, Schedule
- These should be represented as interconnected components

d. Data Processing Layer (src/utils/process/)
- Processors for raw data transformation
- Connection to both API Classes and Types layers

e. Types System Layer (src/api-types/)
- Type hierarchy:
- Raw types (RawCourseData, RawCourseSectionData, etc.)
- Processed types (CourseData, CourseSectionData, etc.)
- Common types (enums like CourseType, SectionCode, etc.)

f. Error Handling Layer (src/errors/)
- Custom error types and their hierarchy

g. External SFU API Layer
- Actual SFU Course Outlines REST API
- Connection to the wrapper

**[Client Application]**
- ↓
**[Wrapper Interface]**
- ↓
**[Core API Classes] ←→ [Error Handling]**
- ↓
**[Data Processing] ←→ [Types System]**
- ↓
**[External SFU API]**

##### Important Details

- Asynchronous nature of the operations (use appropriate symbols)
- Zero runtime dependencies aspect
- Main class relationships (Course contains CourseSection, etc.)
- Data transformation flow from raw API data to processed classes

##### Implementation Notes

- Keep the abstraction level high enough to be understandable but detailed enough to show the architecture

Remember to indicate that this is a TypeScript library with zero runtime dependencies, which is an important architectural characteristic of the project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef client fill:#e1f5fe,stroke:#01579b
    classDef wrapper fill:#e8f5e9,stroke:#1b5e20
    classDef core fill:#bbdefb,stroke:#0d47a1
    classDef process fill:#c8e6c9,stroke:#2e7d32
    classDef types fill:#fff9c4,stroke:#f57f17
    classDef error fill:#ffcdd2,stroke:#b71c1c
    classDef external fill:#f5f5f5,stroke:#212121

    %% Client Layer
    Client["Client Application"]:::client

    %% Wrapper Interface Layer
    subgraph WrapperLayer["Wrapper Interface"]
        WrapperMain["Main Interface"]
        WrapperFuncs["Wrapper Functions"]
    end

    %% Core API Classes Layer
    subgraph CoreLayer["Core API Classes"]
        Course["Course"]:::core
        CourseSection["CourseSection"]:::core
        Department["Department"]:::core
        Instructor["Instructor"]:::core
        Schedule["Schedule"]:::core
        SchedulePart["SchedulePart"]:::core
    end

    %% Data Processing Layer
    subgraph ProcessLayer["Data Processing"]
        ProcessCourse["Course Processor"]:::process
        ProcessSection["Section Processor"]:::process
        ProcessDept["Department Processor"]:::process
        ProcessInstr["Instructor Processor"]:::process
        ProcessSchedule["Schedule Processor"]:::process
    end

    %% Types System Layer
    subgraph TypesLayer["Types System"]
        CourseTypes["Course Types"]:::types
        SectionTypes["Section Types"]:::types
        DeptTypes["Department Types"]:::types
        InstrTypes["Instructor Types"]:::types
        ScheduleTypes["Schedule Types"]:::types
    end

    %% Error Handling Layer
    subgraph ErrorLayer["Error Handling"]
        EmptyError["Empty Response"]:::error
        InvalidError["Invalid Response"]:::error
        NotFoundError["Not Found"]:::error
        RetryError["Retry Limit"]:::error
    end

    %% External Layer
    SFUAPI["SFU Course Outlines API"]:::external

    %% Relationships
    Client --> WrapperLayer
    WrapperLayer --> CoreLayer
    CoreLayer --> ProcessLayer
    ProcessLayer --> TypesLayer
    ProcessLayer --> SFUAPI
    CoreLayer <--> ErrorLayer

    %% Click Events
    click WrapperMain "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/index.ts"
    click WrapperFuncs "https://github.com/ewanbrinkman/sfu-course-api-wrapper/tree/main/src/wrappers/"
    click Course "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/api/Course.ts"
    click CourseSection "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/api/CourseSection.ts"
    click Department "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/api/Department.ts"
    click Instructor "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/api/Instructor.ts"
    click Schedule "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/api/Schedule.ts"
    click SchedulePart "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/api/SchedulePart.ts"
    click ProcessCourse "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/utils/process/processRawCourseData.ts"
    click ProcessSection "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/utils/process/processRawCourseSectionData.ts"
    click ProcessDept "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/utils/process/processRawDepartmentData.ts"
    click ProcessInstr "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/utils/process/processRawInstructorData.ts"
    click ProcessSchedule "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/utils/process/processRawScheduleData.ts"
    click CourseTypes "https://github.com/ewanbrinkman/sfu-course-api-wrapper/tree/main/src/api-types/response/Course/"
    click SectionTypes "https://github.com/ewanbrinkman/sfu-course-api-wrapper/tree/main/src/api-types/response/CourseSection/"
    click DeptTypes "https://github.com/ewanbrinkman/sfu-course-api-wrapper/tree/main/src/api-types/response/Department/"
    click InstrTypes "https://github.com/ewanbrinkman/sfu-course-api-wrapper/tree/main/src/api-types/response/Instructor/"
    click ScheduleTypes "https://github.com/ewanbrinkman/sfu-course-api-wrapper/tree/main/src/api-types/response/Schedule/"
    click EmptyError "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/errors/EmptyResponseError.ts"
    click InvalidError "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/errors/InvalidResponseError.ts"
    click NotFoundError "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/errors/NotFoundError.ts"
    click RetryError "https://github.com/ewanbrinkman/sfu-course-api-wrapper/blob/main/src/errors/RetryLimitReachedError.ts"
```
