# Bulki High School API
A simple school management system backend built with Node.js, Express, and PostgreSQL.
## Setup
1. Copy `.env.example` to `.env`.
2. Update `DATABASE_URL` with your Postgres credentials.
3. Run `npm install`.
4. Run `npm run db:setup` to create the database tables.
5. Run `npm run dev` during development or `npm start` for production.
## Database
The PostgreSQL database name is `bulki_high_school_db`.
Use `npm run db:setup` to apply the SQL file in `sql/schema.sql`.
## API
### Health
- `GET /` - API status and resource links
- `GET /health` - health check
### Students
- `GET /students` - list students
- `GET /students/:id` - get one student
- `POST /students` - create a student
- `PATCH /students/:id` - update a student
- `DELETE /students/:id` - delete a student
- `GET /students/:id/classes` - list a student's classes
Example student body:
```json
{
"first_name": "Amanuel",
"last_name": "Bekele",
"email": "amanuel@example.com",
"enrollment_year": 2026
}
```
### Teachers
- `GET /teachers` - list teachers
- `GET /teachers/:id` - get one teacher
- `POST /teachers` - create a teacher
- `PATCH /teachers/:id` - update a teacher
- `DELETE /teachers/:id` - delete a teacher
Example teacher body:
```json
{
"first_name": "Mekdes",
"last_name": "Tadesse",
"email": "mekdes@example.com",
"subject": "Mathematics",
"hired_at": "2026-01-15"
}
```
### Classes
- `GET /classes` - list classes with assigned teacher details
- `GET /classes/:id` - get one class
- `POST /classes` - create a class
- `PATCH /classes/:id` - update a class
- `DELETE /classes/:id` - delete a class
- `GET /classes/:id/students` - list students in a class
Example class body:
```json
{
"name": "Grade 10 Biology",
"grade_level": 10,
"teacher_id": 1,
"schedule": "Mon/Wed/Fri 09:00"
}
```
### Enrollments
- `GET /enrollments` - list enrollments
- `GET /enrollments?student_id=1` - list enrollments for one student
- `GET /enrollments?class_id=1` - list enrollments for one c …