This guide walks you through setting up the SPS School Backend on your machine for local development or connecting it to a hosted MongoDB Atlas cluster.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.
Prerequisites
Before you begin, make sure the following are installed:| Requirement | Minimum version | Notes |
|---|---|---|
| Node.js | 18.x | LTS recommended |
| npm | 9.x | Bundled with Node.js |
| MongoDB | 6.x (local) or Atlas | See setup options below |
Installation
Install dependencies
- npm
- yarn
package.json, including Express, Mongoose, bcryptjs, jsonwebtoken, and nodemon.Configure environment variables
Copy the example environment file and fill in your values:At minimum, set
PORT, MONGODB_URI, and JWT_SECRET. See the environment variables reference for details on each variable.Set up MongoDB
Choose your database setup:
- Local MongoDB
- MongoDB Atlas
Install MongoDB Community Edition for your operating system.Once MongoDB is running, set your connection string in MongoDB will create the
.env:sps-school database automatically on first write.Verify the server is running
Once the server starts, confirm it is responding correctly by sending a request to the root endpoint:http://localhost:5000/ in your browser and you should see the same message.
The default port is
5000, read from process.env.PORT. If you set a different value in your .env file, use that port instead.Project structure
The following tree shows the top-level layout of the project:| File / folder | Purpose |
|---|---|
server.js | Application entry point. Initializes Express, mounts routes, and starts the HTTP server. |
config/db.js | Establishes the Mongoose connection to MongoDB using MONGODB_URI. |
routes/ | One file per resource. Each file defines the route handlers for that domain area. |
controllers/ | Business logic separated from routing. Called by route handlers. |
middleware/ | Reusable middleware, including JWT authentication checks. |
models/ | Mongoose schema and model definitions. |
.env | Local environment configuration. Never commit this file. |
Available API routes
The following base paths are mounted inserver.js:
| Route prefix | Description |
|---|---|
GET / | Health check — returns "SPS School Backend Running" |
/api/auth | Authentication (register, login) |
/api/teacher | Teacher management |
/api/student | Student management |
/api/attendance | Attendance tracking |
/api/assignment | Assignment management |
/api/application | Applications and admissions |
/api/finance | Finance and fee management |
Next steps
Environment variables
Full reference for all required and optional environment variables.
Authentication
How to authenticate requests using JWT tokens.