
- Complete authentication system with JWT and role-based access control
- User management for Admin, Teacher, Student, and Parent roles
- Student management with CRUD operations
- Class management and assignment system
- Subject and grade tracking functionality
- Daily attendance marking and viewing
- Notification system for announcements
- SQLite database with Alembic migrations
- Comprehensive API documentation with Swagger/ReDoc
- Proper project structure with services, models, and schemas
- Environment variable configuration
- CORS support and security features
🤖 Generated with BackendIM
Co-Authored-By: BackendIM <noreply@anthropic.com>
152 lines
5.0 KiB
Markdown
152 lines
5.0 KiB
Markdown
# School Portal API
|
|
|
|
A comprehensive school management system built with Python FastAPI, supporting multiple user roles and complete student lifecycle management.
|
|
|
|
## Features
|
|
|
|
### User Roles
|
|
- **Admin**: Full system access, user management, class management
|
|
- **Teacher**: Student management, grade tracking, attendance marking, notifications
|
|
- **Student**: View grades, attendance, and notifications
|
|
- **Parent**: View child's grades, attendance, and notifications
|
|
|
|
### Core Functionality
|
|
- **Authentication**: JWT-based login and registration for all user roles
|
|
- **Student Management**: Create, update, and delete student profiles
|
|
- **Class Management**: Assign students to classes and teachers to classes
|
|
- **Subject & Grade Tracking**: Teachers record grades per subject, students/parents view them
|
|
- **Attendance**: Daily attendance marking and viewing
|
|
- **Notifications**: Announcements and messages to students and parents
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
schoolportalapi/
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ └── v1/
|
|
│ │ ├── endpoints/
|
|
│ │ │ ├── auth.py # Authentication endpoints
|
|
│ │ │ ├── users.py # User management
|
|
│ │ │ ├── classes.py # Class management
|
|
│ │ │ ├── subjects.py # Subject management
|
|
│ │ │ ├── grades.py # Grade tracking
|
|
│ │ │ ├── attendance.py # Attendance management
|
|
│ │ │ └── notifications.py # Notification system
|
|
│ │ └── api.py # API router
|
|
│ ├── core/
|
|
│ │ ├── config.py # Configuration settings
|
|
│ │ └── security.py # JWT and password utilities
|
|
│ ├── db/
|
|
│ │ ├── base.py # SQLAlchemy base
|
|
│ │ └── session.py # Database session
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ │ ├── user.py
|
|
│ │ ├── class_model.py
|
|
│ │ ├── subject.py
|
|
│ │ ├── grade.py
|
|
│ │ ├── attendance.py
|
|
│ │ └── notification.py
|
|
│ ├── schemas/ # Pydantic schemas
|
|
│ │ ├── user.py
|
|
│ │ ├── class_schema.py
|
|
│ │ ├── subject.py
|
|
│ │ ├── grade.py
|
|
│ │ ├── attendance.py
|
|
│ │ ├── notification.py
|
|
│ │ └── token.py
|
|
│ └── services/ # Business logic layer
|
|
│ ├── base.py
|
|
│ ├── user.py
|
|
│ ├── class_service.py
|
|
│ ├── subject.py
|
|
│ ├── grade.py
|
|
│ ├── attendance.py
|
|
│ └── notification.py
|
|
├── alembic/ # Database migrations
|
|
│ ├── versions/
|
|
│ └── env.py
|
|
├── main.py # FastAPI application entry point
|
|
├── requirements.txt # Python dependencies
|
|
└── alembic.ini # Alembic configuration
|
|
```
|
|
|
|
## Setup Instructions
|
|
|
|
### Prerequisites
|
|
- Python 3.8+
|
|
- pip
|
|
|
|
### Installation
|
|
|
|
1. **Clone the repository**
|
|
```bash
|
|
git clone <repository-url>
|
|
cd schoolportalapi
|
|
```
|
|
|
|
2. **Create virtual environment**
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
```
|
|
|
|
3. **Install dependencies**
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. **Set environment variables**
|
|
Create a `.env` file or set the following environment variables:
|
|
```bash
|
|
# Required Environment Variables
|
|
SECRET_KEY=your-secret-key-change-in-production
|
|
DATABASE_URL=sqlite:////app/storage/db/db.sqlite
|
|
FIRST_SUPERUSER_EMAIL=admin@schoolportal.com
|
|
FIRST_SUPERUSER_PASSWORD=admin123
|
|
```
|
|
|
|
5. **Create storage directory**
|
|
```bash
|
|
mkdir -p /app/storage/db
|
|
```
|
|
|
|
6. **Run database migrations**
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
7. **Start the application**
|
|
```bash
|
|
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, access the interactive API documentation:
|
|
|
|
- **Swagger UI**: http://localhost:8000/docs
|
|
- **ReDoc**: http://localhost:8000/redoc
|
|
- **OpenAPI JSON**: http://localhost:8000/openapi.json
|
|
|
|
## Environment Variables
|
|
|
|
| Variable | Description | Default |
|
|
|----------|-------------|---------|
|
|
| `SECRET_KEY` | JWT secret key | `your-secret-key-change-in-production` |
|
|
| `DATABASE_URL` | Database connection URL | `sqlite:////app/storage/db/db.sqlite` |
|
|
| `FIRST_SUPERUSER_EMAIL` | Initial admin email | `admin@schoolportal.com` |
|
|
| `FIRST_SUPERUSER_PASSWORD` | Initial admin password | `admin123` |
|
|
|
|
## Security Features
|
|
|
|
- JWT-based authentication
|
|
- Password hashing using bcrypt
|
|
- Role-based access control
|
|
- CORS configuration for cross-origin requests
|
|
- Input validation using Pydantic schemas
|
|
|
|
## Health Check
|
|
|
|
The application provides a health check endpoint:
|
|
- `GET /health` - Returns application health status |