# codenik07/worksphere architecture

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

- Interactive diagram: https://gitdiagram.com/codenik07/worksphere
- Repository: https://github.com/codenik07/worksphere

## Overview

##### Project type and purpose
- This is a full-stack task/workspace management application.
- Frontend: a React+TypeScript single-page app (Vite, Tailwind) providing UI for auth, workspaces, projects, tasks, members, analytics, etc.
- Backend: a Node.js/TypeScript REST API (Express, Passport for auth) exposing endpoints for users, workspaces, projects, tasks, members.
- Database: a relational DB (configured in backend/src/config/database.config.ts) accessed via models (e.g., Sequelize or TypeORM).

##### File structure
- Top-level separation: /frontend and /backend directories.
- Backend follows an MVC-like pattern:
- config (app, http, DB, passport)
- controllers (auth, user, workspace, project, task, member)
- routes (map controllers to endpoints)
- service layer (business logic)
- models (ORM definitions for user, workspace, project, task, member, roles-permission)
- middleware (auth guard, error handling)
- utils & validation
- seeders for initial data
- Frontend implements:
- src/page (route views)
- src/components (UI building blocks, workspace/project/task dialogs)
- src/hooks (API calls, state logic)
- src/context (auth & query providers)
- src/lib (axios client, API helpers)
- routing layer (protected vs public routes)

##### README
- (Empty in this case; infer from structure and file names.)

