{"id":19338587,"url":"https://github.com/surveyjs/surveyjs-nodejs-postgresql","last_synced_at":"2025-04-12T21:03:08.735Z","repository":{"id":239706515,"uuid":"800067742","full_name":"surveyjs/surveyjs-nodejs-postgresql","owner":"surveyjs","description":"This demo illustrates how easy it is to set up a client-server interaction of the SurveyJS client-side form builder component with any backend. By following the steps below you can run a sample React app with an integrated form builder. As a backend, the application uses NodeJS that stores form data in a PostgreSQL database.","archived":false,"fork":false,"pushed_at":"2025-03-10T08:12:14.000Z","size":8868,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T21:02:45.947Z","etag":null,"topics":["form-builder","form-library","node-js","nodejs","postgresql","postgresql-database","survey-creator","survey-software","survey-solutions"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/surveyjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-13T16:32:07.000Z","updated_at":"2025-04-09T04:23:20.000Z","dependencies_parsed_at":"2024-05-17T08:27:43.480Z","dependency_job_id":"6cd5f06f-499b-40b4-b97c-54c76dd62095","html_url":"https://github.com/surveyjs/surveyjs-nodejs-postgresql","commit_stats":null,"previous_names":["surveyjs/surveyjs-nodejs-complex","surveyjs/surveyjs-nodejs-postgresql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surveyjs%2Fsurveyjs-nodejs-postgresql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surveyjs%2Fsurveyjs-nodejs-postgresql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surveyjs%2Fsurveyjs-nodejs-postgresql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surveyjs%2Fsurveyjs-nodejs-postgresql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surveyjs","download_url":"https://codeload.github.com/surveyjs/surveyjs-nodejs-postgresql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631687,"owners_count":21136562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form-builder","form-library","node-js","nodejs","postgresql","postgresql-database","survey-creator","survey-software","survey-solutions"],"created_at":"2024-11-10T03:18:03.137Z","updated_at":"2025-04-12T21:03:08.645Z","avatar_url":"https://github.com/surveyjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SurveyJS + NodeJS + PostgreSQL Demo Example\n\nThis demo shows how to integrate [SurveyJS](https://surveyjs.io/) components with a NodeJS backend using a PostgreSQL database as a storage.\n\n[View Demo Online](https://surveyjs-nodejs.azurewebsites.net/)\n\n## Disclaimer\n\nThis demo must not be used as a real service as it doesn't cover such real-world survey service aspects as authentication, authorization, user management, access levels, and different security issues. These aspects are covered by backend-specific articles, forums, and documentation.\n\n## Run the Application\n\n1. Install [NodeJS](https://nodejs.org/) and [Docker Desktop](https://docs.docker.com/desktop/) on your machine.\n\n2. Run the following commands:\n\n    ```bash\n    git clone https://github.com/surveyjs/surveyjs-nodejs-postgresql.git\n    cd surveyjs-nodejs-postgresql\n    docker compose up -d\n    ```\n\n3. Open http://localhost:9080 in your web browser.\n\n## Client-Side App\n\nThe client-side part is the `surveyjs-react-client` React application. The current project includes only the application's build artifacts in the [public](./public/) directory. Refer to the [`surveyjs-react-client`](https://github.com/surveyjs/surveyjs-react-client) repo for full code and information about the application.\n\n## Integrate SurveyJS with PostgreSQL\n\nSurveyJS communicates with any database using JSON objects that contain either survey schemas or user responses. An SQL database should have two tables to store these objects: `surveys` and `results`. You can use the following SQL script to create them: [`surveyjs.sql`](postgres/initdb/surveyjs.sql). The diagram below shows the structure of these tables:\n\n![SurveyJS: The structure of database tables](https://github.com/surveyjs/surveyjs-nodejs-postgresql/assets/18551316/176a0e1d-963c-4ec0-a11d-33631aa05770)\n\nTo modify data in the `surveys` and `results` tables, you need to implement several JavaScript functions. According to the tasks they perform, these functions can be split into three modules:\n\n- **SQL query builder**        \nJS functions that construct CRUD SQL queries (see the [`sql-crud-adapter.js`](express-app/db-adapters/sql-crud-adapter.js) file).\n\n- **SQL query runner**         \nJS functions that execute queries in an SQL database. The repository you are viewing includes a query runner for PostgreSQL databases (see the [`postgres.js`](express-app/db-adapters/postgres.js) file). You can use it as an example to create a query runner for any other SQL database.\n\n- **Survey storage**        \nJS functions that provide an API for working with survey schemas and user responses (see the [`survey-storage.js`](express-app/db-adapters/survey-storage.js) file). This API is used by the NodeJS application router (see the [`index.js`](express-app/index.js) file).\n\nThese modules interact with each other as shown on the following diagram:\n\n![SurveyJS PostgreSQL Integration](https://github.com/surveyjs/surveyjs-nodejs-postgresql/assets/18551316/2676bb99-d5a1-40fb-b0bb-c780c382e177)\n\nIf you want to integrate SurveyJS with other databases, you can modify or replace the query builder and query runner without changing the survey storage module. This approach is applied to MongoDB integration in the following repository: [`surveyjs-nodejs-mongodb`](https://github.com/surveyjs/surveyjs-nodejs-mongodb).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurveyjs%2Fsurveyjs-nodejs-postgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurveyjs%2Fsurveyjs-nodejs-postgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurveyjs%2Fsurveyjs-nodejs-postgresql/lists"}