# hungluong05/schedura architecture

> Architecture diagram of the GitHub repository hungluong05/schedura, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hungluong05/schedura
- Repository: https://github.com/hungluong05/schedura

## Overview

##### Project type and purpose
- This is a full-stack calendar events management system (“Schedura”) with a React/TypeScript frontend and a Node.js/Express backend.
- Purpose: allow users to register/login, view and manage events (with tags), and synchronize those events with Google Calendar and Microsoft Outlook.

##### File structure
- Top-level directories:
- backend/ – Express API server
- frontend/ – React SPA (Vite + TypeScript)
- Backend substructure follows an MVC-ish pattern:
- config/ – auth and environment setup (Google, Microsoft, JWT)
- controllers/ – request handlers (auth, events)
- routes/ – API endpoint definitions (auth.js, calendar.js, user.js)
- models/ – Mongoose (or similar) schemas for User and Event
- database/ – connection logic
- middlewares/ – authentication middleware
- utils/ – calendar_sync logic with external providers
- Frontend substructure is componentized:
- src/pages – top-level views (Auth, Calendar, Tasks)
- src/components – reusable UI parts (Auth, Calendar views, NavBar, SideBar)
- src/context – global AuthContext
- src/hooks – custom hooks (useAuth, useUser, useLocalStorage)
- src/utils – route protection, helper functions
- Config/build files: package.json, tsconfig, tailwind.config, vite.config, .env loading.

##### Insights from README
- Describes two-step startup (npm install & npm start/dev)
- Highlights Google & Microsoft sync, custom tags.

