# swapnilgupta14/synapse-an-enterprise-workflow-application architecture

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

- Interactive diagram: https://gitdiagram.com/swapnilgupta14/synapse-an-enterprise-workflow-application
- Repository: https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application

## Overview

##### Project type and purpose
- This is a full-stack, single‐page application (SPA) named “Synapse” for enterprise workflow and collaboration.
- Frontend: React + TypeScript + Vite + Tailwind CSS
- Backend: JSON Server (db.json) serving as a mock REST API
- Purpose: allow admins, organizations, and users to manage projects, teams, tasks, view analytics, and handle personal to-dos in a role-based UI.

##### File structure
- Top-level directories/files:
- public, index.html → static assets and entry point
- src → all React code (App.tsx, main.tsx), CSS, types, utils
- server/db.json → mock database for JSON Server
- playwright.config.ts, tests, tests-examples → end-to-end and unit tests
- vite.config.ts, tsconfig*.json, package.json → build & config
- Inside src:
- src/pages & src/components → view layer, dashboards per role
- src/api & src/utils → network layer (axiosInstance, fetch) & helpers (token, localStorage)
- src/redux & src/context → state management (Redux Toolkit slices, React Context for auth/project/team)
- src/routes → React Router route definitions
- src/styles, tailwind.config.js → styling

##### README for additional insights
- Synapse features: project management, team collaboration, task allocation, analytics, responsive design, role-based dashboards
- Highlights tech stack: React, TypeScript, Vite, Tailwind, JSON Server, Axios, Redux Toolkit, Playwright, Jest, React Router, Vercel

a. Main Components
- Client (Browser)
- React SPA
- Routing Layer (React Router)
- UI Component Tree (Pages, Dashboards, Shared UI)
- State Management
– Redux Store
– Context Providers (Auth, Project, Team)
- Network Layer
– Axios Instance
– Service Modules (userServices, projectServices, etc.)
- Mock Backend
– JSON Server (db.json)
- Data Store
– db.json file representing persisting data
- External/Infrastructure
– Vercel (deployment hosting)
– Browser localStorage (for tokens)

b. Relationships & Data Flow
1. Browser → React SPA (load index.html → main.tsx → App)
2. React Router routes requests to specific dashboards/pages
3. UI Components dispatch Redux actions or update Context
4. Redux middleware or service modules call Axios to JSON Server endpoints
5. JSON Server reads/writes db.json, returns JSON responses
6. Responses flow back → network layer → Redux/Context → UI
7. Analytics components read aggregated data from store
8. Authentication uses generateToken & localStorage to persist session

c. Architectural Patterns & Principles
- Component-based UI (atomic UI, dashboards, popups)
- Separation of concerns: UI vs state vs network vs data
- API abstraction: service modules encapsulate REST calls
- Role-based route guarding (ProtectedRoute component)
- State co-existence: Redux for global slices, React Context for scoped contexts
- Mock backend for rapid prototyping/testing (JSON Server)

