# iyush05/raven-file-share architecture

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

- Interactive diagram: https://gitdiagram.com/iyush05/raven-file-share
- Repository: https://github.com/iyush05/raven-file-share

## Overview

##### Main Components
- Client/Frontend: Represented by the Next.js pages (in src/app), React components (in src/components and src/components/ui), and static assets (in public). This is the user interface that interacts with the file sharing service.
- API/Server-side: The Next.js API routes (in src/app/api) provide endpoints for file uploading (/upload) and file retrieval (/getFiles). The server-side logic is integrated into the same codebase.
- Storage: AWS S3 is used for storing the shared files. This external service should be clearly represented.
- Database: Managed by Prisma using migrations (under the prisma/ directory) and a defined schema (prisma/schema.prisma). This database supports user and room data, authentication, and file metadata.
- Containerization & Deployment: Docker support is provided via the Dockerfile, allowing easy deployment. The Dockerfile and .dockerignore are important in how the application is built and run in production.

##### Relationships and Interactions
- The Frontend (Next.js UI) communicates with the API endpoints to execute file uploads, fetch file metadata, or join rooms.
- The API layer handles business logic and interacts with both AWS S3 (for file storage) and the database (through Prisma) to maintain metadata and room data.
- Deployment is done either directly using Node.js or containerized with Docker, with environment variables controlling services like AWS S3 credentials and custom API URLs.

##### Architectural Patterns and Design Principles
- Next.js indicates a server-side rendering (SSR) and API route approach. The use of API routes (serverless-style endpoints) under src/app/api shows a componentized design within a single application.
- The separation between user interface components, business logic (in API routes and lib folder), and data persistence (database via Prisma) showcases a layered architecture.
- Docker support is an example of containerization best practices for deployable and scalable applications.
- Use of TypeScript adds type safety across the application layers.

##### Incorporate Relevant Technologies and Frameworks
- Next.js & React for the frontend and server-side rendering.
- TypeScript for consistent typing.
- Prisma for database management (with migrations included).
- AWS S3 for external file storage solutions.
- Docker for containerized deployment.
- Tailwind CSS (indicated by tailwind.config.ts) for styling and UI design.
- ESLint (eslint.config.mjs) and other configuration files to ensure code quality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client/Frontend"
        subgraph "Pages & Layout"
            FE_P1["Home Page"]  
            FE_P2["Layout"]  
            FE_P3["Join Room Page"]  
            FE_P4["Room Page"]  
        end
        subgraph "React Components"
            FE_RC["UI Components"]  
        end
        subgraph "Styles"
            FE_ST["Global Styles"]  
        end
    end

    subgraph "API/Server-side"
        API_U["Upload API"]
        API_G["GetFiles API"]
    end

    subgraph "External Services"
        S3["AWS S3 (File Storage)"]
        subgraph "Database (Prisma)"
            DB_S["Prisma Schema"]
            DB_M["Migrations"]
            DB_C["Prisma Client"]
        end
    end

    subgraph "Deployment"
        DEP_D1["Dockerfile"]
        DEP_D2[".dockerignore"]
    end

    %% Relationships
    FE_P1 -->|"calls"| API_U
    FE_P1 -->|"calls"| API_G
    FE_RC -->|"triggers"| API_U
    FE_RC -->|"triggers"| API_G

    API_U -->|"inserts"| DB_S
    API_U -->|"manages"| DB_M
    API_U -->|"uploads"| S3

    API_G -->|"queries"| DB_C
    API_G -->|"fetches"| S3

    FE_P1 -->|"deployed_with"| DEP_D1
    FE_RC -->|"deployed_with"| DEP_D1
    API_U -->|"deployed_with"| DEP_D1
    API_G -->|"deployed_with"| DEP_D1

    %% Click Events for Client/Frontend
    click FE_P1 "https://github.com/iyush05/raven-file-share/blob/main/src/app/page.tsx"
    click FE_P2 "https://github.com/iyush05/raven-file-share/blob/main/src/app/layout.tsx"
    click FE_P3 "https://github.com/iyush05/raven-file-share/blob/main/src/app/joinRoom/page.tsx"
    click FE_P4 "https://github.com/iyush05/raven-file-share/blob/main/src/app/room/[roomId]/page.tsx"
    click FE_RC "https://github.com/iyush05/raven-file-share/tree/main/src/components"
    click FE_ST "https://github.com/iyush05/raven-file-share/blob/main/src/app/globals.css"

    %% Click Events for API/Server-side
    click API_U "https://github.com/iyush05/raven-file-share/blob/main/src/app/api/upload/route.ts"
    click API_G "https://github.com/iyush05/raven-file-share/blob/main/src/app/api/getFiles/route.ts"

    %% Click Events for Database (Prisma)
    click DB_S "https://github.com/iyush05/raven-file-share/blob/main/prisma/schema.prisma"
    click DB_M "https://github.com/iyush05/raven-file-share/tree/main/prisma/migrations"
    click DB_C "https://github.com/iyush05/raven-file-share/blob/main/src/lib/prisma.ts"

    %% Click Events for Deployment
    click DEP_D1 "https://github.com/iyush05/raven-file-share/tree/main/Dockerfile"
    click DEP_D2 "https://github.com/iyush05/raven-file-share/blob/main/.dockerignore"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#337ab7,stroke-width:2px;
    classDef api fill:#ffcc99,stroke:#ff8000,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef deployment fill:#f8d7da,stroke:#dc3545,stroke-width:2px;

    class FE_P1,FE_P2,FE_P3,FE_P4,FE_RC,FE_ST frontend;
    class API_U,API_G api;
    class S3 external;
    class DB_S,DB_M,DB_C database;
    class DEP_D1,DEP_D2 deployment;
```
