# paragkoche/group-16-it architecture

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

- Interactive diagram: https://gitdiagram.com/paragkoche/group-16-it
- Repository: https://github.com/paragkoche/group-16-it

## Overview

##### Project Overview & Type
- This is a full-stack application with a clearly separated backend (built with Node.js/Express and TypeScript) and frontend (built with Next.js).
- The README details how to launch both servers, which run on different ports (backend on 8080, frontend on 3000).

##### Main Components
a. Frontend:
- Next.js Application
– Pages grouped under different segments: (auth) (login, register), (dashboard) (dashboard, share-files, upload-file), and (landing) pages.
– API endpoints under src/api, which likely interact with the backend.
– Common UI components (Card, Header, Nav, SideDrawer) and providers (auth.provider) that manage application state or authentication.
- Data flow: User interactions in the frontend trigger API calls (through the Next.js endpoints) to the backend.

b. Backend:
- Express Server based on TypeScript (src/app.ts, server.ts) that sets up APIs.
- Routers:
– Route handling is split across different modules (router/file.ts, router/users.ts) to handle file and user-related endpoints.
- Middleware:
– Authentication middleware (auth.middleware.ts) is used for request validation.
- Database Layer:
– Individual modules for handling files (files.ts), users (users.ts), a repository (repo.ts), and an index entry point.
– A local file-based database (new.db) is used.
- Helper/Utility Modules:
– JWT helper, password functions, schema validations, and possibly additional file utilities (under utl folder and helper modules).

c. External Linking:
- A static folder in the backend storing static assets suggests file serving.
- Environment configuration (.env in frontend) sets the API base URL.

##### Relationships and Interactions
- The user’s browser interacts with the Next.js frontend.
- The frontend communicates with the backend over HTTP requests (using the API base URL defined in the .env).
- The backend routes receive the request, process authentication via middleware and helper functions (JWT verification, password hashing) and then interact with the database modules.
- Data from the database or responses built by the backend are sent back to the frontend.

##### Architectural Patterns & Design Principles
- Separation of concerns: Clear division between frontend and backend.
- MVC or similar layered patterns in the backend – routers/controllers, middleware, and database abstraction layers.
- Use of module-based design in both frontend (components, providers, pages) and backend (routes, middleware, database access helpers).
- Dependency management via package.json files, and configuration support via environment files.

##### Final Assembly
- Expand the backend to show its internal organization (routers, middleware, database layer, helper functions).
- Notes on development tools (npm, TypeScript configuration, etc.) if needed for clarity.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global User
    U["User Browser"]:::user

    %% Frontend Layer
    subgraph "Frontend (Next.js)"
        FE1["Next.js Application"]:::frontend
        subgraph "Pages"
            FE_A1["Auth: Login"]:::frontend
            FE_A2["Auth: Register"]:::frontend
            FE_D1["Dashboard: Dashboard"]:::frontend
            FE_D2["Dashboard: Share Files"]:::frontend
            FE_D3["Dashboard: Upload File"]:::frontend
            FE_L1["Landing Page"]:::frontend
        end
        FE_API["API Endpoints"]:::frontend
        FE_UI["UI Components"]:::frontend
        FE_Prov["Auth Provider"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Express Server)"
        BE_Core["Core Server Files"]:::backend
        BE_MW["Authentication Middleware"]:::backend
        subgraph "Routers"
            BE_R1["File Routes"]:::backend
            BE_R2["User Routes"]:::backend
        end
        subgraph "Database Layer"
            BE_DB_M["Database Modules"]:::database
            BE_DB_P["Persistent Storage (new.db)"]:::database
        end
        subgraph "Helper Modules"
            BE_H1["JWT Helper"]:::backend
            BE_H2["Password Helper"]:::backend
            BE_H3["Schema Validator"]:::backend
            BE_H4["File Utility"]:::backend
        end
        BE_Static["Static Assets"]:::backend
    end

    %% Connections - Frontend Flow
    U -->|"requests"| FE1
    FE_A1 -->|"submits"| FE_API
    FE_A2 -->|"submits"| FE_API
    FE_D1 -->|"requests"| FE_API
    FE_D2 -->|"requests"| FE_API
    FE_D3 -->|"requests"| FE_API
    FE_API -->|"HTTP call"| BE_Core

    %% Connections - Backend Flow
    BE_Core -->|"validates"| BE_MW
    BE_MW -->|"routes to"| BE_R1
    BE_MW -->|"routes to"| BE_R2
    BE_R1 -->|"DB query"| BE_DB_M
    BE_R2 -->|"DB query"| BE_DB_M
    BE_DB_M -->|"persists"| BE_DB_P
    BE_R1 -->|"utilizes"| BE_H1
    BE_R2 -->|"utilizes"| BE_H1
    BE_R1 -->|"assists"| BE_H2
    BE_R2 -->|"assists"| BE_H3
    BE_R1 -->|"assists"| BE_H4
    BE_Core -->|"serves"| BE_Static

    %% Click Events for Frontend
    click FE1 "https://github.com/paragkoche/group-16-it/tree/main/frontend/"
    click FE_A1 "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/app/(auth)/auth/login/page.tsx"
    click FE_A2 "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/app/(auth)/auth/register/page.tsx"
    click FE_D1 "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/app/(dashboard)/dashboard/page.tsx"
    click FE_D2 "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/app/(dashboard)/dashboard/share-files/page.tsx"
    click FE_D3 "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/app/(dashboard)/dashboard/upload-file/page.tsx"
    click FE_L1 "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/app/(landing)/page.tsx"
    click FE_API "https://github.com/paragkoche/group-16-it/tree/main/frontend/src/api/"
    click FE_UI "https://github.com/paragkoche/group-16-it/tree/main/frontend/src/components/"
    click FE_Prov "https://github.com/paragkoche/group-16-it/blob/main/frontend/src/providers/auth.provider.tsx"

    %% Click Events for Backend
    click BE_Core "https://github.com/paragkoche/group-16-it/blob/main/backend/src/app.ts"
    click BE_R1 "https://github.com/paragkoche/group-16-it/blob/main/backend/src/router/file.ts"
    click BE_R2 "https://github.com/paragkoche/group-16-it/blob/main/backend/src/router/users.ts"
    click BE_MW "https://github.com/paragkoche/group-16-it/blob/main/backend/src/middleware/auth.middleware.ts"
    click BE_DB_M "https://github.com/paragkoche/group-16-it/tree/main/backend/src/database/"
    click BE_DB_P "https://github.com/paragkoche/group-16-it/blob/main/backend/new.db"
    click BE_H1 "https://github.com/paragkoche/group-16-it/blob/main/backend/src/helper/jwt.ts"
    click BE_H2 "https://github.com/paragkoche/group-16-it/blob/main/backend/src/helper/password.ts"
    click BE_H3 "https://github.com/paragkoche/group-16-it/blob/main/backend/src/helper/schema.ts"
    click BE_H4 "https://github.com/paragkoche/group-16-it/blob/main/backend/src/utl/file.ts"
    click BE_Static "https://github.com/paragkoche/group-16-it/tree/main/backend/static/"

    %% Styles
    classDef user fill:#fff3cd,stroke:#d39e00,stroke-width:2px;
    classDef frontend fill:#d4efdf,stroke:#27ae60,stroke-width:2px;
    classDef backend fill:#d6eaf8,stroke:#2980b9,stroke-width:2px;
    classDef database fill:#fef9e7,stroke:#f39c12,stroke-width:2px;
```
