# rnagatarun/devsync architecture

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

- Interactive diagram: https://gitdiagram.com/rnagatarun/devsync
- Repository: https://github.com/rnagatarun/devsync

## Overview

##### Project type and purpose
- This is a full-stack web application named DevSync
- Frontend: React + Vite + TypeScript + Tailwind CSS + DaisyUI + react-router-dom + axios
- Backend (“services” folder): Node.js + Express + TypeScript + a database layer (via services/src/database.ts)
- Purpose: allow users to register/login, view and manage profiles and “connection requests”

##### File structure
- Top-level:
– public, index.html, src/ (React app), tailwind.config.js, vite.config.ts, tsconfig*.json
– services/: a standalone Node/Express API with its own package.json, tsconfig, src/
- services/src:
– app.ts (Express app setup)
– database.ts (DB connection logic)
– middlewares/auth.ts (auth guard)
– models/ (ORM/types for User and ConnectionRequest)
– routes/ (auth, profile, request, user endpoints)
– utils/validation.ts (input validation)

##### How to represent this
a. Main components
1. User’s Browser / React SPA
2. HTTP Client Module in React (axios)
3. Express API Server
4. Database (e.g. PostgreSQL/MongoDB)
5. Authentication & Validation (middleware)
b. Relationships & data flow
– Browser ↔ Frontend Router (react-router-dom)
– React Components → axios HTTP calls → API Server endpoints
– Express middleware chain: request → auth/validation → route handler
– Route handler → models → database queries → response
c. Architectural patterns & design principles
– Frontend: Single Page Application, Component-based UI, client-side routing
– Backend: MVC-like separation (routes/controllers vs. models vs. middleware)
– Typed contract between layers via TypeScript interfaces/types
– Shared validation logic in utils, centralized error handling in middleware
d. Key technologies
– Frontend: Vite, React, TypeScript, Tailwind CSS, DaisyUI, react-router-dom, axios
– Backend: Node.js, Express, TypeScript, ts-node, database driver/ORM, middleware for auth
– Build/deploy: npm scripts, tsconfig configurations, environment variables

##### Step-by-step
– Top: Middlewares (auth.ts, validation.ts)
– Middle: Routes/controllers (auth.ts, profile.ts, request.ts, user.ts)
– Bottom: Models (connectionRequest.ts, user.ts) and DB connection (database.ts)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Zone
    subgraph "Frontend" 
        direction TB
        Browser["User's Browser\n(React SPA)"]:::frontend
        MainEntry["Main Entry & App Setup\n(src/main.tsx, src/App.tsx)"]:::frontend
        UIComp["UI Components"]:::frontend
        HTTPClient["HTTP Client Module\n(axios calls)"]:::frontend
        ViteConfig["Vite Build Config"]:::config
        TailwindConfig["Tailwind CSS Config"]:::config
        PublicAssets["Public Assets & HTML Shell"]:::assets
    end

    %% Backend Zone
    subgraph "Backend (Express API)" 
        direction TB
        AppServer["API Server Bootstrap\n(services/src/app.ts)"]:::server
        subgraph "Middlewares"
            direction TB
            AuthMW["Auth Middleware"]:::middleware
            ValidateUtil["Input Validation Utility"]:::middleware
        end
        subgraph "Controllers (Routes)"
            direction TB
            AuthRoute["Auth Route Handler"]:::controller
            ProfileRoute["Profile Route Handler"]:::controller
            RequestRoute["Request Route Handler"]:::controller
            UserRoute["User Route Handler"]:::controller
        end
        subgraph "Models & DB Layer"
            direction TB
            DBConn["Database Connection Layer"]:::server
            UserModel["User Model"]:::models
            ReqModel["ConnectionRequest Model"]:::models
        end
    end

    %% Database
    Database[(Database\nPostgreSQL/MongoDB)]:::db

    %% Connections - Frontend
    Browser -->|uses| MainEntry
    MainEntry -->|renders| UIComp
    UIComp -->|calls| HTTPClient
    HTTPClient -->|REST calls| AppServer

    %% Connections - Backend
    AppServer -->|applies| AuthMW
    AppServer -->|applies| ValidateUtil
    AuthMW -->|to| AuthRoute
    ValidateUtil -->|to| AuthRoute
    AppServer -->|routes to| ProfileRoute
    AppServer -->|routes to| RequestRoute
    AppServer -->|routes to| UserRoute
    AuthRoute -->|uses| DBConn
    ProfileRoute -->|uses| DBConn
    RequestRoute -->|uses| DBConn
    UserRoute -->|uses| DBConn
    DBConn -->|manages| UserModel
    DBConn -->|manages| ReqModel
    DBConn -->|connects to| Database

    %% Config & Assets links
    Browser --> ViteConfig
    Browser --> TailwindConfig
    Browser --> PublicAssets

    %% Click events
    click Browser "https://github.com/rnagatarun/devsync/tree/main/src/"
    click MainEntry "https://github.com/rnagatarun/devsync/blob/main/src/main.tsx"
    click MainEntry "https://github.com/rnagatarun/devsync/blob/main/src/App.tsx"
    click UIComp "https://github.com/rnagatarun/devsync/blob/main/src/components/Body.tsx"
    click UIComp "https://github.com/rnagatarun/devsync/blob/main/src/components/Footer.tsx"
    click UIComp "https://github.com/rnagatarun/devsync/blob/main/src/components/Login.tsx"
    click UIComp "https://github.com/rnagatarun/devsync/blob/main/src/components/Navbar.tsx"
    click HTTPClient "https://github.com/rnagatarun/devsync/blob/main/src/components/Login.tsx"
    click ViteConfig "https://github.com/rnagatarun/devsync/blob/main/vite.config.ts"
    click TailwindConfig "https://github.com/rnagatarun/devsync/blob/main/tailwind.config.js"
    click PublicAssets "https://github.com/rnagatarun/devsync/tree/main/public/"
    click PublicAssets "https://github.com/rnagatarun/devsync/blob/main/index.html"
    click AppServer "https://github.com/rnagatarun/devsync/blob/main/services/src/app.ts"
    click DBConn "https://github.com/rnagatarun/devsync/blob/main/services/src/database.ts"
    click AuthMW "https://github.com/rnagatarun/devsync/blob/main/services/src/middlewares/auth.ts"
    click ValidateUtil "https://github.com/rnagatarun/devsync/blob/main/services/src/utils/validation.ts"
    click UserModel "https://github.com/rnagatarun/devsync/blob/main/services/src/models/user.ts"
    click ReqModel "https://github.com/rnagatarun/devsync/blob/main/services/src/models/connectionRequest.ts"
    click AuthRoute "https://github.com/rnagatarun/devsync/blob/main/services/src/routes/auth.ts"
    click ProfileRoute "https://github.com/rnagatarun/devsync/blob/main/services/src/routes/profile.ts"
    click RequestRoute "https://github.com/rnagatarun/devsync/blob/main/services/src/routes/request.ts"
    click UserRoute "https://github.com/rnagatarun/devsync/blob/main/services/src/routes/user.ts"
    click AppServer "https://github.com/rnagatarun/devsync/blob/main/services/src/types/express.d.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef middleware fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef models fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef controller fill:#98FB98,stroke:#333,stroke-width:1px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef assets fill:#E6E6FA,stroke:#333,stroke-width:1px
```
