Welcome to my blog!

Hello! I’m Mayank. I blog about my learnings here which usually revolve around the realm of machine learning, backend engineering, devops and software architecture.

View on GitHub

http status codes in APIs: 1xx informational 2xx successful 3xx redirection 4xx client error 5xx server error

http requests used by APIs: GET, POST, PUT, DELETE (correspond to CREATE, READ, UPDATE, DELETE of Database operations)

Spring -> dependencies are controlled by objects => tightly coupled dependencies => harder to update/make changes to code -> in IoC, the framework controls the objects(called beans) => done by dependency injection => loosely coupled dependencies

Dependency Injection is a design pattern, and @autowired is a mechanism for implementing it.

Spring Boot = spring framework + prebuilt configuration + embedded servers

Components of spring boot: -> spring boot starters -> auto configuration (automatically configures based on dependency added) -> spring boot actuator (monitoring, metrics gathering, tracing http req) -> embedded server (allows app to run as a executable standalone jar file) (tomcat, jetty etc) -> springboot dev tools

Layered Architecture of Spring Boot: -> presentation layer - presents data and app features. all controller classes exist here controller accepts request from user -> validates the input -> passes it to service layer

-> service layer - business logic resides here. evaluations, decision making, data processing etc. -> data access layer - all repository classes reside which are responsible for DB operations. Responsible for CRUD operations.

JPA(Java Persistence API) -> allows classes to be directly translated into database tables -> DB queries can be done using entities or objects instead of writing raw SQL -> easy integration with spring boot -> In JPA repository is an interface to perform various operations involving the DB without writing boilerplate code.

H2 database -> fast, opensource, jdbc api -> embedded mode - runs in the same jvm as the application code -> server mode - running on its own as a server. accepts connections from clients over the server. has seperate process of its own.

Springboot Actuator -> built in endpoints -> ability to view real time metrics, application health, sessions etc. -> customizable(create your own endpoints, modify existing ones, control security aspect(who i want to access the actuator))

Docker Architecture(https://docs.docker.com/get-started/overview/) Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface. Another Docker client is Docker Compose, that lets you work with applications consisting of a set of containers. -> Docker Engine - includes Docker CLI, Docker API and Docker Daemon -> Docker CLI - The CLI uses Docker APIs to control or interact with the Docker daemon through scripting or direct CLI commands. -> Docker API - -> Docker Daemon - The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services. ->Docker Images: template to create container. multiple containers can be made from same docker image. ->Docker Containers: running instance of docker image -> Docker Registry - stores Docker images -> Dockerfile - contains instructions to build a docker image -> DockerHub - cloud based registry that hosts a vast collection of docker images

Docker Commands

docker pull mayankch283/jobappimage docker run -it -d -p 8080:8080 mayankch283/jobappimage (-it interactive, -d detached/terminal free, -p port mapping) ps (lists all docker containers running as service) docker stop docker start

note: Docker containers cannot communicate without docker networks. (docker exec -it pgadmin ping db)

Start the PostgreSQL service: docker run -d / –name postgres_container -e POSTGRES_USER=mayank -e POSTGRES_PASSWORD=mayank -e PGDATA=/data/postgres -v postgres:/data/postgres (mounts docker volume named postgres to this particular path; to persist the postgres data) -p 5432:5432 –network postgres –restart unless-stopped postgres

Start the pgAdmin service: docker run -d / –name pgadmin_container -e PGADMIN_DEFAULT_EMAIL=mayankch283@gmail.com -e PGADMIN_DEFAULT_PASSWORD=admin -e PGADMIN_CONFIG_SERVER_MODE=False -v pgadmin:/var/lib/pgadmin -p 5050:80 –network postgres / –restart unless-stopped / dpage/pgadmin4

Docker Compose: Tool for defining and running multi container applications. Provices streamlined and efficient development and deployment experience