# henrique-jost/hack4edu architecture

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

- Interactive diagram: https://gitdiagram.com/henrique-jost/hack4edu
- Repository: https://github.com/henrique-jost/hack4edu

## Overview

This project is a full-stack Next.js application designed to offer an interactive tutoring platform where teachers can create intelligent tutors and students interact via audio. The system supports authentication, chat, file management, and analytics, all backed by PostgreSQL (via drizzle-orm) and integrated with several external services like hume.ai and @vercel offerings.

- Frontend (UI):
- Next.js pages (e.g., /app/(auth) and /app/(chat)) as the user interface for login, chat interaction, and dashboard views.
- React components (in the components directory) displaying chat, forms, history, etc.
- Tailwind CSS for styling.

- Backend/API:
- API routes under /app/(auth)/api and /app/(chat)/api handling authentication (using next-auth) and chat functions.
- Middleware components (see middleware.ts and AI logic in /ai directory) processing specific features such as RAG and AI interactions.

- Database:
- PostgreSQL management via drizzle-orm (drizzle.config.ts, schema.ts) for storing user data, chat logs, and analytics.
- Future integration with a vector database for enhanced student-interaction data.

- AI and External Services:
- The ai directory contains core logic to interface with language models and audio-based interaction systems.
- External dependencies include @ai-sdk/openai and hume-ai for audio and sentiment analysis.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    User["User"]:::user

    %% Frontend Layer
    subgraph "Frontend (UI)"
        A["Authentication Pages"]:::frontend
        B["Chat Page"]:::frontend
        C["React Components"]:::frontend
        D["Tailwind Styling"]:::frontend
    end

    %% Backend/API Layer
    subgraph "Backend/API"
        E["Authentication API"]:::backend
        F["Chat API"]:::backend
        G["File Management API"]:::backend
        H["History API"]:::backend
        I["Middleware & AI Logic"]:::backend
    end

    %% Database Layer
    subgraph "Database"
        J["PostgreSQL (drizzle-orm)"]:::database
    end

    %% External Services Layer
    subgraph "External Services"
        K["External AI Services"]:::external
    end

    %% Connections from User to Frontend
    User --> A
    User --> B
    User --> C

    %% Frontend to Backend
    A -->|"login"| E
    B -->|"chat"| F
    C -->|"triggers"| G

    %% Backend to Database
    E -->|"store"| J
    F -->|"store"| J
    G -->|"store"| J
    H -->|"store"| J
    I -->|"store"| J

    %% Backend Internal Connections
    I -->|"process"| K

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef database fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef external fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef user fill:#EEEEEE,stroke:#757575,stroke-width:2px;

    %% Click Events
    click A "https://github.com/henrique-jost/hack4edu/blob/main/app/(auth)/login/page.tsx"
    click B "https://github.com/henrique-jost/hack4edu/blob/main/app/(chat)/page.tsx"
    click C "https://github.com/henrique-jost/hack4edu/tree/main/components/"
    click D "https://github.com/henrique-jost/hack4edu/blob/main/tailwind.config.ts"
    click E "https://github.com/henrique-jost/hack4edu/blob/main/app/(auth)/api/auth/[...nextauth]/route.ts"
    click F "https://github.com/henrique-jost/hack4edu/blob/main/app/(chat)/api/chat/route.ts"
    click G "https://github.com/henrique-jost/hack4edu/blob/main/app/(chat)/api/files/upload/route.ts"
    click H "https://github.com/henrique-jost/hack4edu/blob/main/app/(chat)/api/history/route.ts"
    click I "https://github.com/henrique-jost/hack4edu/blob/main/middleware.ts"
    click J "https://github.com/henrique-jost/hack4edu/blob/main/drizzle.config.ts"
```
