# resilient-labs/kinfolx architecture

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

- Interactive diagram: https://gitdiagram.com/resilient-labs/kinfolx
- Repository: https://github.com/resilient-labs/kinfolx

## Overview

##### Project type and purpose
- Kinfolx is a full-stack web application for collecting and displaying user-submitted company reviews (diversity & culture ratings).
- The frontend is a React/Vite single-page app; the backend is a Node/Express API; data is stored in MongoDB; Clerk is used for authentication; Railway/Caddy handle deployment and hosting.

##### File structure
- Top level:
- public/, index.html, assets, static font files → static front-end resources served by Vite/Caddy.
- src/ → React components, pages, layouts, utilities.
- server/ → Express app organized in MVC style:
– config/database.js
– models/{User,Company,Reviews}.js
– controllers/{user,company,reviews}.js
– routes/{user,company,news,reviews}.js
– server.js entrypoint.
- .github/workflows → CI/CD for code formatting and deploy to Railway.
- Caddyfile, nixpacks.toml → web server & build/runtime config.

##### README for technical stack and architecture notes
- Confirms React + Vite on front, Node.js + Express on back, MongoDB, Clerk for auth.
- Front and back run on separate ports (5173 & 3000), use environment variables with VITE_ prefix for client keys.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["User Browser"]:::client
        CaddyServer["Caddy Server"]:::external
        Browser -->|"HTTPS"| CaddyServer
    end

    %% Frontend Layer
    subgraph "Frontend (React/Vite)" 
        direction TB
        ViteConfig["vite.config.js"]:::frontend
        IndexHTML["index.html"]:::frontend
        PublicDir["public/"]:::frontend
        SrcDir["src/"]:::frontend
        SrcMain["main.jsx"]:::frontend
        ComponentsDir["components/"]:::frontend
        LayoutDir["layouts/rootLayout/RootLayout.jsx"]:::frontend
        PagesDir["pages/"]:::frontend

        CaddyServer -->|"serves static assets"| PublicDir
        CaddyServer -->|"serves HTML template"| IndexHTML
        CaddyServer -->|"serves bundle"| ViteConfig

        PublicDir --> SrcDir
        SrcDir --> SrcMain
        SrcDir --> ComponentsDir
        SrcDir --> LayoutDir
        SrcDir --> PagesDir
    end

    %% Application Layer
    subgraph "Backend (Express API)" 
        direction TB
        ServerJS["server/server.js"]:::backend
        ConfigDB["server/config/database.js"]:::backend
        ModelsDir["server/models/"]:::backend
        ControllersDir["server/controllers/"]:::backend
        RoutesDir["server/routes/"]:::backend

        CaddyServer -->|"routes API requests"| ServerJS
        ServerJS --> ConfigDB
        ServerJS --> RoutesDir
        ConfigDB --> ModelsDir
        RoutesDir --> ControllersDir
        ControllersDir --> ModelsDir
    end

    %% Data Layer
    subgraph "Database (MongoDB)"
        direction TB
        MongoDB["MongoDB"]:::database
        ConfigDB -->|connects via ORM/driver| MongoDB
        ModelsDir -->|defines schemas| MongoDB
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Clerk["Clerk Auth Service"]:::external
        CI_CD["CI/CD Pipeline"]:::external
        GitHub["GitHub Repository"]:::external
        PrettierCI[".github/workflows/prettier.yaml"]:::external
        RailwayCI[".github/workflows/railway.yaml"]:::external
        Nixpacks["nixpacks.toml"]:::external

        ServerJS -->|"auth token exchange"| Clerk
        GitHub --> PrettierCI
        GitHub --> RailwayCI
        PrettierCI --> CI_CD
        RailwayCI --> CI_CD
        CI_CD -->|deploys to| RailwayCI
        CI_CD -->|builds using| Nixpacks
        CI_CD -->|deploys containers to| CaddyServer
        CI_CD -->|deploys containers to| ServerJS
    end

    %% Client-API Interaction
    SrcMain -->|"REST API calls"| ServerJS

    %% Click Events
    click SrcMain "https://github.com/resilient-labs/kinfolx/blob/main/src/main.jsx"
    click IndexHTML "https://github.com/resilient-labs/kinfolx/blob/main/index.html"
    click ViteConfig "https://github.com/resilient-labs/kinfolx/blob/main/vite.config.js"
    click PublicDir "https://github.com/resilient-labs/kinfolx/tree/main/public/"
    click ComponentsDir "https://github.com/resilient-labs/kinfolx/tree/main/src/components/"
    click LayoutDir "https://github.com/resilient-labs/kinfolx/blob/main/src/layouts/rootLayout/RootLayout.jsx"
    click PagesDir "https://github.com/resilient-labs/kinfolx/tree/main/src/pages/"
    click ServerJS "https://github.com/resilient-labs/kinfolx/blob/main/server/server.js"
    click ConfigDB "https://github.com/resilient-labs/kinfolx/blob/main/server/config/database.js"
    click ModelsDir "https://github.com/resilient-labs/kinfolx/tree/main/server/models/"
    click ControllersDir "https://github.com/resilient-labs/kinfolx/tree/main/server/controllers/"
    click RoutesDir "https://github.com/resilient-labs/kinfolx/tree/main/server/routes/"
    click PrettierCI "https://github.com/resilient-labs/kinfolx/blob/main/.github/workflows/prettier.yaml"
    click RailwayCI "https://github.com/resilient-labs/kinfolx/blob/main/.github/workflows/railway.yaml"
    click Nixpacks "https://github.com/resilient-labs/kinfolx/blob/main/nixpacks.toml"

    %% Styles
    classDef client fill:#BBDEFB,stroke:#2196F3,color:#000
    classDef frontend fill:#E3F2FD,stroke:#1976D2,color:#000
    classDef backend fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef database fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef external fill:#E1BEE7,stroke:#8E24AA,color:#000
```