##### Detail guidance
- Call out the calendar_sync utility as the bridge to external calendars.
- On the frontend, show ProtectedRoute and AuthContext wrapping Calendar and Tasks pages.
- Don’t overcrowd: only include modules that impact data flow or responsibilities.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    User("User") 

    %% Frontend
    subgraph "Browser / React Client"
        direction TB
        ReactApp["React App"]:::frontend

        subgraph "Context & Routing"
            direction TB
            AuthContext["AuthContext"]:::frontend
            ProtectedRoute["ProtectedRoute"]:::frontend
        end

        subgraph "Pages"
            direction TB
            AuthPage["Auth Page"]:::frontend
            CalendarPage["Calendar Page"]:::frontend
            TasksPage["Tasks Page"]:::frontend
        end

        subgraph "Components"
            direction TB
            LoginComponent["LoginComponent"]:::frontend
            RegisterComponent["RegisterComponent"]:::frontend
            NavBar["NavBar"]:::frontend
            SideBar["SideBar"]:::frontend
            CalendarNavBar["CalendarNavBar"]:::frontend
            AddEvent["AddEvent"]:::frontend
            ViewEvent["ViewEvent"]:::frontend
            TagsField["TagsField"]:::frontend
            WeekView["WeekView"]:::frontend
            Days["Days"]:::frontend
            Day["Day"]:::frontend
        end

        subgraph "Hooks"
            direction TB
            useAuth["useAuth"]:::frontend
            useUser["useUser"]:::frontend
            useLocalStorage["useLocalStorage"]:::frontend
        end
    end

    %% Backend
    subgraph "Server / API"
        direction TB
        ExpressAPI["Express API"]:::backend

        subgraph "Configuration"
            direction TB
            GoogleOAuth["Google OAuth (authGoogle.js)"]:::backend
            MicrosoftOAuth["Microsoft OAuth (authMicrosoft.js)"]:::backend
            JWTAuth["JWT Auth (authJWT.js)"]:::backend
            Env["Environment (.env)"]:::backend
        end

        subgraph "Routes"
            direction TB
            AuthRoutes["Auth Routes"]:::backend
            CalendarRoutes["Calendar Routes"]:::backend
            UserRoutes["User Routes"]:::backend
        end

        subgraph "Controllers"
            direction TB
            AuthenticationController["Authentication Controller"]:::backend
            EventsController["Events Controller"]:::backend
        end

        subgraph "Models"
            direction TB
            UserModel["User Model"]:::backend
            EventModel["Event Model"]:::backend
        end

        subgraph "Middlewares"
            direction TB
            JWTMiddleware["JWT Middleware"]:::backend
        end

        subgraph "Utilities"
            direction TB
            CalendarSync["Calendar Sync"]:::backend
        end
    end

    %% Database
    MongoDB["MongoDB"]:::database

    %% External Services
    GoogleCal["Google Calendar API"]:::external
    Outlook["Microsoft Graph API"]:::external

    %% Connections
    User -->|"uses UI"| ReactApp
    ReactApp -->|"HTTP/JSON"| ExpressAPI
    ExpressAPI -->|"reads/writes"| MongoDB
    ExpressAPI -->|"OAuth API calls"| GoogleCal
    ExpressAPI -->|"OAuth API calls"| Outlook

    ExpressAPI --> GoogleOAuth
    ExpressAPI --> MicrosoftOAuth
    ExpressAPI --> JWTAuth
    ExpressAPI --> Env

    ExpressAPI --> AuthRoutes
    ExpressAPI --> CalendarRoutes
    ExpressAPI --> UserRoutes

    AuthRoutes --> AuthenticationController
    CalendarRoutes --> EventsController
    UserRoutes --> AuthenticationController

    AuthenticationController --> UserModel
    EventsController --> EventModel
    EventsController --> CalendarSync

    AuthenticationController --> JWTMiddleware
    EventsController --> JWTMiddleware

    %% Click Events - Frontend
    click ReactApp "https://github.com/hungluong05/schedura/tree/main/frontend/"
    click AuthContext "https://github.com/hungluong05/schedura/blob/main/frontend/src/context/AuthContext.tsx"
    click ProtectedRoute "https://github.com/hungluong05/schedura/blob/main/frontend/src/utils/ProtectedRoute/ProtectedRoute.tsx"
    click AuthPage "https://github.com/hungluong05/schedura/blob/main/frontend/src/pages/Auth.tsx"
    click CalendarPage "https://github.com/hungluong05/schedura/blob/main/frontend/src/pages/Calendar.tsx"
    click TasksPage "https://github.com/hungluong05/schedura/blob/main/frontend/src/pages/Tasks.tsx"
    click LoginComponent "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Auth/LoginComponent.tsx"
    click RegisterComponent "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Auth/RegisterComponent.tsx"
    click NavBar "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/NavBar/NavBar.tsx"
    click SideBar "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/SideBar/SideBar.tsx"
    click CalendarNavBar "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/CalendarNavBar/CalendarNavBar.tsx"
    click AddEvent "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/Event/AddEvent/AddEvent.tsx"
    click ViewEvent "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/Event/ViewEvent/ViewEvent.tsx"
    click TagsField "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/Tag/TagsField.tsx"
    click WeekView "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/WeekView/WeekView.tsx"
    click Days "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/WeekView/Days.tsx"
    click Day "https://github.com/hungluong05/schedura/blob/main/frontend/src/components/Calendar/WeekView/Day.tsx"
    click useAuth "https://github.com/hungluong05/schedura/blob/main/frontend/src/hooks/useAuth.tsx"
    click useUser "https://github.com/hungluong05/schedura/blob/main/frontend/src/hooks/useUser.tsx"
    click useLocalStorage "https://github.com/hungluong05/schedura/blob/main/frontend/src/hooks/useLocalStorage.tsx"

    %% Click Events - Backend
    click ExpressAPI "https://github.com/hungluong05/schedura/blob/main/backend/main.js"
    click GoogleOAuth "https://github.com/hungluong05/schedura/blob/main/backend/config/authGoogle.js"
    click MicrosoftOAuth "https://github.com/hungluong05/schedura/blob/main/backend/config/authMicrosoft.js"
    click JWTAuth "https://github.com/hungluong05/schedura/blob/main/backend/config/authJWT.js"
    click Env "https://github.com/hungluong05/schedura/blob/main/backend/config/dotenv.js"
    click AuthenticationController "https://github.com/hungluong05/schedura/blob/main/backend/controllers/auth.js"
    click EventsController "https://github.com/hungluong05/schedura/blob/main/backend/controllers/events.js"
    click AuthRoutes "https://github.com/hungluong05/schedura/blob/main/backend/routes/auth.js"
    click CalendarRoutes "https://github.com/hungluong05/schedura/blob/main/backend/routes/calendar.js"
    click UserRoutes "https://github.com/hungluong05/schedura/blob/main/backend/routes/user.js"
    click UserModel "https://github.com/hungluong05/schedura/blob/main/backend/models/User.model.js"
    click EventModel "https://github.com/hungluong05/schedura/blob/main/backend/models/Event.model.js"
    click JWTMiddleware "https://github.com/hungluong05/schedura/blob/main/backend/middlewares/authenticate.js"
    click CalendarSync "https://github.com/hungluong05/schedura/blob/main/backend/utils/calendar_sync.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#DFFFE0,stroke:#228B22,color:#228B22
    classDef database fill:#F0F0F0,stroke:#555,color:#555
    classDef external fill:#FFE4B5,stroke:#FF8C00,color:#FF8C00
```
