PsycheIT is intentionally minimal in its infrastructure footprint — two Node.js processes, no database, and a single-file backend — so that any college can self-host the platform without cloud vendor dependencies or operational complexity. Understanding the architecture helps you extend the classifier, add new routes, or replace the flat-file storage with a proper database when you are ready to scale.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Nandini-13/PsycheIT/llms.txt
Use this file to discover all available pages before exploring further.
High-Level Overview
PsycheIT runs as two independent processes that communicate over HTTP:| Process | Technology | Default Port |
|---|---|---|
| Frontend | Vite dev server (development) / static build (production) | 5173 |
| Backend | Express 5 on Node.js | 5000 |
fetch calls. CORS is enabled globally on the backend (cors() middleware), so both processes can run on different origins during development. In production you would typically serve the Vite build as static files from the same Express server or a CDN, and remove the open CORS policy.
Frontend Structure
The frontend is a React 19 single-page application bundled by Vite 7, styled with Tailwind CSS 4, and navigated with React Router v7.Routes
All routes are declared insrc/App.jsx. Two routes are public; every other route is wrapped in a ProtectedRoute component that checks for a valid JWT in localStorage before rendering.
| Path | Component | Access |
|---|---|---|
/ | HomePage | Public |
/auth | Auth | Public |
/dashboard | StudentDashboard | Protected |
/chatbot | Chatbot | Protected |
/resources | Resources | Protected |
/blogs/:id | BlogPage | Protected |
/forum | PeerForum | Protected |
/book | BookingPage | Protected |
/screening | ScreeningTest | Protected |
Authentication Guard
ProtectedRoute is a wrapper component that reads the token key from localStorage. If no token is present, the user is redirected to /auth. On successful login the backend returns a JWT which the frontend stores in localStorage under the key token.
StudentDashboard component decodes the JWT payload client-side (base64 decode of the middle segment) to extract and display the userId — no additional API call is required.
Backend Structure
The entire backend lives in a single file:server/server.js. It uses Express 5 with the body-parser and cors middleware, and exposes exactly three API endpoints.
Endpoints
| Method | Path | Auth Required | Purpose |
|---|---|---|---|
POST | /signup | No | Generate a userId and random password |
POST | /login | No | Verify credentials; issue JWT |
POST | /classify | No | Run NLP intent classification on a message |
The
/classify endpoint is currently unauthenticated, which is intentional for the chatbot’s first-contact use case. If you deploy publicly, consider adding rate-limiting middleware (e.g., express-rate-limit) to prevent abuse.NLP Classifier
The chatbot’s intelligence comes fromnatural.BayesClassifier, a Naive Bayes text classifier from the natural.js library. The classifier is instantiated, trained with labelled documents, and kept in memory for the lifetime of the server process.
Training
Training happens once at server startup — synchronously, before any request is served. Approximately 20 labelled example documents are added per intent class:Recognised Intents
The classifier recognises ten intent labels:| Intent | Example trigger phrase |
|---|---|
greeting | ”hi”, “hello”, “good morning” |
academic | ”I am stressed about exams” |
family | ”My parents keep fighting” |
social | ”I feel lonely and left out” |
sleep | ”I can’t sleep at night” |
anxiety | ”I feel anxious and panic” |
highrisk | ”I want to die”, “I don’t want to live” |
depression | ”I feel sad all the time” |
general | ”I feel okay”, “I’m doing good” |
counselor | ”I need a counselor”, “I want therapy” |
Classification Response
The/classify endpoint returns the top intent and the full sorted classification scores:
.slice(0, 3)). The frontend chatbot uses the intent field to decide which canned response or follow-up action to show the student.
Authentication Flow
PsycheIT uses a deliberate two-step auth model to preserve anonymity — students never provide a username or email.Step 1 — Sign Up
POST /signup accepts a collegeCode string and returns a generated userId and a random 8-character alphanumeric password. Nothing is persisted at this stage.
Step 2 — Log In
POST /login accepts { userId, password }. On first login the password is hashed with bcryptjs (salt rounds: 10) and the record { userId, hashedPassword } is written to users.json. On subsequent logins, bcrypt.compareSync is used to verify the plaintext password against the stored hash.
If verification passes, a JWT is signed and returned:
{ userId, iat, exp }. The frontend stores it in localStorage and decodes the payload locally to display the user’s ID on the dashboard.
The JWT signing key is hardcoded as
"secretKey" in the current source. Replace this with a strong, randomly generated secret stored in an environment variable (e.g., process.env.JWT_SECRET) before any public deployment. A leaked signing key allows anyone to forge valid tokens.Data Storage
PsycheIT uses flat JSON files on disk instead of a database, keeping the setup to a singlenpm install. The backend manages one file for user credentials; the frontend bundles two additional JSON files for content.
| File | Location | Contents | Created By |
|---|---|---|---|
users.json | server/ | Array of { userId, password } objects (password is bcrypt hash) | Auto-created on first /login call |
PeerForum.json | frontend/src/PeerForum/ | Array of forum post objects | Pre-seeded in the frontend bundle; read at runtime by the React app |
resources.json | frontend/src/resourceHub/ | Array of resource/article objects | Pre-seeded in the frontend bundle; read-only at runtime |
Flat-file storage is suitable for a single-server development or pilot deployment. For a production environment serving multiple concurrent users, replace the
loadUsers / saveUsers helpers in server.js with calls to a database (PostgreSQL, MongoDB, or similar) to avoid race conditions during concurrent writes.