https://github.com/varshamohan08/student-management
This project is a RESTful API for managing student and teacher data, user authentication, and CRUD operations using Flask and PostgreSQL.
https://github.com/varshamohan08/student-management
Last synced: 3 months ago
JSON representation
This project is a RESTful API for managing student and teacher data, user authentication, and CRUD operations using Flask and PostgreSQL.
- Host: GitHub
- URL: https://github.com/varshamohan08/student-management
- Owner: varshamohan08
- Created: 2024-11-09T17:09:44.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-09T21:59:26.000Z (6 months ago)
- Last Synced: 2025-01-11T21:25:21.365Z (4 months ago)
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
##### student-management
# Student Management System APIThis project is a RESTful API for managing student and teacher data, user authentication, and CRUD operations using Flask and PostgreSQL. The system allows user registration, login, and tracks sign-in activity in the `logs` table.
## Features
- User authentication with JWT (JSON Web Tokens)
- User registration (Student and Teacher)
- Login functionality (Student and Teacher)
- CRUD operations for students (Create, Read, Update, Delete)
- Assigning teachers to students
- Log tracking for user sign-ins## Technologies
- **Flask**: Python web framework for building the API
- **PostgreSQL**: Database for storing user and student data
- **JWT**: For authentication and token management
- **Bcrypt**: For password hashing and verification
- **Psycopg2**: PostgreSQL database adapter for Python## Installation
1. Clone the repository:
```
git clone https://github.com/varshamohan08/student-management.git
```
2. Navigate to the project folder:
```
cd student-management
```
3. Create and activate a virtual environment:
```
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
4. Install dependencies:
```
pip install -r requirements.txt
```
5. Configure your PostgreSQL database:
Set the following environment variables or modify the Config.py file to reflect your PostgreSQL database credentials:
```
DB_NAME = "student_management"
DB_USER = "your_db_user"
DB_PASSWORD = "your_db_password"
DB_HOST = "localhost"
DB_PORT = 5432
```
6. Create the required database tables using SQL script: [database.sql](https://github.com/varshamohan08/student-management/blob/main/database.sql).## Endpoints
### Authentication Routes
#### 1. Register User
- Endpoint: `auth/register/`
- Method: POST
- Body:
```
{
"name": "John Doe",
"email": "[email protected]",
"password": "password123"
}
```
- User Types: student, teacher
#### 2. Login User
- Endpoint: `auth/login/`
- Method: POST
- Body:
```
{
"email": "[email protected]",
"password": "password123"
}
```
### Student Routes
#### 3. View Students
- Endpoint: `students/`
- Method: GET
- Authorization: Bearer token required
#### 4. Add Student
- Endpoint: `students/add`
- Method: POST
- Body:
```
{
"name": "Jane Doe",
"email": "[email protected]",
"password": "password123"
}
```
- Authorization: Bearer token required
#### 5. Update Student
- Endpoint: `students/update/`
- Method: PUT
- Body:
```
{
"name": "Updated Name"
}
```
- Authorization: Bearer token required
#### 6. Delete Student
- Endpoint: `students/delete/`
- Method: DELETE
- Authorization: Bearer token required
#### 7. Assign Teacher to Student
- Endpoint: `students//teachers`
- Method: POST
- Body:
```
{
"teacher_id": 1
}
```
- Authorization: Bearer token required
### JWT Authentication
Use the Authorization header with the Bearer token in the request to authenticate protected routes:
```
Authorization: Bearer
```
### Logging
Every sign-in event is logged in the logs table with the following details: user ID, user type, name, and sign-in time.