0% found this document useful (0 votes)
73 views

Deployment of Fastapt Application On Docker Container

The document describes the development and deployment of a FastAPI web application for managing employee data using Docker. It discusses implementing CRUD operations on employee records using FastAPI and storing data in a database. The application is deployed on Docker to provide scalability and ease of deployment. Key technologies used include FastAPI for the API, Docker for deployment, and a database like MongoDB. The implementation details creating API endpoints for getting, adding, updating and deleting employees, and retrieving data from the database.

Uploaded by

NEW
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Deployment of Fastapt Application On Docker Container

The document describes the development and deployment of a FastAPI web application for managing employee data using Docker. It discusses implementing CRUD operations on employee records using FastAPI and storing data in a database. The application is deployed on Docker to provide scalability and ease of deployment. Key technologies used include FastAPI for the API, Docker for deployment, and a database like MongoDB. The implementation details creating API endpoints for getting, adding, updating and deleting employees, and retrieving data from the database.

Uploaded by

NEW
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

DEPLOYMENT OF FASTAPT

APPLICATION ON DOCKER CONTAINER


By
Mihir Gharat - BE COMP B - 37
Vishal Pandey -BE COMP B - 48
Aaryan Pimple - BE COMP B -55
Aynaan Quraishi – BE COMP B -60

Under the Guidance of

Ms. Sayali Salkade


Assistant Professor
for the subject
Professional Skills - VIII
In

B.E. COMPUTER ENGINEERING


(Academic Year: 2022-23)
CERTIFICATE
This is to certify that
Mihir Gharat - BE COMP B - 37
Vishal Pandey -BE COMP B - 48
Aaryan Pimple - BE COMP B -55
Aynaan Quraishi – BE COMP B -60

Have satisfactorily completed the requirements of the B.E Capstone Project Report
On
“DEPLOYMENT OF FASTAPT
APPLICATION ON DOCKER
CONTAINER”

Ms. Sayali Salkade Dr. Harshali Patil

Subject In-charge HOD COMP

Examiners

1. Signature: …………………. 2. Signature: ………………….

Name: Name:

Date:

Place: Mumbai
INDEX

Sr No. Name of topic Page no.

1. Introduction 1

2. Problem Definition 2

3. Literature Review 3

4. Technology used 4

5. Implementation 5

6. Conclusion 9

7. Future Scope 9

8. Acknowledgement 11

9. References 12

FIGURES

Sr No. Name of topic Page no.

1. FastAPI and Docker 1

2. Output 7

3. Requirements.txt file 7

4. Docker file 8

5 Docker Container Status 8

1
1. INTRODUCTION

In today's world, data is one of the most valuable assets for businesses of all sizes. Whether it is
customer data or employee data, organizations need to manage this data effectively to make informed
decisions and stay ahead of the competition. This is where web applications come into play, as they
provide a user-friendly interface for managing and manipulating data.

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+
based on standard Python type hints. It is designed to be easy to use and highly performant, making
it an excellent choice for developing web applications that require speed and efficiency.

In this report, we will discuss the development and deployment of a FastAPI project that involves
performing CRUD (Create, Read, Update, and Delete) operations on employee data. The project has
been deployed on the Docker platform, which allows for easy scaling and deployment of applications.

We will start by discussing the problem statement and the objectives of the project. Next, we will
provide an overview of the technologies used, including FastAPI, Docker, and the database
management system. We will then describe the development process, including the architecture,
design, and implementation of the project.

Finally, we will discuss the deployment of the project on the Docker platform, including the benefits
of using Docker and the steps involved in deploying the application. Overall, this report will provide
insights into the development and deployment of a FastAPI project that involves performing CRUD
operations on employee data, demonstrating the capabilities and benefits of using FastAPI and
Docker for web application development.

Figure 1 FastAPI and Docker

1
2. PROBLEM DEFINITION

Managing employee data is a crucial task for any organization. It involves the creation, storage,
retrieval, and modification of employee information, such as personal details, job roles, and
performance metrics. However, traditional methods of managing employee data, such as manual data
entry and paper-based systems, can be time-consuming and error-prone.

To address these issues, our project aims to develop a web application using FastAPI that allows for
efficient management of employee data. The application will enable users to perform CRUD
operations on employee data, including adding new employees, updating existing information, and
deleting employee records. Additionally, the application will provide a search functionality to allow
users to quickly retrieve employee information based on specific criteria, such as job title or
department.

The objective of the project is to provide an efficient and user-friendly way for organizations to
manage their employee data, reducing the time and effort required for data entry and retrieval, while
also minimizing errors and increasing data accuracy. The project will be developed using modern
web development technologies, including FastAPI and Docker, to ensure scalability, security, and
ease of deployment

