A comprehensive RESTful API for school management system built with modern technologies. This backend service handles circulars, timetables, and homework management for educational institutions.
- Features
- Tech Stack
- Installation
- Environment Setup
- API Documentation
- Database Schema
- Running the Application
- Testing
- Project Structure
- Contributing
- License
- Circular Management: Create, retrieve, and delete school circulars by class
- Timetable Management: Handle class-wise and section-wise timetables
- Homework Management: Manage homework assignments with teacher and student views
- CORS Support: Cross-origin resource sharing enabled
- Data Validation: Comprehensive input validation and error handling
- Type Safety: Full TypeScript implementation
- Database Integration: PostgreSQL with Prisma ORM
- Automatic Timestamps: CreatedAt timestamps for all records
- Case-Insensitive: Flexible class name handling
| Technology | Description | Version |
|---|---|---|
| JavaScript runtime environment | 18.x+ | |
| Fast web application framework | 4.x | |
| Type-safe JavaScript superset | 5.x |
| Technology | Description | Version |
|---|---|---|
| Advanced open source database | 14.x+ | |
| Next-generation ORM toolkit | 5.x |
| Package | Purpose | Badge |
|---|---|---|
| CORS | Cross-origin resource sharing | |
| dotenv | Environment variable management | |
| Axios | HTTP client for API requests |
-
Clone the repository
git clone <repository-url> cd kalinga-backend
-
Install dependencies
npm install
-
Install development dependencies
npm install -D typescript @types/node @types/express ts-node nodemon
-
Create a
.envfile in the root directory:DATABASE_URL="postgresql://username:password@localhost:5432/kalinga_db" PORT=3001
-
Setup PostgreSQL database
- Install PostgreSQL on your system
- Create a new database named
kalinga_db - Update the
DATABASE_URLwith your credentials
-
Run Prisma migrations
npx prisma migrate dev npx prisma generate
http://localhost:3001/api
POST /api/circular
Content-Type: application/json
{
"url": "https://example.com/circular.pdf",
"className": "JUNIOR"
}GET /api/circular/JUNIORResponse:
[
{
"id": 1,
"url": "https://example.com/circular.pdf",
"className": "JUNIOR",
"createdAt": "2024-01-15T10:30:00.000Z"
}
]DELETE /api/circular/1POST /api/timetable
Content-Type: application/json
{
"url": "https://example.com/timetable.pdf",
"className": "Class 5",
"section": "A"
}GET /api/timetable/Class%205/AResponse:
{
"id": 1,
"url": "https://example.com/timetable.pdf",
"className": "Class 5",
"section": "A",
"createdAt": "2024-01-15T10:30:00.000Z"
}DELETE /api/timetable/1POST /api/homework
Content-Type: application/json
{
"className": "JUNIOR",
"section": "A",
"subject": "Mathematics",
"teacher": "John Doe"
}GET /api/homework/teacher/John%20DoeGET /api/homework/student/JUNIOR/AResponse:
[
{
"id": 1,
"className": "JUNIOR",
"section": "A",
"subject": "Mathematics",
"teacher": "John Doe",
"createdAt": "2024-01-15T10:30:00.000Z"
}
]DELETE /api/homework/1All endpoints return appropriate HTTP status codes:
200- Success201- Created400- Bad Request (validation errors)404- Not Found500- Internal Server Error
Error response format:
{
"error": "Error message description"
}CREATE TABLE Circular (
id SERIAL PRIMARY KEY,
url TEXT NOT NULL,
className ClassType NOT NULL,
createdAt TIMESTAMP DEFAULT NOW()
);CREATE TABLE Timetable (
id SERIAL PRIMARY KEY,
url TEXT NOT NULL,
className TEXT NOT NULL,
section TEXT NOT NULL,
createdAt TIMESTAMP DEFAULT NOW()
);CREATE TABLE Homework (
id SERIAL PRIMARY KEY,
className ClassType NOT NULL,
section TEXT NOT NULL,
subject TEXT NOT NULL,
teacher TEXT NOT NULL,
createdAt TIMESTAMP DEFAULT NOW()
);CREATE TYPE ClassType AS ENUM ('JUNIOR', 'PRIMARY', 'SENIOR');npm run devThe server will start on http://localhost:3001 with auto-reload enabled.
npm run build
npm startnpm run dev- Run development server with auto-reloadnpm run build- Build TypeScript to JavaScriptnpm run test- Run test suitenpm start- Start production server
Run the comprehensive test suite:
npm run test- β All API endpoints functionality
- β Data validation and error handling
- β Database operations
- β Edge cases and boundary conditions
- β HTTP status code validation
kalinga-backend/
βββ src/
β βββ routes/
β β βββ circular.ts
β β βββ timetable.ts
β β βββ homework.ts
β βββ types/
β β βββ index.ts
β βββ utils/
β β βββ database.ts
β βββ app.ts
βββ prisma/
β βββ schema.prisma
β βββ migrations/
βββ tests/
β βββ circular.test.ts
β βββ timetable.test.ts
β βββ homework.test.ts
βββ dist/ (generated)
βββ .env
βββ .gitignore
βββ package.json
βββ tsconfig.json
βββ README.md
We welcome contributions to the Kalinga Backend project! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
npm run test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Write comprehensive tests for new features
- Update documentation for API changes
- Use meaningful commit messages
- Ensure code passes all existing tests
- Use TypeScript for all new code
- Follow existing naming conventions
- Add appropriate error handling
- Include JSDoc comments for functions
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please contact:
- Email: support@kalinga-backend.com
- Issues: GitHub Issues
Made with β€οΈ for educational institutions