This project is a Next.js application with a Prisma/Postgres backend designed to facilitate the management and completion of needs assessment surveys.
Gitpod provides a fully automated development environment for your Next.js project, and the development environment is set up with just a single click. Follow these steps to get started:
- Click the
Open in Gitpod
button above. Note: you'll need to have an account on Gitpod before proceeding with the next steps (this requires a GitHub account). - Click the
Continue
button. - Relax, a development environment is being set up for you in the first terminal.
- To access your workspace later, go to Gitpod Workspaces. Pin the
needs-assessment-v2
workspace to prevent auto-deletion after 14 days by clicking the three dots next to the workspace name and selecting "Pin".
- Frontend: Next.js (React, TypeScript, TailwindCSS)
- Backend: Prisma ORM with PostgreSQL
- Containerization: Docker (Postgres in Docker)
- Authentication: NextAuth.js
git clone https://github.com/your-repo/needs-assessment.git
cd needs-assessment
Make sure you have Node.js installed. Then install project dependencies:
npm install
Create a .env
file based on .env.example
:
cp .env.example .env
Ensure the following environment variables are correctly set in .env
:
DATABASE_URL="postgresql://postgres:password@localhost:5432/needs_assessment"
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key
This project uses Docker to manage the PostgreSQL database. Make sure Docker is installed and running.
Start the PostgreSQL container:
docker-compose up -d
Apply Prisma migrations and seed the database with initial data:
npx prisma migrate dev --name init
npx prisma db seed
To reset the database and reseed:
npx prisma migrate reset
Use Prisma Studio to visually inspect and manage the database:
npx prisma studio
Run the Next.js development server:
npm run dev
Visit http://localhost:3000 to view the app.
needs-assessment/
βββ prisma/ # Prisma schema and migrations
βββ src/
β βββ app/ # Next.js app directory with routes
β βββ components/ # Reusable React components
β βββ types/ # TypeScript types and models
βββ docker-compose.yml # Docker configuration (Postgres)
βββ .env.example # Example environment configuration
βββ package.json # Project metadata and scripts
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature-name
). - Open a pull request.
-
Implement critical features:
- Incorporate a real authentication system (waiting on updates)
- Update survey to reflect the actual questions we want
- Store all responses in a queryable way (e.g. Baserow?)
- Get initial survey questions from Strapi (waiting on strapi deploy)
-
Enhance Form Components:
- Create reusable components for different question types (
Numeric
,Dropdown
,MultiSelect
, etc.). - Add validation and user-friendly error messages for required fields.
- Create reusable components for different question types (
-
UI/UX Enhancements:
- Improve the Sidebar with better progress indicators or navigation.
- Add animations/transitions using Framer Motion for smoother interactions.
- Implement responsive design improvements using TailwindCSS.
-
Survey Summary Page:
- Build a summary page that displays a user's completed responses before final submission.
-
Loading and Error States:
- Add loading spinners or skeleton components while data is being fetched.
- Improve error handling with user-friendly messages and retry options.
-
Add Role-Based Access Control (RBAC):
- Implement roles (Admin, Contributor, Viewer) with different permissions for surveys and responses.
-
Optimize Database Queries:
- Review and optimize Prisma queries to reduce response times.
- Add indexes to frequently queried fields (e.g.,
siteId
,surveyId
).
-
Audit Logging:
- Track changes to surveys and responses in an audit log for accountability.
-
Add Unit and Integration Tests:
- Write tests for API routes using Jest or React Testing Library.
- Add tests for form validation and submission.
-
End-to-End Testing:
- Set up Cypress for end-to-end testing of the survey flow.
-
Docker Optimization:
- Optimize Dockerfile for faster builds and smaller image sizes.
- Set up separate Docker configurations for development and production.
-
Expand Documentation:
- Add detailed API documentation for backend routes.
- Create a guide for setting up the project without Docker for contributors who prefer a local setup.
-
Survey Versioning:
- Implement a system to track different versions of surveys over time.
-
Data Visualization Dashboard:
- Build a dashboard to visualize survey responses using Chart.js or Recharts.
-
Import/Export Surveys:
- Add functionality to import/export surveys and responses as CSV or JSON.
-
Docker Issues:
- If Docker volumes are stuck, try restarting Docker or force removing volumes:
docker volume prune -f
- If Docker volumes are stuck, try restarting Docker or force removing volumes:
-
Database Errors:
- If migrations fail, try resetting the database:
npx prisma migrate reset
- If migrations fail, try resetting the database:
-
Port Conflicts:
- Make sure ports
3000
(Next.js) and5432
(Postgres) are not in use by other applications.
- Make sure ports
This project is licensed under the MIT License.