# jeon-man/free-survey-client architecture

> Architecture diagram of the GitHub repository jeon-man/free-survey-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeon-man/free-survey-client
- Repository: https://github.com/jeon-man/free-survey-client

## Overview

##### Project Type and Purpose
- This is a frontend-focused Next.js application that leverages the app directory for routing and page layout. It primarily provides a survey feature set, allowing users to view, create, and edit surveys. The use of both dynamic routes (e.g., [surveyId]) and dedicated survey as well as UI components indicates modular design specifically tailored to survey functionality.

##### File Structure
- Top-Level Files: Key configurations and dependency management are done via files like package.json, tsconfig.json, next.config.ts, and various configuration files for eslint and postcss.
- src/app: Contains the main entry points – global styles (globals.css), layout (layout.tsx), and the primary page (page.tsx). It also has a survey-specific subdirectory that includes dynamic routing for viewing and editing surveys.
- src/components: Organized into common, survey-specific, and UI-specific components. This separation highlights a strategy that isolates shared UI functions (like buttons, cards, alerts) from domain-specific UI elements related to surveys.
- src/hooks: Custom hooks are used for business logic related to surveys, e.g., creating and fetching surveys.
- src/services: Encapsulates API calls or business logic operations related to surveys, separating them from UI concerns.
- src/lib: This folder holds API utilities, environment configuration along with state management helpers built on Zustand, which indicates that some parts of the application use a centralized store for state management.
- Providers: Global providers such as query-provider and theme-provider ensure that query caching and theming are available throughout the app.
- Types: Contains TypeScript definitions for questions and surveys to maintain type safety across the project.

##### Specific Elements
- Next.js Application Shell (including Global Layout, Pages)
- Survey Module (differentiated by dynamic routes and dedicated survey pages)
- UI Components (with subdivisions for common, survey-specific, and reusable UI elements)
- Custom Hooks & Services for Survey Management
- Global Providers (Query Provider, Theme Provider)
- Utility/Lib Layer (API helpers, environment variables, Zustand stores)
- How pages utilize components.
- How components interact with hooks.
- The flow from hooks to services and API utilities.
- The wrapping of the entire application with the providers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    B["Global Providers"]:::providers
    A["Next.js Application Shell"]:::appShell
    C["Survey Module (Pages & Routes)"]:::module
    D["UI Components (Reusable)"]:::ui
    J["Common UI Components"]:::ui
    E["Survey-specific Components"]:::ui
    F["Custom Hooks for Survey Management"]:::hooks
    G["Survey Services"]:::services
    H["API/Utility Layer & State Management"]:::api
    I["Type Definitions"]:::types

    %% Relationships
    B -->|"wraps"| A
    A -->|"routes"| C
    C -->|"renders"| D
    C -->|"renders"| E
    C -->|"renders"| J
    D -->|"triggers"| F
    E -->|"triggers"| F
    J -->|"triggers"| F
    F -->|"calls"| G
    G -->|"invokes"| H
    H -->|"utilizes"| I

    %% Click Events
    click A "https://github.com/jeon-man/free-survey-client/tree/main/src/app"
    click C "https://github.com/jeon-man/free-survey-client/tree/main/src/app/survey"
    click D "https://github.com/jeon-man/free-survey-client/tree/main/src/components/ui"
    click J "https://github.com/jeon-man/free-survey-client/tree/main/src/components/common"
    click E "https://github.com/jeon-man/free-survey-client/tree/main/src/components/survey"
    click F "https://github.com/jeon-man/free-survey-client/tree/main/src/hooks/survey"
    click G "https://github.com/jeon-man/free-survey-client/tree/main/src/services/survey"
    click B "https://github.com/jeon-man/free-survey-client/tree/main/src/providers"
    click H "https://github.com/jeon-man/free-survey-client/tree/main/src/lib"
    click I "https://github.com/jeon-man/free-survey-client/tree/main/src/types"

    %% Styles
    classDef providers fill:#e2f0cb,stroke:#333,stroke-width:2px;
    classDef appShell fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef module fill:#ffefdb,stroke:#333,stroke-width:2px;
    classDef ui fill:#fde4cd,stroke:#333,stroke-width:2px;
    classDef hooks fill:#ffe6e6,stroke:#333,stroke-width:2px;
    classDef services fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef api fill:#e6e6ff,stroke:#333,stroke-width:2px;
    classDef types fill:#d9f2d9,stroke:#333,stroke-width:2px;
```
