# rohitd3v/devdesk architecture

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

- Interactive diagram: https://gitdiagram.com/rohitd3v/devdesk
- Repository: https://github.com/rohitd3v/devdesk

## Overview

##### Project Type and Purpose
- DevDesk is a full-stack ticketing and DevOps automation tool aimed at small to mid-sized developer teams.
- The file tree reveals two main directories: “frontend” (a Next.js 13 app in TypeScript) and “backend” (an Express-style Node.js API, also in TypeScript), plus integration with Supabase for data storage and auth.

##### High-Level Architecture Components
a. Frontend (Next.js)
- Pages & layout (app/page.tsx, app/layout.tsx)
- UI components (Sidebar, TicketCard, Forms)
- Feature modules under src/app/features (auth, projects, tickets, comments, profiles)
- API client wrapper (apiClient.ts) that communicates with the backend via REST
b. Backend (Express-style API)
- Entry point: server.ts
- Routing layer: routers for auth, profiles, projects, tickets, ticketComments, ticketActivity
- Controllers: business logic handling for each resource
- Services: reusable logic (e.g., ticketService)
- Middleware: auth checks, validation, error handling
- Supabase client: config/supabaseClient.ts for DB and auth interactions
c. Database & External Services
- Supabase (Postgres database + built-in Auth)
- Potential future integrations (e.g., email/webhooks) via additional services or controllers

##### Key Architectural Patterns
- Layered MVC-style architecture on the backend: Routes → Controllers → Services → Database
- Feature-driven modularization on the frontend: each feature folder contains its components, hooks, services
- Centralized API client on the frontend for all HTTP calls
- Zod validation in backend for request payloads
- Async handler wrapper for uniform error handling

a. Main Components
- Browser/Client (React–Next.js)
- Next.js app (UI render, routing)
- API Client (apiClient.ts)
- Backend API (Express server)
- Supabase (Auth & Postgres)
b. Relationships & Data Flows
1. User interacts with Next.js UI →
2. Next.js calls apiClient → issues HTTPS requests to Backend API endpoints (e.g., /api/projects) →
3. Backend middleware authenticates via Supabase Auth →
4. Controllers call Services → Supabase Client executes SQL queries or auth operations →
5. Responses flow back up: Supabase → Service → Controller → HTTP Response → apiClient → Next.js → UI
c. Important Design Principles
- Separation of concerns: UI vs business logic vs data layer
- Modular, feature-based structure in frontend to ease scaling and maintenance
- Centralized error handling and validation in backend
- Use of typed interfaces (TypeScript types + Zod schemas) for end-to-end type safety
d. Technologies & Frameworks
- Frontend: Next.js 13, React, TypeScript, PostCSS
- Backend: Node.js, Express-style routing, TypeScript, Zod, Supabase client
- Database/Auth: Supabase (PostgreSQL + JWT auth)

