# zikenn26/examdashboard architecture

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

- Interactive diagram: https://gitdiagram.com/zikenn26/examdashboard
- Repository: https://github.com/zikenn26/examdashboard

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“My Exam Dashboard”) that provides:
– User authentication and profiles
– Exam and category CRUD
– Real-time countdown timers and bookmarks
– News integration with AI summarization
– An AI chatbot and study-plan generator
- It uses a React + Vite + Tailwind front end, and an Express + Node back end with external AI and news APIs.

##### File Structure
- Top-level:
– package.json, index.html, src/ → Front-end code
– server/ → Back-end code (routes, middleware, services)
– config files: .env, tsconfig.json, ESLint, Tailwind, Vite
- server/ substructure:
– server/server.js → Express app entry point
– server/routes/ → Controllers for auth, exams, categories, news, AI
– server/middleware/auth.js → JWT validation
– server/services/ → API-wrapper modules (openai.js, gemini.js, newsApi.js)
– server/data.js → Mock or persistence layer
- src/ substructure:
– src/pages/ → Route-level pages (Dashboard, News, AdminPanel, etc.)
– src/components/ → Presentational components by feature
– src/context/, src/hooks/ → State management and API hooks
– src/utils/ → Shared utilities

##### README for Additional Insights
- JWT-based login/signup
- REST endpoints under /api/**
- External dependencies:
– OpenAI (GPT-3.5) → /api/ai/chat, exam-summary, recommendations
– Gemini AI → /api/ai/exam-insights, study-plan
– NewsAPI → /api/news, /api/ai/news-analysis
- Fallback to mock data if env vars missing

##### Main Components
a. Front-End (Browser)
– UI Layer (pages, components)
– State & Context (AuthContext, ThemeContext)
– API Client (useApi hook)
b. Back-End (Node/Express)
– HTTP Server (Express)
– Middleware (Auth/JWT, CORS, body-parser)
– Controllers (route handlers for auth, exams, categories, news, AI)
– Service Layer (wrappers for external AI & News APIs)
– Data Layer (mock data or database abstraction in data.js)
c. External Services
– OpenAI API
– Google Gemini API
– NewsAPI
d. Persistence Layer
– (Optional) Database (e.g., MongoDB/PostgreSQL) or mock data store

##### Relationships & Data Flows
- Front-End ↔ Back-End over HTTPS/REST
– Auth requests: login, register → backend → JWT issued
– Exam, category, news data fetch/update
– AI API requests forwarded by back end
- Back-End → External Services (OpenAI, Gemini, NewsAPI)
– Service modules handle HTTP calls, return JSON
- Back-End → Data Layer
– CRUD operations on exams, users, categories
- Real-time countdowns, bookmarks, and notifications are purely front-end features driven by fetched data

##### Architectural Patterns & Design Principles
- Layered Architecture (Presentation, API/Controller, Service, Data)
- Separation of Concerns:
– React components vs. context/hooks vs. pure UI
– Express routes vs. middleware vs. services
- MVC-style backend, though data layer is simple
- Client-Server RESTful design
- Use of external APIs as integration points (adapter pattern in services/)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Browser
    User["User"]:::user
    Browser["Browser"]:::frontend

    User -->|"Interacts via UI"| Browser

    subgraph "Front-End (React + Vite + Tailwind)" 
        direction TB
        Pages["Pages\n(Dashboard, News, AdminPanel,\nAllExams, Categories, Profile)"]:::frontend
        Components["Presentational Components\n(LoginForm, RegisterForm,\nChatBot, CountdownTimer,\nLoadingSpinner, SearchBar,\nExamCard, ExamFilters,\nHeader, Sidebar)"]:::frontend
        Context["State & Context\n(AuthContext, ThemeContext)"]:::frontend
        Hook["API Client Hook\n(useApi)"]:::frontend

        Browser --> Pages
        Pages --> Components
        Pages --> Context
        Pages --> Hook
    end

    subgraph "Back-End (Node/Express)" 
        direction TB
        Server["Express Server\n(server.js)"]:::backend
        Middleware["Middleware\n(JWT Auth, CORS,\nbody-parser)"]:::backend
        Controllers["Controllers\n(auth.js, exams.js,\ncategories.js, news.js,\nai.js, user.js)"]:::backend
        Services["Service Layer\n(openai.js, gemini.js,\nnewsApi.js)"]:::backend
        DataLayer["Data Layer\n(data.js)"]:::database

        Hook -->|HTTPS REST| Server
        Server --> Middleware
        Middleware --> Controllers
        Controllers --> Services
        Controllers --> DataLayer
    end

    subgraph "External Services" 
        direction TB
        OpenAI["OpenAI API"]:::external
        Gemini["Google Gemini API"]:::external
        NewsAPI["NewsAPI"]:::external

        Services -->|API calls| OpenAI
        Services -->|API calls| Gemini
        Services -->|API calls| NewsAPI
    end

    Controllers -->|CRUD Exams/Categories| DataLayer
    Controllers -->|Proxy /api/ai/*| Services

    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#0d47a1;
    classDef backend fill:#d5f5e3,stroke:#28a745,color:#145a32;
    classDef external fill:#fce4ec,stroke:#ec407a,color:#880e4f,shape:hexagon;
    classDef database fill:#fff3cd,stroke:#f39c12,color:#7a4f01,shape:cylinder;
    classDef user fill:#e0e0e0,stroke:#616161,color:#212121;

    %% Click Events for Front-End
    click Pages "https://github.com/zikenn26/examdashboard/blob/main/src/pages/Dashboard.tsx"
    click Pages "https://github.com/zikenn26/examdashboard/blob/main/src/pages/News.tsx"
    click Pages "https://github.com/zikenn26/examdashboard/blob/main/src/pages/AdminPanel.tsx"
    click Pages "https://github.com/zikenn26/examdashboard/blob/main/src/pages/AllExams.tsx"
    click Pages "https://github.com/zikenn26/examdashboard/blob/main/src/pages/Categories.tsx"
    click Pages "https://github.com/zikenn26/examdashboard/blob/main/src/pages/Profile.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/auth/LoginForm.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/auth/RegisterForm.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/chat/ChatBot.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/common/CountdownTimer.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/common/LoadingSpinner.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/common/SearchBar.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/exams/ExamCard.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/exams/ExamFilters.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/layout/Header.tsx"
    click Components "https://github.com/zikenn26/examdashboard/blob/main/src/components/layout/Sidebar.tsx"
    click Context "https://github.com/zikenn26/examdashboard/blob/main/src/context/AuthContext.tsx"
    click Context "https://github.com/zikenn26/examdashboard/blob/main/src/context/ThemeContext.tsx"
    click Hook "https://github.com/zikenn26/examdashboard/blob/main/src/hooks/useApi.ts"

    %% Click Events for Back-End
    click Server "https://github.com/zikenn26/examdashboard/blob/main/server/server.js"
    click Middleware "https://github.com/zikenn26/examdashboard/blob/main/server/middleware/auth.js"
    click Controllers "https://github.com/zikenn26/examdashboard/blob/main/server/routes/auth.js"
    click Controllers "https://github.com/zikenn26/examdashboard/blob/main/server/routes/exams.js"
    click Controllers "https://github.com/zikenn26/examdashboard/blob/main/server/routes/categories.js"
    click Controllers "https://github.com/zikenn26/examdashboard/blob/main/server/routes/news.js"
    click Controllers "https://github.com/zikenn26/examdashboard/blob/main/server/routes/ai.js"
    click Controllers "https://github.com/zikenn26/examdashboard/blob/main/server/routes/user.js"
    click Services "https://github.com/zikenn26/examdashboard/blob/main/server/services/openai.js"
    click Services "https://github.com/zikenn26/examdashboard/blob/main/server/services/gemini.js"
    click Services "https://github.com/zikenn26/examdashboard/blob/main/server/services/newsApi.js"
    click DataLayer "https://github.com/zikenn26/examdashboard/blob/main/server/data.js"
    click DataLayer "https://github.com/zikenn26/examdashboard/blob/main/server/.env.example"
```
