# zigbee-student-developers-club/zigbee-2 architecture

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

- Interactive diagram: https://gitdiagram.com/zigbee-student-developers-club/zigbee-2
- Repository: https://github.com/zigbee-student-developers-club/zigbee-2

## Overview

##### Project Type and Purpose
- Project Type: This is a full-stack web application built using Next.js (with the new app directory structure) where both the frontend and backend (API endpoints) coexist.
- Purpose: Zigbee is a community-driven initiative for software development by students. The project is clearly segmented into various functional areas (e.g., alumni, codewars, dashboard, events, gallery, login, magazines, profile, resources, team, upload-profile), which likely support community-driven interactions, content display, and user interaction.

##### File Structure
- Top-Level Files: Configuration files (.env.example, tsconfig.json, tailwind.config.ts, next.config.mjs, etc.) and project-specific ones (package.json, README.md) make clear that the project follows best practices for code quality and styling (ESLint, Prettier).
- Directory “src”: Contains the core of the application.
- “src/app”: Acts as the main entry point, organized by feature groups using route segments (e.g., alumni, events, login, dashboard). This shows a clear separation of concerns and a modular approach.
- “src/app/api”: Contains API endpoints used by the front-end, including subdirectories for admin operations (e.g., events, magazines, resource, users, seed) and public endpoints (e.g., auth, alumni, check-user), indicating a RESTful API design integrated into the Next.js framework.
- “src/components”: Holds common UI components as well as feature-specific UI elements. The naming (e.g., Header, Footer, Card, Modal, etc.) indicates that these are reused across pages.
- “src/lib”: Contains modules for external integrations and utilities such as axios (allApiCall and axiosConfig), cloudinary, firebase, jwt, and middleware for authentication and authorization. This suggests the project interacts with multiple external services.
- “src/hooks”: Custom hooks (like use-toast) are defined to manage state and side-effects.
- Public Assets: The “public” directory contains static files (like the site.webmanifest) that are served directly.

##### Main Components
- Frontend (Client Side):
- Pages & Route Components: Each folder under src/app/(app) (e.g., alumni, events, dashboard, team, etc.) represents a distinct view or section of the application.
- Common UI Components in src/app/_components and src/components: Includes layout elements (Header, Footer, Hero) and reusable UI pieces (Card, Modal, etc.).
- API Layer (Backend):
- API Endpoints: Represented in src/app/api with distinct groups for public endpoints (e.g., auth, alumni, event, login, etc.) and admin-specific endpoints.
- Authentication: Managed through next-auth under src/app/api/auth and additional user verification endpoints like sendotp, verifyotp.
- External Integrations and Services:
- Firebase: For authentication or realtime updates.
- Cloudinary: For image uploading & management.
- Resend: Likely used for emails (given the components for email templates).
- Axios: For making API calls within the application.
- Utility Libraries & Middleware:
- Middleware for authentication/authorization found in src/lib/middleware.
- Global styling and theme management through Tailwind CSS and other providers.