##### Detail
- Every layer: UI, hooks, services, middleware, controllers, data access.
- Validation (Zod) and error handling as cross-cutting middleware.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Next.js)" 
        direction TB
        Page["Page Entry Point"]:::frontend
        Layout["Global Layout"]:::frontend
        subgraph "UI Components"
            direction TB
            Sidebar["Sidebar Component"]:::frontend
            TicketCard["TicketCard Component"]:::frontend
            NewTicketForm["NewTicketForm Component"]:::frontend
            LoginForm["LoginForm Component"]:::frontend
            SignupForm["SignupForm Component"]:::frontend
        end
        subgraph "Feature Modules"
            direction TB
            subgraph "Auth Feature"
                direction TB
                useLogin["useLogin Hook"]:::frontend
                useSignup["useSignup Hook"]:::frontend
                authService["AuthService"]:::frontend
            end
            subgraph "Projects Feature"
                direction TB
                projectService["ProjectService"]:::frontend
            end
            subgraph "Tickets Feature"
                direction TB
                ticketServiceFE["TicketService"]:::frontend
            end
            subgraph "Comments Feature"
                direction TB
                commentServiceFE["CommentService"]:::frontend
            end
            subgraph "Profiles Feature"
                direction TB
                profileServiceFE["ProfileService"]:::frontend
            end
        end
        APIClient["API Client"]:::apiClient
    end

    %% Backend Layer
    subgraph "Backend (Node/Express API)"
        direction TB
        Server["Server Entry (server.ts)"]:::backend
        subgraph "Middleware"
            direction TB
            AuthMiddleware["AuthMiddleware"]:::backend
            ValidateReq["validateRequest"]:::backend
            ValidateTicket["validateTicket"]:::backend
            ErrorHandler["errorHandler"]:::backend
        end
        subgraph "Routing Layer"
            direction TB
            AuthRouter["authRouter"]:::backend
            ProfileRouter["profileRouter"]:::backend
            ProjectsRouter["projectsRouter"]:::backend
            TicketsRouter["ticketsRouter"]:::backend
            TicketCommentsRouter["ticketCommentsRouter"]:::backend
            TicketActivityRouter["ticketActivityRouter"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthController["AuthController"]:::backend
            ProfileController["ProfileController"]:::backend
            ProjectController["ProjectController"]:::backend
            TicketController["TicketController"]:::backend
            TicketCommentController["TicketCommentController"]:::backend
            TicketActivityController["TicketActivityController"]:::backend
        end
        subgraph "Services"
            direction TB
            TicketServiceBE["TicketService"]:::backend
        end
        subgraph "Utilities & Validation"
            direction TB
            AsyncHandler["asyncHandler"]:::backend
            SendResponse["sendResponse"]:::backend
            ZodValidation["zodValidation"]:::backend
        end
        SupabaseClient["Supabase Client"]:::backend
    end

    %% External Services
    subgraph "Supabase" 
        direction TB
        SupabaseAuth["Auth Service"]:::external
        SupabaseDB["Postgres Database"]:::external
    end

    %% Data Flow
    Page --> Layout
    Layout --> Sidebar
    Layout --> TicketCard
    Layout --> NewTicketForm
    Layout --> LoginForm
    Layout --> SignupForm
    Sidebar --> APIClient
    TicketCard --> APIClient
    NewTicketForm --> APIClient
    LoginForm --> APIClient
    SignupForm --> APIClient
    useLogin --> APIClient
    useSignup --> APIClient
    authService --> APIClient
    projectService --> APIClient
    ticketServiceFE --> APIClient
    commentServiceFE --> APIClient
    profileServiceFE --> APIClient
    APIClient --> Server
    Server --> AuthMiddleware
    AuthMiddleware --> ValidateReq
    ValidateReq --> ValidateTicket
    ValidateTicket --> ErrorHandler
    ErrorHandler --> AuthRouter
    AuthRouter --> AuthController
    ProfileRouter --> ProfileController
    ProjectsRouter --> ProjectController
    TicketsRouter --> TicketController
    TicketCommentsRouter --> TicketCommentController
    TicketActivityRouter --> TicketActivityController
    AuthController --> TicketServiceBE
    ProfileController --> TicketServiceBE
    ProjectController --> TicketServiceBE
    TicketController --> TicketServiceBE
    TicketCommentController --> TicketServiceBE
    TicketActivityController --> TicketServiceBE
    TicketServiceBE --> SupabaseClient
    AsyncHandler --> SupabaseClient
    SendResponse --> SupabaseClient
    ZodValidation --> SupabaseClient
    SupabaseClient --> SupabaseAuth
    SupabaseClient --> SupabaseDB

    %% Click Events
    click Page "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/page.tsx"
    click Layout "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/layout.tsx"
    click Sidebar "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/components/Sidebar.tsx"
    click TicketCard "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/tickets/components/TicketCard.tsx"
    click NewTicketForm "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/tickets/components/NewTicketForm.tsx"
    click LoginForm "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/auth/components/LoginForm.tsx"
    click SignupForm "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/auth/components/SignupForm.tsx"
    click useLogin "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/auth/hooks/useLogin.ts"
    click useSignup "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/auth/hooks/useSignup.ts"
    click authService "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/auth/services/authService.ts"
    click projectService "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/projects/services/projectService.ts"
    click ticketServiceFE "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/tickets/services/ticketService.ts"
    click commentServiceFE "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/comments/services/commentService.ts"
    click profileServiceFE "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/features/profiles/services/profileService.ts"
    click APIClient "https://github.com/rohitd3v/devdesk/blob/main/frontend/src/app/services/apiClient.ts"
    click Server "https://github.com/rohitd3v/devdesk/blob/main/backend/src/server.ts"
    click SupabaseClient "https://github.com/rohitd3v/devdesk/blob/main/backend/src/config/supabaseClient.ts"
    click AuthRouter "https://github.com/rohitd3v/devdesk/blob/main/backend/src/routes/authRouter.ts"
    click ProfileRouter "https://github.com/rohitd3v/devdesk/blob/main/backend/src/routes/profileRouter.ts"
    click ProjectsRouter "https://github.com/rohitd3v/devdesk/blob/main/backend/src/routes/projectsRouter.ts"
    click TicketsRouter "https://github.com/rohitd3v/devdesk/blob/main/backend/src/routes/ticketsRouter.ts"
    click TicketCommentsRouter "https://github.com/rohitd3v/devdesk/blob/main/backend/src/routes/ticketCommentsRouter.ts"
    click TicketActivityRouter "https://github.com/rohitd3v/devdesk/blob/main/backend/src/routes/ticketActivityRouter.ts"
    click AuthController "https://github.com/rohitd3v/devdesk/blob/main/backend/src/controllers/authController.ts"
    click ProfileController "https://github.com/rohitd3v/devdesk/blob/main/backend/src/controllers/profileController.ts"
    click ProjectController "https://github.com/rohitd3v/devdesk/blob/main/backend/src/controllers/projectController.ts"
    click TicketController "https://github.com/rohitd3v/devdesk/blob/main/backend/src/controllers/ticketController.ts"
    click TicketCommentController "https://github.com/rohitd3v/devdesk/blob/main/backend/src/controllers/ticketCommentController.ts"
    click TicketActivityController "https://github.com/rohitd3v/devdesk/blob/main/backend/src/controllers/ticketActivityController.ts"
    click TicketServiceBE "https://github.com/rohitd3v/devdesk/blob/main/backend/src/services/ticketService.ts"
    click AuthMiddleware "https://github.com/rohitd3v/devdesk/blob/main/backend/src/middleware/Authmiddleware.ts"
    click ValidateReq "https://github.com/rohitd3v/devdesk/blob/main/backend/src/middleware/validateRequest.ts"
    click ValidateTicket "https://github.com/rohitd3v/devdesk/blob/main/backend/src/middleware/validateTicket.ts"
    click ErrorHandler "https://github.com/rohitd3v/devdesk/blob/main/backend/src/middleware/errorHandler.ts"
    click AsyncHandler "https://github.com/rohitd3v/devdesk/blob/main/backend/src/utils/asyncHandler.ts"
    click SendResponse "https://github.com/rohitd3v/devdesk/blob/main/backend/src/utils/sendResponse.ts"
    click ZodValidation "https://github.com/rohitd3v/devdesk/blob/main/backend/src/validators/zodValidation.ts"

    %% Styles
    classDef frontend fill:#bdecb6,stroke:#2e8b57,color:#000
    classDef backend fill:#add8e6,stroke:#1e90ff,color:#000
    classDef external fill:#ffdab9,stroke:#ff8c00,color:#000
    classDef apiClient fill:#dda0dd,stroke:#9400d3,color:#000,shape:parallelogram
```