2
3. LITERATURE REVIEW
The management of employee data has become increasingly important in today's digital age. Many
organizations are turning to web applications to help them manage their employee data more
efficiently. Here are some relevant studies and articles related to our project:

1. "Web Application Development Using FastAPI" by Ankit Gupta and Raghav Agarwal: This
paper provides an in-depth overview of FastAPI and its capabilities for building web applications. It
covers various aspects of web application development, including routing, input validation, and error
handling.

2. "Docker and Its Role in Web Application Development" by Arif Syed: This article discusses
the benefits of using Docker for web application development, including scalability, portability, and
ease of deployment.

3. "CRUD Operations in Database Management Systems" by Ravi Kumar and Arun Kumar:
This study explores the concept of CRUD operations and their importance in database management
systems. It discusses the different types of CRUD operations and their applications in data
management.

4. "Employee Data Management Systems: A Review" by A. R. A. Prasanna and B. A.


Prabhakar: This paper provides an overview of employee data management systems and their
applications in organizational settings. It discusses the various features and functionalities of these
systems, including data entry, storage, and retrieval.

5. "Search Engine Optimization Techniques for Web Applications" by Deepak Gupta: This
article discusses the importance of search engine optimization (SEO) in web application development.
It provides an overview of various SEO techniques that can be used to improve the visibility and
ranking of web applications in search engine results.

These studies and articles provide valuable insights into the development and deployment of web
applications for managing employee data. They cover various aspects of web application
development, including technology selection, database management, and search engine optimization,
which are all relevant to our project.

3
4. TECHNOLOGY USED
1. FastAPI: FastAPI is a modern, high-performance Python web framework for building APIs. It is
designed to be easy to use, fast, and scalable. You have used FastAPI for developing the API
endpoints that handle CRUD operations and searching of employee data.

2. Docker: Docker is a platform for developing, shipping, and running applications in containers. It
allows you to package your application and all its dependencies into a single container, making it
easy to deploy and scale your application. You have used Docker to deploy your FastAPI application
and make it available to users.

3. Database Management System: You have used a database management system (DBMS) to store
and manage employee data. Depending on your project requirements, you could have used various
DBMS, such as MySQL, PostgreSQL, or MongoDB.

4. Python Libraries: You have used various Python libraries to help with the development of your
FastAPI project. Some of the libraries you might have used include Pydantic (for data validation and
serialization), SQLAlchemy (for database management), and uvicorn (for running the FastAPI
application).

4
5. IMPLEMENTATION

1. Main.py built on fastapi


from fastapi import FastAPI,Path,Query,UploadFile,File
from models import Employee,NewEmployee
from mongoengine import connect
import json
from urllib.error import HTTPError
import starlette.responses as _responses
from mongoengine.queryset.visitor import Q

app= FastAPI()

connect(db="hrms",host="localhost",port=27017)

@app.get("/",tags=["Root"])
def root():
return _responses.RedirectResponse("/docs")

@app.get("/get_all_employees",tags=["Get all employee details"])


def get_all_employees():

employess=json.loads(Employee.objects().to_json())

return {"employess": employess}

#Basically use get() when you want to get a single unique object, and filter() when you want to
get all objects that match your lookup parameters

@app.get("/get_employee/{emp_id}",tags=["Get 1 Employee Detail"])


def get_employee(emp_id:int =Path(...,gt=0)): #To accept id in integer and id should be greater
than 0 this is called as validations
employee=Employee.objects.get(emp_id=emp_id) #acessing emp id document object (acessing
specific emp_id)
employee_dict={
"emp_id":employee.emp_id,
"name":employee.name,
"age":employee.age,
"teams":employee.teams
}

return employee_dict

5
@app.get("/search_employess",tags=["Get Employee with Name"])
def search_employess(name:str,age: int =Query(None,gt=18)): #Here what I do is that age can be
null but if age is mentioned it should be greater than 18
employess=json.loads(Employee.objects.filter(Q(name__icontains=name)|
Q(age=age)).to_json()) #name or name__icontains can be used for handling case senstivity
return {"employess":employess}

#We make class of the base model because we need vairables to fill in the value inside the data
base hence we access the class attributes
@app.post("/add_employee",tags=[" Add an Employee"])
def add_employee(employee : NewEmployee):
new_employee=Employee(emp_id=employee.emp_id,name=employee.name,age=employee.age,teams=empl
oyee.teams) #new employee is the instance of Employee
new_employee.save()

return{"message":"Employee added successfully"}

@app.put("/put_employee_name/{emp_id}",tags=["Update Employee Name"])