##### Detail
- Subsystems (e.g., AuthController, TaskService, RoleGuard middleware).
- API layer, business logic layer, data layer distinctly.
- Do not over-simplify; break backend and frontend into as many meaningful components as needed.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Single-Page App"
        FEApp["App (frontend/src/App.tsx)"]:::frontend
        FEMain["Main (frontend/src/main.tsx)"]:::frontend
        FEPage["Pages/Routes (frontend/src/page & frontend/src/routes)"]:::frontend
        FEComp["UI Components (frontend/src/components)"]:::frontend
        FEHook["Hooks (frontend/src/hooks)"]:::frontend
        FEContext["Context Providers (frontend/src/context)"]:::frontend
        FEClient["API Client & Helpers\n(axios-client.ts, api.ts)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend API Server"
        BEEntry["Entry Point (backend/src/index.ts)"]:::backend
        BEConfig["Configuration\n(app, http, database, passport)"]:::backend
        BERoutes["Routes (backend/src/routes)"]:::backend
        BEController["Controllers (backend/src/controller)"]:::backend
        BEService["Services (backend/src/service)"]:::backend
        BEModel["Models (backend/src/models)"]:::backend
        BEMiddleware["Middleware\n(isAuthenticated, errorHandler, asyncHandler)"]:::backend
        BEValidation["Validation (backend/src/validation)"]:::backend
        BEUtils["Utilities (backend/src/utils)"]:::backend
        BESeeder["Seeders (backend/src/seeders)"]:::backend
    end

    %% Database
    DB[(Relational Database)]:::database

    %% External OAuth
    OAuth((Google OAuth)):::external

    %% Connections
    FEMain -->|"renders"| FEApp
    FEApp -->|"uses Components"| FEComp
    FEApp -->|"uses Hooks"| FEHook
    FEApp -->|"provides Context"| FEContext
    FEApp -->|"calls API"| FEClient
    FEClient -->|"HTTP REST"| BERoutes

    BERoutes -->|"invoke"| BEController
    BEController -->|"business logic"| BEService
    BEService -->|"data access"| BEModel
    BEModel -->|"DB queries"| DB

    BERoutes -->|"middleware"| BEMiddleware
    BEController --> BEValidation
    BEController --> BEUtils
    BEEntry --> BEConfig
    BEEntry --> BERoutes
    BEEntry --> BEMiddleware

    FEApp -->|"OAuth Redirect"| OAuth
    OAuth -->|"callback"| BERoutes

    BESeeder --> BEModel
    BESeeder --> BEUtils

    %% Click Events
    click FEApp "https://github.com/codenik07/worksphere/blob/main/frontend/src/App.tsx"
    click FEMain "https://github.com/codenik07/worksphere/blob/main/frontend/src/main.tsx"
    click FEPage "https://github.com/codenik07/worksphere/tree/main/frontend/src/page"
    click FEPage "https://github.com/codenik07/worksphere/tree/main/frontend/src/routes"
    click FEComp "https://github.com/codenik07/worksphere/tree/main/frontend/src/components"
    click FEHook "https://github.com/codenik07/worksphere/tree/main/frontend/src/hooks"
    click FEContext "https://github.com/codenik07/worksphere/tree/main/frontend/src/context"
    click FEClient "https://github.com/codenik07/worksphere/blob/main/frontend/src/lib/axios-client.ts"
    click FEClient "https://github.com/codenik07/worksphere/blob/main/frontend/src/lib/api.ts"
    click BEEntry "https://github.com/codenik07/worksphere/blob/main/backend/src/index.ts"
    click BEConfig "https://github.com/codenik07/worksphere/blob/main/backend/src/config/app.config.ts"
    click BEConfig "https://github.com/codenik07/worksphere/blob/main/backend/src/config/http.config.ts"
    click BEConfig "https://github.com/codenik07/worksphere/blob/main/backend/src/config/database.config.ts"
    click BEConfig "https://github.com/codenik07/worksphere/blob/main/backend/src/config/passport.config.ts"
    click BERoutes "https://github.com/codenik07/worksphere/blob/main/backend/src/routes/auth.route.ts"
    click BERoutes "https://github.com/codenik07/worksphere/blob/main/backend/src/routes/user.route.ts"
    click BERoutes "https://github.com/codenik07/worksphere/blob/main/backend/src/routes/workspace.route.ts"
    click BERoutes "https://github.com/codenik07/worksphere/blob/main/backend/src/routes/project.route.ts"
    click BERoutes "https://github.com/codenik07/worksphere/blob/main/backend/src/routes/task.route.ts"
    click BERoutes "https://github.com/codenik07/worksphere/blob/main/backend/src/routes/member.route.ts"
    click BEController "https://github.com/codenik07/worksphere/blob/main/backend/src/controller/auth.controller.ts"
    click BEController "https://github.com/codenik07/worksphere/blob/main/backend/src/controller/user.controller.ts"
    click BEController "https://github.com/codenik07/worksphere/blob/main/backend/src/controller/workspace.controller.ts"
    click BEController "https://github.com/codenik07/worksphere/blob/main/backend/src/controller/project.controller.ts"
    click BEController "https://github.com/codenik07/worksphere/blob/main/backend/src/controller/task.controller.ts"
    click BEController "https://github.com/codenik07/worksphere/blob/main/backend/src/controller/member.controller.ts"
    click BEService "https://github.com/codenik07/worksphere/blob/main/backend/src/service/auth.service.ts"
    click BEService "https://github.com/codenik07/worksphere/blob/main/backend/src/service/user.service.ts"
    click BEService "https://github.com/codenik07/worksphere/blob/main/backend/src/service/workspace.service.ts"
    click BEService "https://github.com/codenik07/worksphere/blob/main/backend/src/service/project.service.ts"
    click BEService "https://github.com/codenik07/worksphere/blob/main/backend/src/service/task.service.ts"
    click BEService "https://github.com/codenik07/worksphere/blob/main/backend/src/service/member.service.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/user.model.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/workspace.model.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/project.model.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/task.model.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/member.model.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/account.model.ts"
    click BEModel "https://github.com/codenik07/worksphere/blob/main/backend/src/models/roles-permission.model.ts"
    click BEMiddleware "https://github.com/codenik07/worksphere/blob/main/backend/src/middleware/isAuthenticated.middleware.ts"
    click BEMiddleware "https://github.com/codenik07/worksphere/blob/main/backend/src/middleware/errorHandler.middleware.ts"
    click BEMiddleware "https://github.com/codenik07/worksphere/blob/main/backend/src/middleware/asyncHandler.middleware.ts"
    click BEValidation "https://github.com/codenik07/worksphere/blob/main/backend/src/validation/auth.validation.ts"
    click BEValidation "https://github.com/codenik07/worksphere/blob/main/backend/src/validation/workspace.validation.ts"
    click BEValidation "https://github.com/codenik07/worksphere/blob/main/backend/src/validation/project.validation.ts"
    click BEValidation "https://github.com/codenik07/worksphere/blob/main/backend/src/validation/task.validation.ts"
    click BEUtils "https://github.com/codenik07/worksphere/blob/main/backend/src/utils/appError.ts"
    click BEUtils "https://github.com/codenik07/worksphere/blob/main/backend/src/utils/bcrypt.ts"
    click BEUtils "https://github.com/codenik07/worksphere/blob/main/backend/src/utils/uuid.ts"
    click BEUtils "https://github.com/codenik07/worksphere/blob/main/backend/src/utils/role-permission.ts"
    click BEUtils "https://github.com/codenik07/worksphere/blob/main/backend/src/utils/roleGuard.ts"
    click BEUtils "https://github.com/codenik07/worksphere/blob/main/backend/src/utils/get-env.ts"
    click BESeeder "https://github.com/codenik07/worksphere/blob/main/backend/src/seeders/role.seeder.ts"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef backend fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20
    classDef database fill:#ffe0b2,stroke:#e65100,color:#e65100
    classDef external fill:#eceff1,stroke:#37474f,color:#37474f
```
