# numcap/kpa-website architecture

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

- Interactive diagram: https://gitdiagram.com/numcap/kpa-website
- Repository: https://github.com/numcap/kpa-website

## Overview

##### And Label Main Components
- Frontend: Represented by the “src” directory. This contains the main application (App.jsx), various React components (e.g., About, Calendar, HeroBanner, JoinUs), pages (login views), and layout components (Navbar, Footer). Include details showing the use of React, Vite for bundling, and Tailwind CSS for stylings.
- Backend APIs: Located under the “api” directory. Sub-components include:
- Authentication (authorization.js, login.js) to handle secure login with JWT.
- Calendar (addEvent.js) for event data handling.
- Cron Jobs (deleteOldDates.js) for scheduled tasks, such as purging old events.
- Database: Although not directly visible in the file tree, the README specifies PostgreSQL usage. Map this as an external service that interacts with the backend.
- Deployment/Hosting: Vercel plays an essential role for hosting serverless functions and delivering the site.

##### Relationships and Data Flow
- Interactions between backend APIs and the PostgreSQL database. Indicate that both the authentication and calendar features send queries and receive responses.
- Details that the frontend obtains data (about events, user session info) via these APIs.
- If applicable, note that environment variables (managed outside the file tree) secure sensitive backend configurations.

##### Architectural Patterns
- Component-based design for the frontend: emphasize the separation of concerns between UI layout, re-usable components, and state contexts (like PositionContext).
- Serverless backend design: multiple API endpoints meant for handling specific functions (Auth, Calendar, Cron jobs), each deployed as separate functions in Vercel.
- Use of JWT for stateless authentication.
- A clear separation of responsibilities between UI (handled in “src”) and backend logic (in “api”).

##### Relevant Technologies
- Vite (for fast build times)
- React (for building the UI)
- Tailwind CSS (for styling)
- PostgreSQL (for the relational database)
- Vercel (for hosting and serverless API functions)
- JWT (for authentication)
- Optionally, note supporting files such as the Vite and Tailwind configurations that frame the development environment.

- Clear labels for every component: e.g., “React Frontend”, “Auth API (JWT)”, “Calendar API”, “Cron Jobs Service”, “PostgreSQL Database”, “Vercel Hosting”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User Browser"):::external

    subgraph "Frontend Layer"
        FE("React Frontend (App.jsx)"):::frontend
        subgraph "React Components"
            About("About"):::frontend
            Calendar("Calendar"):::frontend
            HeroBanner("HeroBanner"):::frontend
            JoinUs("JoinUs"):::frontend
        end
        subgraph "Layout Components"
            Navbar("Navbar"):::frontend
            Footer("Footer"):::frontend
            Content("Content"):::frontend
        end
        subgraph "Context Providers"
            PositionContext("PositionContext"):::frontend
        end
        subgraph "Build & Styling"
            ViteConfig("Vite Config"):::frontend
            TailwindCSS("Tailwind CSS"):::frontend
        end
    end

    subgraph "Backend Layer"
        Vercel("Vercel Hosting"):::deployment
        AuthAPI("Auth API (JWT)"):::backend
        CalendarAPI("Calendar API"):::backend
        CronJobs("Cron Jobs Service"):::backend
        DB("PostgreSQL Database"):::db
    end

    %% Connections
    User --> FE
    FE -->|"Login_Request"| AuthAPI
    FE -->|"Event_Query"| CalendarAPI
    Vercel -->|"deploys"| AuthAPI
    Vercel -->|"deploys"| CalendarAPI
    Vercel -->|"deploys"| CronJobs
    AuthAPI -->|"DB_Query"| DB
    CalendarAPI -->|"DB_Query"| DB
    CronJobs -->|"Data_Cleanup"| DB

    %% Click Events
    click FE "https://github.com/numcap/kpa-website/tree/main/src"
    click About "https://github.com/numcap/kpa-website/blob/main/src/Components/About.jsx"
    click Calendar "https://github.com/numcap/kpa-website/blob/main/src/Components/Calendar.jsx"
    click HeroBanner "https://github.com/numcap/kpa-website/blob/main/src/Components/HeroBanner.jsx"
    click JoinUs "https://github.com/numcap/kpa-website/blob/main/src/Components/JoinUs.jsx"
    click Navbar "https://github.com/numcap/kpa-website/blob/main/src/layout/Navbar.jsx"
    click Footer "https://github.com/numcap/kpa-website/blob/main/src/layout/Footer.jsx"
    click Content "https://github.com/numcap/kpa-website/blob/main/src/layout/Content.jsx"
    click PositionContext "https://github.com/numcap/kpa-website/blob/main/src/contexts/PositionContext.jsx"
    click AuthAPI "https://github.com/numcap/kpa-website/tree/main/api/auth"
    click CalendarAPI "https://github.com/numcap/kpa-website/tree/main/api/calendar"
    click CronJobs "https://github.com/numcap/kpa-website/tree/main/api/cronJobs"
    click Vercel "https://github.com/numcap/kpa-website/blob/main/vercel.json"
    click ViteConfig "https://github.com/numcap/kpa-website/blob/main/vite.config.js"
    click TailwindCSS "https://github.com/numcap/kpa-website/blob/main/tailwind.config.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef db fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef deployment fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
