A full-stack web application for personality testing with user authentication and result storage.
- User authentication (register, login, logout)
- Personality test based on MBTI framework
- Result storage in MySQL database
- User dashboard to view test history
- Responsive design with Tailwind CSS
- Node.js (>= 14.x)
- MySQL Server
- npm or yarn
-
Make sure you are in the Source_Code directory
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with the following variables:# JWT Secret (used for authentication) JWT_SECRET=your_jwt_secret_here # Database Configuration DB_HOST=localhost DB_USER=your_mysql_user DB_PASSWORD=your_mysql_password DB_NAME=mbti_db # Server Configuration PORT=3000
-
Create a MySQL database named
mbti_db
(or whatever you specified in your .env file)
npm run dev
npm run build
npm start
The application uses two main tables:
- id (INT, PRIMARY KEY)
- username (VARCHAR)
- email (VARCHAR)
- password (VARCHAR, hashed)
- created_at (TIMESTAMP)
- id (INT, PRIMARY KEY)
- user_id (INT, FOREIGN KEY to users.id)
- result_type (VARCHAR) - The MBTI personality type (e.g., "INTJ")
- score (JSON) - Detailed scores for each dimension
- created_at (TIMESTAMP)
- POST /api/auth/register - Register a new user
- POST /api/auth/login - Log in a user
- GET /api/auth/profile - Get the current user's profile (protected)
- GET /api/personality/results - Get all test results for the current user (protected)
- POST /api/personality/results - Save a new test result (protected)
- GET /api/personality/results/:id - Get a specific test result (protected)
MIT