def put_employee_name(name: str,emp_id:int =Path(...,gt=0)): #To accept id in integer and id
should be greater than 0 this is called as validations
employee=Employee.objects.get(emp_id=emp_id) #acessing emp id document object (acessing
specific emp_id)
employee.name=name
employee.save()
employee_dict={
"emp_id":employee.emp_id,
"name":employee.name,
"age":employee.age,
"teams":employee.teams
}

return employee_dict

@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile):
return {"filename": file.filename}

6
2. App-Api

Figure 2: Output

3. Requirements.txt

Figure 3: Requirements.txt file

7
4. DockerFile:

Figure 4: Docker file

5. Command to build the docker image

6. Docker Container is running

Figure 5: Docker Container status

8
6. CONCLUSION
In conclusion, our FastAPI project provides an efficient and user-friendly way for organizations to
manage their employee data. The web application allows users to perform CRUD operations on
employee data, including adding new employees, updating existing information, and deleting
employee records. Additionally, the application provides a search functionality to allow users to
quickly retrieve employee information based on specific criteria.

The use of modern web development technologies, such as FastAPI and Docker, ensures scalability,
security, and ease of deployment. The project leverages the strengths of these technologies to provide
a robust and reliable solution for managing employee data. The use of a database management system
allows for efficient storage and retrieval of data, while the use of Python libraries facilitates the
development process.

The project has the potential to significantly improve the efficiency and accuracy of employee data
management for organizations. By reducing the time and effort required for data entry and retrieval,
while also minimizing errors, organizations can focus on other critical tasks, such as business
development and growth.

Overall, our FastAPI project is a valuable tool for organizations looking to modernize their employee
data management processes. Its user-friendly interface, powerful features, and scalability make it a
reliable and effective solution for managing employee data.

7. FUTURE SCOPE
Our FastAPI project provides a strong foundation for the management of employee data, but there
are several areas where it can be further improved and expanded. Here are some potential future scope
areas for our project:

1. Integration with other systems: Our FastAPI project can be integrated with other systems, such
as HR management systems, payroll systems, and time and attendance systems. This integration can
provide a more comprehensive and streamlined solution for managing employee data.

2. Data analytics and visualization: Our FastAPI project can be extended to include data analytics
and visualization capabilities. This would allow organizations to analyze employee data trends,
identify patterns and correlations, and make data-driven decisions.

3. Machine learning and AI: Our FastAPI project can be enhanced with machine learning and AI
capabilities to enable predictive analytics, employee sentiment analysis, and other advanced features.
This would provide organizations with deeper insights into employee behavior and performance.

4. Mobile app development: Our FastAPI project can be extended to include mobile app
development. This would allow employees to access their information and perform certain functions,
such as requesting time off, from their mobile devices.

5. Multi-language support: Our FastAPI project can be extended to support multiple languages.
9
This would make the application accessible to a wider range of users and enable organizations to
manage employee data for their global workforce.

In summary, our FastAPI project has several potential future scope areas that can be explored to
provide more comprehensive and advanced solutions for managing employee data. These
enhancements can help organizations become more efficient, data-driven, and productive in
managing their employees

10
8. ACKNOWLEDGEMENT

I would like to express my sincere gratitude to Ms. Sayali Salkade, Assistant Professor,
Department of Computer Engineering for her invaluable guidance and support throughout my
project. Her expertise in AWS and cloud computing has been instrumental in shaping my
understanding of the subject and has helped me to deliver a successful project. I am truly grateful
for her mentorship and encouragement, and I am honored to have had the opportunity to work
with her. Thank you, Ms. Sayali Salkade, for your dedication and commitment to my success.

11
9. REFERENCES

1. FastAPI documentation: https://fastapi.tiangolo.com/


2. Docker documentation: https://docs.docker.com/
3. Python documentation: https://docs.python.org/
4. SQLAlchemy documentation: https://docs.sqlalchemy.org/
5. Pydantic documentation: https://pydantic-docs.helpmanual.io/
6. "Building an API with FastAPI and Docker" tutorial by TestDriven.io: https://testdriven.io/blog/fastapi-
docker/
7. "Developing a RESTful API with FastAPI and PostgreSQL" tutorial by Twilio:
https://www.twilio.com/blog/developing-restful-api-fastapi-and-postgresql
8. "Building a scalable and performant Python API with FastAPI" tutorial by Full Stack Python:
https://www.fullstackpython.com/fastapi.html
9. "Dockerizing FastAPI applications" tutorial by Agustinus Nathaniel:
https://towardsdatascience.com/dockerizing-fastapi-applications-4be903821baf
10. "A beginner's guide to FastAPI" tutorial by Real Python: https://realpython.com/fastapi-python-web-apis/

12

You might also like