Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/praveenarya123/sps-backend/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you from a fresh clone to a running server with a verified API response.
1

Check prerequisites

You need the following installed before you begin:
  • Node.js v18 or later — nodejs.org
  • MongoDB running locally on the default port (27017), or a MongoDB Atlas connection string
Verify your versions:
node --version
mongod --version
2

Clone the repository

git clone https://github.com/praveenarya123/sps-backend.git
cd sps-backend
3

Install dependencies

npm install
This installs Express, Mongoose, bcryptjs, jsonwebtoken, cors, and dotenv.
4

Configure environment variables

Create a .env file in the project root:
cp .env.example .env
Then open .env and set the following values:
.env
PORT=5000
MONGODB_URI=mongodb://localhost:27017/sps_school
JWT_SECRET=your-strong-secret-key-here
Never commit your .env file. It contains secrets. Ensure .env is listed in your .gitignore.
VariableDescription
PORTPort the Express server listens on
MONGODB_URIMongoDB connection string — local or Atlas
JWT_SECRETSecret key used to sign and verify JWT tokens. Use a long random string in production.
5

Start the server

node server.js
You should see:
Server running on port 5000
Confirm the server is reachable:
curl http://localhost:5000
Expected response:
SPS School Backend Running
6

Register your first user

Make your first authenticated API call by registering a user:
curl -X POST http://localhost:5000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Alice Admin",
    "email": "alice@example.com",
    "password": "securepassword123",
    "role": "SUPER_ADMIN"
  }'
The server responds with the created user object:
{
  "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "name": "Alice Admin",
  "email": "alice@example.com",
  "password": "$2b$10$...",
  "role": "SUPER_ADMIN",
  "__v": 0
}
The password field in the response is the bcrypt hash — never the plaintext value.
7

Log in and get your token

Exchange your credentials for a JWT:
curl -X POST http://localhost:5000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "alice@example.com",
    "password": "securepassword123"
  }'
Response:
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "role": "SUPER_ADMIN"
}
Save the token value. You will pass it in the Authorization header for all protected requests.

What’s next

Authentication

Understand JWT tokens, roles, and how to authenticate every request.

API reference

Explore all available endpoints with request and response schemas.

Build docs developers (and LLMs) love