1- <h1 align =" center " >FizzBuzz API</h1 >
2-
3- <div align =" center " >
1+ # FizzBuzz API
42
53![ STATUS] ( https://img.shields.io/badge/status-active-brightgreen?style=for-the-badge )
64![ LICENSE] ( https://img.shields.io/badge/license-MIT-blue?style=for-the-badge )
1210## 📝 Table of Contents
1311
1412- [ About] ( #about )
15- - [ Getting Started] ( #getting_started )
13+ - [ Getting Started] ( #getting-started )
1614- [ Usage] ( #usage )
1715- [ Testing] ( #testing )
1816- [ Authors] ( #authors )
1917
20- ## 🔎 About < a name = " about " ></ a >
18+ ## About
2119
22- The whole point of this project is to showcase the concepts of SWE and DevOps that I have learned so far. This project features CI/CD
23- workflows and automations, unittesting, and containerization. Git & Github were used as the VCS, and a Docker Hub image is published
24- for container deployment. I dub this as "FizzBuzz-as-a-Service".
20+ The whole point of this project is to showcase the concepts of SWE and DevOps that I have learned
21+ so far. This project features CI/CD workflows and automations, unittesting, and containerization.
22+ Git & Github were used as the VCS, and a Docker Hub image is published for container deployment.
23+ I dub this as "FizzBuzz-as-a-Service".
2524
26- This program aims to create a FastAPI-based microservice that solves the classic FizzBuzz programming problem. The FizzBuzz problem is a
27- common coding challenge often used in interviews to evaluate a candidate's basic programming skills. The task is to write a program that
28- prints numbers from 1 to n; however, for multiples of 3, it should print "Fizz" instead of the number, for multiples of 5, it should
29- print "Buzz," and for numbers that are multiples of both 3 and 5, it should print "FizzBuzz". The FizzBuzz Microservice API provides a
30- simple HTTP-based API to solve the FizzBuzz problem. It allows users to make requests to the microservice and receive the FizzBuzz
31- sequence as a response. This microservice can be easily integrated into other applications or used for testing and learning purposes.
25+ This program aims to create a FastAPI-based microservice that solves the FizzBuzz algorithm. The
26+ FizzBuzz problem is a common coding challenge often used in interviews to evaluate a candidate's
27+ basic programming skills. The task is to write a program that prints numbers from ` 1 ` to ` n ` ;
28+ however, for multiples of ` 3 ` , it should print ` "Fizz" ` instead of the number, for multiples of
29+ ` 5 ` , it should print ` "Buzz" ` , and for numbers that are multiples of both ` 3 ` and ` 5 ` , it would
30+ print ` "FizzBuzz" ` . The FizzBuzz API provides a simple HTTP API to solve the FizzBuzz problem.
31+ It allows users to make requests to the microservice and receive the resulting FizzBuzz sequence
32+ as a response. This microservice can be easily integrated into other applications or used for
33+ testing and learning purposes.
3234
33- ## 🏁 Getting Started < a name = " getting_started " ></ a >
35+ ## Getting Started
3436
35- These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
37+ These instructions will get you a copy of the project up and running on your local machine for
38+ development and testing purposes.
3639
3740### Prerequisites
3841
39- Before running the FizzBuzz Microservice API, make sure you have the following prerequisites installed:
42+ Before running the FizzBuzz Microservice API, make sure you have the following prerequisites
43+ installed:
4044
4145- [ Python 3.9] ( https://www.python.org/downloads/ ) or above
4246- [ Poetry] ( https://python-poetry.org/ ) dependency manager
4347- [ Just] ( https://github.com/casey/just ) command runner
4448
4549### Installing
4650
47- To get started with this project, clone the repository to your local machine and install the required dependencies.
51+ To get started with this project, clone the repository to your local machine and install the required
52+ dependencies.
4853
4954``` bash
5055git clone https://github.com/jgfranco17/fizzbuzz-api.git
@@ -53,7 +58,7 @@ poetry install
5358poetry shell
5459```
5560
56- ## 🚀 Usage < a name = " usage " ></ a >
61+ ## Usage
5762
5863### Dev mode
5964
@@ -69,7 +74,9 @@ just run-debug
6974
7075### Build with Docker
7176
72- To run the microservice in a container, the package comes with both a Dockerfile and a Compose YAML configuration. Run either of the following to get the API launched in a container; by default, the API will be set to listen on port 5050 for the Compose.
77+ To run the microservice in a container, the package comes with both a Dockerfile and a Compose YAML
78+ configuration. Run either of the following to get the API launched in a container; by default, the
79+ API will be set to listen on port ` 5050 ` for the Compose.
7380
7481``` bash
7582# Plain Docker build
@@ -88,45 +95,48 @@ docker pull jgfranco17/fizzbuzz-api:latest
8895
8996### Calling the API
9097
91- Once the microservice is launched, the API is now reachable. To get a FizzBuzz sequence, simply send a ` GET ` request to the server, with the number as a parameter.
98+ Once the microservice is launched, the API is now reachable. To get a FizzBuzz sequence, simply send
99+ a ` GET ` request to the server, with the number as a parameter.
92100
93101``` bash
94102curl http://localhost:< PORT> /fizzbuzz? number=< number>
95103```
96104
97- ## 🔧 Testing < a name = " testing " ></ a >
105+ ## Testing
98106
99107### Running unittest suite
100108
101- In order to run diagnostics and unittests, first install the testing dependencies. This will allow you to utilize the full capacity of the
102- test modules we have built. To run the full test suite, run the Justfile command as follows:
109+ In order to run diagnostics and unittests, first install the testing dependencies. This will allow
110+ you to utilize the full capacity of the test modules we have built. To run the full test suite,
111+ run the Justfile command as follows:
103112
104113``` bash
105114just pytest
106115```
107116
108117### Using PyTest
109118
110- You can run these tests using the [ PyTest] ( https://docs.pytest.org/en/7.3.x/ ) CLI tool. To run all tests in the directory containing the test
111- files, navigate to the directory and enter ` pytest ` in the command line; for added verbosity, add the ` -vv ` flag after. To run a specific test
112- file, enter ` pytest <filename> ` .
119+ You can run these tests using the [ PyTest] ( https://docs.pytest.org/en/7.3.x/ ) CLI tool. To run all
120+ tests in the directory containing the test files, navigate to the directory and enter ` pytest ` in
121+ the command line. Prepending ` just ` ensures that the Pytest used is the one from the current
122+ dev environment.
113123
114124``` bash
115125# Run all tests in the testing module with verbose detail
116- pytest -vv
126+ just pytest -vv
117127
118128# Or, run a specific test file
119- cd ./tests
120- pytest -v < filename> .py
129+ just pytest -v < filepath>
121130```
122131
123132This will run the specified test module and generates a detailed result report in the terminal.
124133
125134### Running Behave suite
126135
127- Behave is a Python-based BDD framework that allows you to write tests in a natural language style using Gherkin syntax. Gherkin uses a simple,
128- human-readable format that is easy for both technical and non-technical stakeholders to understand. Behave translates these plain-text scenarios
129- into executable code, allowing teams to collaborate on defining and implementing software features.
136+ Behave is a Python-based BDD framework that allows you to write tests in a natural language style
137+ using Gherkin syntax. Gherkin uses a simple, human-readable format that is easy for both technical
138+ and non-technical stakeholders to understand. Behave translates these plain-text scenarios into
139+ executable code, allowing teams to collaborate on defining and implementing software features.
130140
131141To run the full Behave suite, run the Justfile command as follows:
132142
@@ -138,11 +148,12 @@ This will run the specified test module and generates a detailed result report i
138148
139149#### Why BDD?
140150
141- Behavior-Driven Development (BDD) is a software development methodology that focuses on collaboration among developers, QA, and non-technical
142- stakeholders. BDD aims to enhance communication and understanding by using natural language descriptions of software behaviors and features.
143- BDD allows teams to define the expected behavior of the software before implementation; clear specifications help developers focus on
144- delivering features that meet business requirements. Non-technical team members can also easily understand and contribute to the specification
145- process.
151+ Behavior-Driven Development (BDD) is a software development methodology that focuses on collaboration
152+ among developers, QA, and non-technical stakeholders. BDD aims to foster and enhance communication
153+ and understanding by using natural language descriptions of software behaviors and features. BDD
154+ allows teams to define the expected behavior of the software before implementation; clear specifications
155+ help developers focus on delivering features that meet business requirements. Non-technical team members
156+ can also easily understand and contribute to the specification process.
146157
147158For example, below is a demonstration of a simple test case for pinging the ` /healthz ` endpoint.
148159
@@ -153,20 +164,34 @@ Scenario: Access health-check endpoint
153164 Then the response is returned with status code 200
154165```
155166
156- Using Gherkin allows us to run simple test cases without diving too deep into the technicals. As long as the test-writer is
157- familiarized with the basic test steps that can be used, there is no need to use more complex testing frameworks for routine
158- tests. Feel free to write your own Gherkin steps for this project!
167+ Using Gherkin allows us to run simple test cases without diving too deep into the technicals. As long
168+ as the test-writer is familiarized with the basic test steps that can be used, there is no need to use
169+ more complex testing frameworks for routine tests. Feel free to write your own Gherkin steps for this
170+ project!
159171
160172### Load-testing with Locust
161173
162- Load testing is a type of performance testing that evaluates how a system behaves under a specific load. The primary goal is to ensure the
163- system can handle expected user traffic and identify potential bottlenecks or performance issues before they affect end users. During load
164- testing, the system is subjected to increasing numbers of simultaneous users or transactions to determine its capacity, stability, and
174+ Load testing is a type of performance testing that evaluates how a system behaves under a specific load.
175+ The primary goal is to ensure the system can handle expected user traffic and identify potential bottlenecks
176+ or performance issues before they affect end users. During load test execution, the system is subjected to
177+ increasing numbers of simultaneous users or transactions to determine its capacity, stability, and
165178scalability.
166179
167- For this project, we use [ Locust] ( https://locust.io/ ) , an open-source load testing tool that is highly flexible and scalable, making it a
168- popular choice for load testing web applications, APIs, and other services.
180+ For this project, we use [ Locust] ( https://locust.io/ ) , an open-source load testing tool that is highly
181+ flexible and scalable, making it a popular choice for load testing web applications, APIs, and other
182+ services.
183+
184+ ## CI/CD
185+
186+ This project uses Github Actions for DevOps automations. On push to main, the following pipeline is enacted.
187+
188+ - Run build and test
189+ - Codebase linting
190+ - Coverage reporting
191+ - Deployment to [ hosting service] ( https://fizzbuzz-api.onrender.com/ )
192+
193+ Smoke tests and load tests are run periodically on schedule.
169194
170- ## ✒️ Authors < a name = " authors " ></ a >
195+ ## Authors
171196
172197- [ Chino Franco] ( https://github.com/jgfranco17 )
0 commit comments