##### Relationships and Interactions
- Data Flow:
- Users interact with Frontend pages that use common UI components and are structured within the Next.js app directory.
- These pages communicate with API endpoints to perform actions like authentication, fetching data for alumni, events, galleries, etc.
- API endpoints contain business logic and interface with external services (Firebase, Cloudinary, Resend) as well as internal databases (if any) or storage.
- The utility libraries (axios, SWR hooks) in src/lib facilitate communication between the frontend and these API routes.
- Architectural Patterns:
- The separation of the “app” directory into UI and API subfolders denotes a clear pattern of organizing routes.
- Code modularity with reusable components, custom hooks, and utility libraries follows component-based architectural principles.
- Built-in use of middleware for authentication/authorization ensures secure access control across endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    U["User"]:::frontend

    %% Frontend UI Components and Pages
    subgraph "Frontend (UI Components and Pages)"
        direction TB
        Shared_UI["Shared UI Components"]:::frontend
        Alumni_Page["Alumni Page"]:::frontend
        Codewars_Page["Codewars Page"]:::frontend
        Dashboard_Page["Dashboard Page"]:::frontend
        Events_Page["Events Page"]:::frontend
        Gallery_Page["Gallery Page"]:::frontend
        Login_Page["Login Page"]:::frontend
        Magazines_Page["Magazines Page"]:::frontend
        Profile_Page["Profile Page"]:::frontend
        Resources_Page["Resources Page"]:::frontend
        Team_Page["Team Page"]:::frontend
        Upload_Profile_Page["Upload Profile Page"]:::frontend
    end

    %% Utility libraries used by the Frontend
    subgraph "Utility & Middleware"
        direction TB
        Axios_SWR["Axios & SWR"]:::utility
        SWR_Hooks["SWR Hooks"]:::utility
        Middleware["Middleware"]:::utility
    end

    %% Backend API Endpoints
    subgraph "Backend API Endpoints"
        direction TB
        Alumni_API["Alumni API"]:::backend
        Magazine_API["Magazine API"]:::backend
        Resource_API["Resource API"]:::backend
        Team_API["Team API"]:::backend
        Update_Profile_API["Update Profile API"]:::backend
        Auth_API["Authentication API"]:::backend
        OTP_Send_API["OTP Send API"]:::backend
        OTP_Verify_API["OTP Verify API"]:::backend
        Admin_API["Admin Endpoints"]:::backend
    end

    %% External Integrations
    subgraph "External Services"
        direction TB
        Firebase["Firebase Integration"]:::external
        Cloudinary["Cloudinary Integration"]:::external
        Resend["Resend Integration"]:::external
    end

    %% Data Flow Connections
    U --> Shared_UI
    Shared_UI --> Axios_SWR
    Axios_SWR --> Alumni_API
    Axios_SWR --> Magazine_API
    Axios_SWR --> Resource_API
    Axios_SWR --> Team_API
    Axios_SWR --> Update_Profile_API

    %% Direct Frontend to API calls for specific pages
    Alumni_Page -->|"callsAPI"| Alumni_API
    Magazines_Page -->|"callsAPI"| Magazine_API
    Resources_Page -->|"callsAPI"| Resource_API
    Team_Page -->|"callsAPI"| Team_API
    Upload_Profile_Page -->|"callsAPI"| Update_Profile_API
    Login_Page -->|"callsAPI"| Auth_API
    Login_Page -->|"callsAPI"| OTP_Send_API
    Login_Page -->|"callsAPI"| OTP_Verify_API

    %% Additional connections from other pages to Admin endpoints
    Dashboard_Page -->|"callsAPI"| Admin_API
    Events_Page -->|"callsAPI"| Admin_API
    Gallery_Page -->|"callsAPI"| Admin_API
    Codewars_Page -->|"callsAPI"| Admin_API
    Profile_Page -->|"callsAPI"| Admin_API

    %% Middleware integration in API flow
    Auth_API --> Middleware
    Update_Profile_API --> Middleware

    %% Middleware forwarding to External Services
    Middleware --> Firebase
    Middleware --> Cloudinary

    %% Specific external integrations by API endpoints
    OTP_Send_API --> Resend

    %% SWR Hooks used by Frontend components
    Shared_UI --> SWR_Hooks

    %% Click Events for Frontend Pages & Components
    click Alumni_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/alumni"
    click Codewars_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/codewars"
    click Dashboard_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/dashboard"
    click Events_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/events"
    click Gallery_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/gallery"
    click Login_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/login"
    click Magazines_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/magazines"
    click Profile_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/profile"
    click Resources_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/resources"
    click Team_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/team"
    click Upload_Profile_Page "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/(app)/upload-profile"
    click Shared_UI "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/_components"
    click Shared_UI "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/components"

    %% Click Events for API Endpoints
    click Alumni_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/alumni/route.ts"
    click Magazine_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/magazine/route.ts"
    click Resource_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/resource/route.ts"
    click Team_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/team/route.ts"
    click Update_Profile_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/update-profile-image/route.ts"
    click Auth_API "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/app/api/auth"
    click OTP_Send_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/sendotp/route.ts"
    click OTP_Verify_API "https://github.com/zigbee-student-developers-club/zigbee-2/blob/main/src/app/api/verifyotp/route.ts"

    %% Click Events for External Integrations
    click Firebase "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/lib/firebase"
    click Cloudinary "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/lib/cloudinary"
    click Resend "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/lib/resend"

    %% Click Events for Utility Libraries & Middleware
    click Axios_SWR "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/lib/axios"
    click SWR_Hooks "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/lib/SWRhooks"
    click Middleware "https://github.com/zigbee-student-developers-club/zigbee-2/tree/main/src/lib/middleware"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef utility fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
```
