# sushilupadhayay/rkcnl_survey_app architecture

> Architecture diagram of the GitHub repository sushilupadhayay/rkcnl_survey_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushilupadhayay/rkcnl_survey_app
- Repository: https://github.com/sushilupadhayay/rkcnl_survey_app

## Overview

This repository implements a survey-management product: administrators use a web portal to manage surveys, question sets, categories, field staff, assignments, responses, and reports; an Express/Prisma API provides the application services and persists data. The sampled code confirms portal routing and authentication, API route dispatch, survey assignment operations, user administration, and database access. The Flutter platform files are native launch shells only in this tree, so the field-survey client workflow cannot be traced here; the legacy app is likewise not connected by shown evidence.

Main entry points: [`admin-portal/src/routes/index.tsx`](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/routes/index.tsx) (Portal routes), [`backend/src/app.js`](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/app.js) (Express API), [`backend/src/middleware/auth.middleware.js`](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/middleware/auth.middleware.js) (Authentication gate), [`backend/src/config/db.js`](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/config/db.js) (Prisma client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Admin portal"]
  node_app["Portal runtime<br/>[App.tsx]"]
  node_auth["Admin auth<br/>[AuthContext.tsx]"]
  node_login["Login<br/>[LoginPage.tsx]"]
  node_portalroutes["Portal routes<br/>[index.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_categories["Categories"]
  node_surveys["Survey authoring"]
  node_surveyview["Survey detail"]
  node_assignments["Assignments<br/>[AssignmentPage.tsx]"]
  node_users["User administration<br/>[UserListPage.tsx]"]
  node_responses["Responses"]
  node_reports["Reports<br/>[ReportsPage.tsx]"]
  node_profile["Profile<br/>[ProfilePage.tsx]"]
  node_api_client["HTTP client<br/>[client.ts]"]
end

subgraph group_api["API services"]
  node_api_app["Express API<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.routes.js]"]
  node_survey_routes["Survey routes<br/>[survey.routes.js]"]
  node_user_routes["User routes<br/>[user.routes.js]"]
  node_category_routes["Category routes<br/>[category.routes.js]"]
  node_response_routes["Response routes<br/>[response.routes.js]"]
  node_dashboard_routes["Dashboard routes"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_survey_controller["Survey controller"]
  node_user_controller["User controller<br/>[user.controller.js]"]
  node_category_controller["Category controller"]
  node_response_controller["Response controller"]
  node_dashboard_controller["Dashboard controller"]
  node_auth_middleware["Authentication gate<br/>[auth.middleware.js]"]
  node_validation["Request validation"]
end

subgraph group_data["Persistence"]
  node_prisma["Prisma client<br/>[db.js]"]
  node_postgres[("PostgreSQL")]
end

node_admin(("Administrator"))

node_admin -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"loads routes"| node_portalroutes
node_portalroutes -->|"routes to"| node_login
node_portalroutes -->|"routes to"| node_dashboard
node_portalroutes -->|"routes to"| node_categories
node_portalroutes -->|"routes to"| node_surveys
node_portalroutes -->|"routes to"| node_surveyview
node_portalroutes -->|"routes to"| node_assignments
node_portalroutes -->|"routes to"| node_users
node_portalroutes -->|"routes to"| node_responses
node_portalroutes -->|"routes to"| node_reports
node_portalroutes -->|"routes to"| node_profile
node_auth -->|"requests profile"| node_api_client
node_api_app -->|"mounts routes"| node_auth_routes
node_api_app -->|"mounts routes"| node_survey_routes
node_api_app -->|"mounts routes"| node_user_routes
node_api_app -->|"mounts routes"| node_category_routes
node_api_app -->|"mounts routes"| node_response_routes
node_api_app -->|"mounts routes"| node_dashboard_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_survey_routes -->|"dispatches"| node_survey_controller
node_user_routes -->|"dispatches"| node_user_controller
node_category_routes -->|"dispatches"| node_category_controller
node_response_routes -->|"dispatches"| node_response_controller
node_dashboard_routes -->|"dispatches"| node_dashboard_controller
node_auth_routes -->|"protects profile"| node_auth_middleware
node_survey_routes -->|"protects endpoints"| node_auth_middleware
node_survey_routes -->|"validates input"| node_validation
node_category_routes -->|"protects endpoints"| node_auth_middleware
node_category_routes -->|"validates input"| node_validation
node_user_routes -->|"protects endpoints"| node_auth_middleware
node_auth_controller -->|"queries data"| node_prisma
node_survey_controller -->|"reads writes"| node_prisma
node_user_controller -->|"reads writes"| node_prisma
node_auth_middleware -->|"loads user"| node_prisma
node_prisma -.->|"connects"| node_postgres

click node_app "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/App.tsx"
click node_auth "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/auth/AuthContext.tsx"
click node_login "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/auth/LoginPage.tsx"
click node_portalroutes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/routes/index.tsx"
click node_dashboard "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/dashboard/DashboardPage.tsx"
click node_categories "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/categories/CategoryListPage.tsx"
click node_surveys "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/surveys/QuestionBuilderPage.tsx"
click node_surveyview "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/surveys/SurveyDetailPage.tsx"
click node_assignments "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/assignments/AssignmentPage.tsx"
click node_users "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/users/UserListPage.tsx"
click node_responses "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/responses/ResponseListPage.tsx"
click node_reports "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/reports/ReportsPage.tsx"
click node_profile "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/users/ProfilePage.tsx"
click node_api_client "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/api/client.ts"
click node_api_app "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/app.js"
click node_auth_routes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/auth.routes.js"
click node_survey_routes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/survey.routes.js"
click node_user_routes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/user.routes.js"
click node_category_routes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/category.routes.js"
click node_response_routes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/response.routes.js"
click node_dashboard_routes "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/dashboard.routes.js"
click node_auth_controller "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/auth.controller.js"
click node_survey_controller "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/survey.controller.js"
click node_user_controller "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/user.controller.js"
click node_category_controller "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/category.controller.js"
click node_response_controller "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/response.controller.js"
click node_dashboard_controller "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/dashboard.controller.js"
click node_auth_middleware "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/middleware/auth.middleware.js"
click node_validation "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/middleware/validate.middleware.js"
click node_prisma "https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_auth,node_login,node_portalroutes,node_dashboard,node_categories,node_surveys,node_surveyview,node_assignments,node_users,node_responses,node_reports,node_profile,node_api_client toneBlue
class node_api_app,node_auth_routes,node_survey_routes,node_user_routes,node_category_routes,node_response_routes,node_dashboard_routes,node_auth_controller,node_survey_controller,node_user_controller,node_category_controller,node_response_controller,node_dashboard_controller,node_auth_middleware,node_validation toneAmber
class node_prisma,node_postgres toneMint
class node_admin toneIndigo
```

## Components

### Admin portal

- [Portal runtime](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/App.tsx): `admin-portal/src/App.tsx`
- [Admin auth](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/auth/AuthContext.tsx): `admin-portal/src/features/auth/AuthContext.tsx`
- [Login](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/auth/LoginPage.tsx): `admin-portal/src/features/auth/LoginPage.tsx`
- [Portal routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/routes/index.tsx): `admin-portal/src/routes/index.tsx`
- [Dashboard](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/dashboard/DashboardPage.tsx): `admin-portal/src/features/dashboard/DashboardPage.tsx`
- [Categories](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/categories/CategoryListPage.tsx): `admin-portal/src/features/categories/CategoryListPage.tsx`
- [Survey authoring](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/surveys/QuestionBuilderPage.tsx): `admin-portal/src/features/surveys/QuestionBuilderPage.tsx`
- [Survey detail](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/surveys/SurveyDetailPage.tsx): `admin-portal/src/features/surveys/SurveyDetailPage.tsx`
- [Assignments](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/assignments/AssignmentPage.tsx): `admin-portal/src/features/assignments/AssignmentPage.tsx`
- [User administration](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/users/UserListPage.tsx): `admin-portal/src/features/users/UserListPage.tsx`
- [Responses](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/responses/ResponseListPage.tsx): `admin-portal/src/features/responses/ResponseListPage.tsx`
- [Reports](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/reports/ReportsPage.tsx): `admin-portal/src/features/reports/ReportsPage.tsx`
- [Profile](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/features/users/ProfilePage.tsx): `admin-portal/src/features/users/ProfilePage.tsx`
- [HTTP client](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/admin-portal/src/api/client.ts): `admin-portal/src/api/client.ts`

### API services

- [Express API](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/app.js): `backend/src/app.js`
- [Auth routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Survey routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/survey.routes.js): `backend/src/routes/survey.routes.js`
- [User routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/user.routes.js): `backend/src/routes/user.routes.js`
- [Category routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/category.routes.js): `backend/src/routes/category.routes.js`
- [Response routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/response.routes.js): `backend/src/routes/response.routes.js`
- [Dashboard routes](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/routes/dashboard.routes.js): `backend/src/routes/dashboard.routes.js`
- [Auth controller](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Survey controller](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/survey.controller.js): `backend/src/controllers/survey.controller.js`
- [User controller](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/user.controller.js): `backend/src/controllers/user.controller.js`
- [Category controller](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/category.controller.js): `backend/src/controllers/category.controller.js`
- [Response controller](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/response.controller.js): `backend/src/controllers/response.controller.js`
- [Dashboard controller](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/controllers/dashboard.controller.js): `backend/src/controllers/dashboard.controller.js`
- [Authentication gate](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [Request validation](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/middleware/validate.middleware.js): `backend/src/middleware/validate.middleware.js`

### Persistence

- [Prisma client](https://github.com/sushilupadhayay/rkcnl_survey_app/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- **PostgreSQL**

### Other components

- **Administrator**

## Connections

- Administrator → Portal runtime: uses
- Portal runtime → Admin auth: provides auth (evidence: `admin-portal/src/App.tsx`)
- Portal runtime → Portal routes: loads routes (evidence: `admin-portal/src/App.tsx`)
- Portal routes → Login: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Dashboard: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Categories: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Survey authoring: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Survey detail: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Assignments: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → User administration: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Responses: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Reports: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Portal routes → Profile: routes to (evidence: `admin-portal/src/routes/index.tsx`)
- Admin auth → HTTP client: requests profile (evidence: `admin-portal/src/features/auth/AuthContext.tsx`)
- Express API → Auth routes: mounts routes (evidence: `backend/src/app.js`)
- Express API → Survey routes: mounts routes (evidence: `backend/src/app.js`)
- Express API → User routes: mounts routes (evidence: `backend/src/app.js`)
- Express API → Category routes: mounts routes (evidence: `backend/src/app.js`)
- Express API → Response routes: mounts routes (evidence: `backend/src/app.js`)
- Express API → Dashboard routes: mounts routes (evidence: `backend/src/app.js`)
- Auth routes → Auth controller: dispatches (evidence: `backend/src/routes/auth.routes.js`)
- Survey routes → Survey controller: dispatches (evidence: `backend/src/routes/survey.routes.js`)
- User routes → User controller: dispatches (evidence: `backend/src/routes/user.routes.js`)
- Category routes → Category controller: dispatches (evidence: `backend/src/routes/category.routes.js`)
- Response routes → Response controller: dispatches (evidence: `backend/src/routes/response.routes.js`)
- Dashboard routes → Dashboard controller: dispatches (evidence: `backend/src/routes/dashboard.routes.js`)
- Auth routes → Authentication gate: protects profile (evidence: `backend/src/routes/auth.routes.js`)
- Survey routes → Authentication gate: protects endpoints (evidence: `backend/src/routes/survey.routes.js`)
- Survey routes → Request validation: validates input (evidence: `backend/src/routes/survey.routes.js`)
- Category routes → Authentication gate: protects endpoints (evidence: `backend/src/routes/category.routes.js`)
- Category routes → Request validation: validates input (evidence: `backend/src/routes/category.routes.js`)
- User routes → Authentication gate: protects endpoints (evidence: `backend/src/routes/user.routes.js`)
- Auth controller → Prisma client: queries data (evidence: `backend/src/controllers/auth.controller.js`)
- Survey controller → Prisma client: reads writes (evidence: `backend/src/controllers/survey.controller.js`)
- User controller → Prisma client: reads writes (evidence: `backend/src/controllers/user.controller.js`)
- Authentication gate → Prisma client: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- Prisma client → PostgreSQL: connects
