# bilalshabbir31/akw-consultants-assessment architecture

> Architecture diagram of the GitHub repository bilalshabbir31/akw-consultants-assessment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bilalshabbir31/akw-consultants-assessment
- Repository: https://github.com/bilalshabbir31/akw-consultants-assessment

## Overview

##### Main Components
- Frontend (Client):
- Components: A React (Vite-based) application structured under the client directory.
- Key folders: src (contains components like admin, auth, user, common, pages, assets, config, and state management files found in the store directory).
- Purpose: Provide separate views for users (home page, KYC submission) and admins (dashboard, requests review).

- Backend (Server):
- Components: Express.js (or similar Node-based server) application located in the server directory.
- Key folders and files:
▪ config (includes DB configuration for MongoDB and Cloudinary integration)
▪ controllers (divided into admin, auth, and user handling KYC actions)
▪ models (defines data schemas for User and KYC)
▪ routes (defines endpoints organized by user role – admin, auth, and user)
▪ middleware and utilities (auth verification and file uploading logic)
- Purpose: Handle API requests, authentication, KYC processing, and file management.

- Database:
- MongoDB is used with Mongoose ORM for flexibility in managing unstructured data.

- External Services:
- Cloudinary: Used for document storage, integrated via configuration and utility modules.
- Render: Deployment platform for both the client and server applications.

##### Relationships and Interactions
- Data Flow:
- The client interacts with the server using HTTP requests (Axios is configured in the client’s src/config directory).
- On the frontend, user actions (login, registration, submitting KYC requests) send requests to the appropriate API routes on the backend.
- The backend processes these requests using controllers, communicates with the database to store or retrieve data, and uses Cloudinary via utility functions for file uploads.
- Component Interaction:
- The admin panel on the frontend communicates with the server endpoints under routes/admin for request verification.
- The user pages communicate with the endpoints under routes/user to submit and track requests.
- Auth components interact with routes/auth to manage user authentication and registration.

##### Architectural Patterns and Technical Stack
- Use of a clear separation between frontend and backend (full-stack application) with dedicated directories.
- Patterns observed in MVC-like organization on the backend (models, controllers, and routes).
- State management on the client is separated into slices (auth-slice, admin KYC, user KYC) indicating a Redux or similar architecture.
- Clear modular division that supports scalability (e.g., separate admin and user functionalities).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend (React/Vite)"
        FE_Client["Frontend (React/Vite)"]:::frontend
        FE_Admin["Admin Panel"]:::frontend
        FE_User["User Pages"]:::frontend
        FE_Auth["Authentication"]:::frontend
        FE_State["State Management"]:::frontend
        FE_Api["API Configuration (Axios)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Express.js)"
        BE_Server["Backend (Express.js)"]:::backend
        BE_Config["Configuration (DB & Cloudinary)"]:::config
        BE_AuthCtrl["Auth Controller"]:::backend
        BE_AdminCtrl["Admin KYC Controller"]:::backend
        BE_UserCtrl["User KYC Controller"]:::backend
        BE_Models["Models (MongoDB Schemas)"]:::backend
        BE_AdminRoutes["Admin Routes"]:::backend
        BE_UserRoutes["User Routes"]:::backend
        BE_AuthRoutes["Auth Routes"]:::backend
        BE_Middleware["Authentication Middleware"]:::backend
        BE_Util["File Upload Utility"]:::backend
    end

    %% Database and External Services
    DB["MongoDB (Mongoose)"]:::db
    Cloud["Cloudinary"]:::external
    Deploy["Render (Deployment)"]:::external

    %% Frontend Internal Connections
    FE_Client --> FE_Admin
    FE_Client --> FE_User
    FE_Client --> FE_Auth
    FE_Client --> FE_State
    FE_Client --> FE_Api

    %% Client to Server Connections
    FE_Client -->|"HTTPRequests"| BE_Server
    FE_Admin -->|"KYCValidation"| BE_AdminRoutes
    FE_User -->|"KYCSubmission"| BE_UserRoutes
    FE_Auth -->|"AuthCalls"| BE_AuthRoutes
    FE_Api -->|"AxiosConfig"| BE_Server

    %% Backend Internal Connections
    BE_Server --> BE_Config
    BE_Server --> BE_AuthCtrl
    BE_Server --> BE_AdminCtrl
    BE_Server --> BE_UserCtrl
    BE_Server --> BE_Models
    BE_Server --> BE_AdminRoutes
    BE_Server --> BE_UserRoutes
    BE_Server --> BE_AuthRoutes
    BE_Server --> BE_Middleware
    BE_Server --> BE_Util

    %% Backend Controllers and Models
    BE_AdminRoutes -->|"Calls"| BE_AdminCtrl
    BE_UserRoutes -->|"Calls"| BE_UserCtrl
    BE_AuthRoutes -->|"Calls"| BE_AuthCtrl

    BE_AdminCtrl -->|"DataOps"| BE_Models
    BE_UserCtrl -->|"DataOps"| BE_Models
    BE_AuthCtrl -->|"DataOps"| BE_Models

    %% File Upload Flow
    BE_AdminCtrl -->|"UploadsDocs"| BE_Util
    BE_UserCtrl -->|"UploadsDocs"| BE_Util
    BE_Util -->|"Uses"| Cloud

    %% Configuration Flow
    BE_Config -->|"Connects"| DB
    BE_Config -->|"Configures"| Cloud

    %% Deployment Annotation
    Deploy --- FE_Client
    Deploy --- BE_Server

    %% Click Events - Frontend
    click FE_Client "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client"
    click FE_Admin "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/components/admin"
    click FE_Admin "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/pages/admin"
    click FE_User "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/components/user"
    click FE_User "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/pages/user"
    click FE_Auth "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/components/auth"
    click FE_Auth "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/pages/auth"
    click FE_State "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/client/src/store"
    click FE_Api "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/client/src/config/axios.js"

    %% Click Events - Backend
    click BE_Server "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/server"
    click BE_Config "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/server/config"
    click BE_AdminCtrl "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/controllers/admin/kycController.js"
    click BE_UserCtrl "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/controllers/user/kycController.js"
    click BE_AuthCtrl "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/controllers/auth/authController.js"
    click BE_Models "https://github.com/bilalshabbir31/akw-consultants-assessment/tree/master/server/models"
    click BE_AdminRoutes "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/routes/admin/kycRoutes.js"
    click BE_UserRoutes "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/routes/user/kycRoutes.js"
    click BE_AuthRoutes "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/routes/auth/authRoutes.js"
    click BE_Middleware "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/middleware/auth.js"
    click BE_Util "https://github.com/bilalshabbir31/akw-consultants-assessment/blob/master/server/utils/fileUploader.js"

    %% Styles
    classDef frontend fill:#D0EFFF, stroke:#036, stroke-width:2px;
    classDef backend fill:#FFEDCC, stroke:#E67E22, stroke-width:2px;
    classDef db fill:#D5F5E3, stroke:#28B463, stroke-width:2px, shape: cylinder;
    classDef external fill:#FADBD8, stroke:#C0392B, stroke-width:2px;
    classDef config fill:#F0ECEC, stroke:#999, stroke-width:2px;
```
