AMS Backend
AMS Backend
- SAHIL VERMA
- RAGHVENDRA SINGH
Overview
SQLAlchemy:
JWT (JSON Web
Flask: Micro web Object Relational
Tokens): Handling
framework for Mapper (ORM) for
user authentication
creating the API database
and authorization
management
Database models:
Flask-Migrate:
Defining the
Handling database
structure of the
migrations
database
Database Models
Student: Contains student information (e.g., ID, name,
department, batch)
Improved data consistency: Foreign keys help maintain data consistency across multiple
tables in a database. By ensuring that data in one table corresponds to valid data in
another table, foreign keys help prevent data inconsistencies and ensure that data is
reliable.
Improved database performance: Foreign keys can also help improve the performance of
queries that involve multiple tables. By enforcing referential integrity, foreign keys
can help the database optimizer generate more efficient execution plans for queries.
Easier database maintenance: By using foreign keys, you can simplify database
maintenance tasks such as updating or deleting records. When you update or delete a
record in a parent table, the corresponding records in child tables can be automatically
updated or deleted as well, ensuring that the data remains consistent.
Data Migration with Flask-Migrate
01 02 03
Introduction to Flask- Benefits of using Flask- Integration into the
Migrate: A tool for Migrate for data existing application:
handling database migration: Simplifies Adding Flask-Migrate to
schema changes schema updates, the application and
version control, and using it to manage
reduces the risk of data database migrations
loss
• Login endpoint: /login
• User sends their student ID and
password
• Server checks the credentials
JWT Based and generates an access token
• Access token is returned to the
Authentication user
• User includes the access token
in the request headers for
protected endpoints
API Endpoints
Student Information Endpoints
/relevantCourses /otherCourses
Displays courses relevant to the user based Shows all available courses, regardless of the
on their batch and department user's batch and department
Input: Input:
Method: GET Method: GET
Header: Authorization: Bearer Header:
{access_token} Authorization: Bearer {access_token}
Output: Output:
Success (HTTP status 200): Success (HTTP status 200): { "otherCourses": [ {
{ "relevantCoureses": course_info }, ... ] }
[ { course_info }, ... ] }
I-Card and Scholarship Endpoints
Allows users to submit ICard Enables users to submit scholarship Retrieves scholarship information
requests with their sign and image requests with details about ongoing for the user, if available
and applied scholarships, bank
Input: information, and family income Input:
Method: POST information Method: GET
Header: Authorization: Bearer Header: Authorization: Bearer
{access_token} Input: {access_token}
JSON body: { "sign": "signature", Method: GET
"image": "image_data" } Header: Output:
Authorization: Bearer •Success (HTTP status 200):
Output: {access_token} { "scholarship":
•Success (HTTP status 200): JSON body: { scholarship_data } { scholarship_info } }
{ "message": "I-card submitted •Not Found (HTTP status 404):
successfully" } Output: { "message": "No scholarship
•Failure (HTTP status 500): •Success (HTTP status 200): found" }
{ "message": "error_message" } { "message": "Scholarship submitted •Failure (HTTP status 500):
successfully" } { "message": "error_message" }
•Failure (HTTP status 500):
{ "message": "Something went wrong" }
Learning From This Project
Understanding Flask and Authentication and Database interaction and Data migration and Error handling and
RESTful API design: security: models: versioning: debugging:
Learned how to design and Learned how to implement JWT- Learned how to design and use Utilized Flask-Migrate for Improved debugging skills by
implement RESTful APIs with based authentication for secure efficient data models to handling database schema identifying and fixing issues
clear, standardized routes. access to resources. represent real-world entities. changes and versioning. during development.
Conclusion