d. Key Technologies & Frameworks
- React & React Router
- TypeScript & Vite
- Tailwind CSS for styling
- Redux Toolkit & React Context
- Axios for HTTP
- JSON Server as REST API
- Playwright & Jest for testing
- Vercel for deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Browser"]:::external
        Index["index.html"]:::ui
        Main["main.tsx"]:::ui
        App["App.tsx"]:::ui
        ProtectedRoute["ProtectedRoute.tsx"]:::ui
        AdminRoutes["adminRoutes.tsx"]:::ui
        OrgRoutes["organisationRoutes.tsx"]:::ui
        Pages["Pages & Components"]:::ui
    end

    subgraph "UI Component Tree"
        direction TB
        Landing["landingPage.tsx"]:::ui
        AuthPage["auth.tsx"]:::ui
        AuthUI["authUI.tsx"]:::ui
        AdminDash["AdminDashboard/index.tsx"]:::ui
        OrgDash["OrganisationDashboard/index.tsx"]:::ui
        UserDash["UserDashboard/index.tsx"]:::ui
        Shared["Shared Components"]:::ui
    end

    subgraph "Application Layer"
        direction TB
        ReduxStore["store.tsx"]:::state
        AuthSlice["authSlice.tsx"]:::state
        AuthCtx["AuthContext.tsx"]:::state
        ProjectCtx["ProjectContext.tsx"]:::state
        TeamCtx["TeamContext.tsx"]:::state
    end

    subgraph "Network Layer"
        direction TB
        Axios["axiosInstance.ts"]:::network
        Fetch["fetch.ts"]:::network
        Services["Service Modules"]:::network
    end

    subgraph "Persistence Layer"
        direction TB
        JSONServer["JSON Server"]:::data
        DB["db.json"]:::data
    end

    subgraph "Config & Deployment"
        direction TB
        ViteConfig["vite.config.ts"]:::config
        TailwindConfig["tailwind.config.js"]:::config
        Vercel["vercel.json"]:::external
    end

    subgraph "Testing Suites"
        direction TB
        PlaywrightConf["playwright.config.ts"]:::test
        E2E["*.spec.ts"]:::test
        UnitTests["*.test.tsx"]:::test
    end

    %% Connections
    Browser --> Index
    Index --> Main
    Main --> App
    App --> ProtectedRoute
    ProtectedRoute --> AdminRoutes
    ProtectedRoute --> OrgRoutes
    App --> Pages
    Pages --> Landing
    Pages --> AuthPage
    Pages --> AuthUI
    Pages --> AdminDash
    Pages --> OrgDash
    Pages --> UserDash
    Pages --> Shared

    AdminDash -->|"uses"| Shared
    OrgDash --> Shared
    UserDash --> Shared

    Pages --> ReduxStore
    ReduxStore --> AuthSlice
    App --> AuthCtx
    App --> ProjectCtx
    App --> TeamCtx

    AuthSlice --> Axios
    AuthCtx --> Axios
    ProjectCtx --> Axios
    TeamCtx --> Axios
    ReduxStore --> Services
    Services --> Axios
    Axios --> JSONServer
    Fetch --> JSONServer
    JSONServer --> DB
    JSONServer --> Axios

    ViteConfig -.-> App
    TailwindConfig -.-> Shared
    Vercel -.-> Browser

    PlaywrightConf -.-> Browser
    PlaywrightConf -.-> JSONServer
    E2E -.-> Browser
    UnitTests -.-> ReduxStore

    %% Click Events
    click Index "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/index.html"
    click Main "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/main.tsx"
    click App "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/App.tsx"
    click ProtectedRoute "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/ProtectedRoute.tsx"
    click AdminRoutes "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/routes/adminRoutes.tsx"
    click OrgRoutes "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/routes/organisationRoutes.tsx"
    click Landing "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/pages/landingPage.tsx"
    click AuthPage "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/pages/authentication/auth.tsx"
    click AuthUI "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/pages/authentication/authUI.tsx"
    click AdminDash "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/pages/dashboards/AdminDashboard/index.tsx"
    click OrgDash "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/pages/dashboards/OrganisationDashboard/index.tsx"
    click UserDash "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/pages/dashboards/UserDashboard/index.tsx"
    click Shared "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/tree/main/src/components"
    click ReduxStore "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/redux/store.tsx"
    click AuthSlice "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/redux/reducers/authSlice.tsx"
    click AuthCtx "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/context/AuthContext.tsx"
    click ProjectCtx "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/context/ProjectContext.tsx"
    click TeamCtx "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/context/TeamContext.tsx"
    click Axios "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/api/axiosInstance.ts"
    click Fetch "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/src/api/fetch.ts"
    click Services "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/tree/main/src/api/services"
    click DB "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/server/db.json"
    click ViteConfig "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/vite.config.ts"
    click TailwindConfig "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/tailwind.config.js"
    click PlaywrightConf "https://github.com/swapnilgupta14/synapse-an-enterprise-workflow-application/blob/main/playwright.config.ts"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,color:#006064
    classDef state fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
    classDef network fill:#FFF3E0,stroke:#E65100,color:#E65100
    classDef data fill:#ECEFF1,stroke:#37474F,color:#37474F
    classDef external fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
    classDef config fill:#FFFDE7,stroke:#F9A825,color:#F9A825
    classDef test fill:#FBE9E7,stroke:#D84315,color:#D84315
```
