<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Fastapi - Category - JMS Blog</title><link>/categories/fastapi/</link><description>Fastapi - Category - JMS Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Tue, 07 Jul 2026 07:53:52 -0600</lastBuildDate><atom:link href="/categories/fastapi/" rel="self" type="application/rss+xml"/><item><title>Hexagonal Architecture (Python)</title><link>/posts/hexagonal-arc-python/</link><pubDate>Tue, 07 Jul 2026 07:53:52 -0600</pubDate><author>jms</author><guid>/posts/hexagonal-arc-python/</guid><description><![CDATA[<figure><a class="lightgallery" href="/img/posts/uploads/2026/07/hex-arc.jpg" title="/img/posts/uploads/2026/07/hex-arc.jpg" data-thumbnail="/img/posts/uploads/2026/07/hex-arc.jpg" data-sub-html="<h2>Hexagonal Architecture (image)</h2>">
        
    </a><figcaption class="image-caption">Hexagonal Architecture (<code>image</code>)</figcaption>
    </figure>
<p>Hexagonal Architecture (also known as Ports and Adapters) is one of the best patterns for keeping your core business logic pure, testable, and completely decoupled from external noise like databases, APIs, or UI frameworks.</p>
<p>To get started, I will explain these core concepts and how they are applied using FastAPI, PostgreSQL, and Pytest.</p>
<h2 id="the-core-philosophy">The core philosophy</h2>
<p>The main idea is simple: Your business logic does not care what database or web framework you use. Instead of building your application in traditional database-centric layers, you put your Domain (Business Logic) at the absolute center. Anything outside that core (FastAPI, PostgreSQL, Celery, External APIs) is considered an &ldquo;external detail.&rdquo;</p>]]></description></item><item><title>Timezone lookup using latitude and longitud (part 2)</title><link>/posts/2020-08-12-timezone-finder-2/</link><pubDate>Wed, 12 Aug 2020 00:00:00 +0000</pubDate><author>jms</author><guid>/posts/2020-08-12-timezone-finder-2/</guid><description><![CDATA[<p>For the fastapi project we are going to use Sqlalchemy and postgresql
taking some reference from the fastapi documentation.</p>
<div class="code-block code-line-numbers open" style="counter-reset: code-block 0">
    <div class="code-header language-bash">
        <span class="code-title"><i class="arrow fas fa-angle-right" aria-hidden="true"></i></span>
        <span class="ellipses"><i class="fas fa-ellipsis-h" aria-hidden="true"></i></span>
        <span class="copy" title="Copy to clipboard"><i class="far fa-copy" aria-hidden="true"></i></span>
    </div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># create a virtualenv, with any tool: poetry, pipenv, virtualenv module, etc </span>
</span></span><span class="line"><span class="cl">pip install fastapi uvicorn aiofiles SQLAlchemy psycopg2-binary</span></span></code></pre></div></div>
<p>project structure</p>
<div class="code-block code-line-numbers" style="counter-reset: code-block 0">
    <div class="code-header language-bash">
        <span class="code-title"><i class="arrow fas fa-angle-right" aria-hidden="true"></i></span>
        <span class="ellipses"><i class="fas fa-ellipsis-h" aria-hidden="true"></i></span>
        <span class="copy" title="Copy to clipboard"><i class="far fa-copy" aria-hidden="true"></i></span>
    </div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">.
</span></span><span class="line"><span class="cl">├── Dockerfile
</span></span><span class="line"><span class="cl">├── LICENSE
</span></span><span class="line"><span class="cl">├── main.py
</span></span><span class="line"><span class="cl">├── README.md
</span></span><span class="line"><span class="cl">├── requirements.txt
</span></span><span class="line"><span class="cl">└── timezone_utils
</span></span><span class="line"><span class="cl">    ├── database.py
</span></span><span class="line"><span class="cl">    ├── __init__.py
</span></span><span class="line"><span class="cl">    ├── models.py
</span></span><span class="line"><span class="cl">    ├── schemas.py
</span></span><span class="line"><span class="cl">    └── utils.py
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="m">1</span> directory, <span class="m">10</span> files</span></span></code></pre></div></div>
<p>we define the models, schemas and engine for sqlalchemy and the api in the package <code>timezone_utils</code></p>]]></description></item><item><title>Timezone lookup using latitude and longitude (part 1)</title><link>/posts/2020-08-11-timezone-finder-1/</link><pubDate>Tue, 11 Aug 2020 00:00:00 +0000</pubDate><author>jms</author><guid>/posts/2020-08-11-timezone-finder-1/</guid><description><![CDATA[<p>First timezones are evil, but sometimes you need to work with them. Sometimes is easy to consume some third party api to get timezone information based on a given location using geocoding but there also exists some alternatives.</p>
<p>Then inspired on this <a href="https://github.com/evansiroky/timezone-boundary-builder" target="_blank" rel="noopener noreffer ">blog post</a> and the project <a href="https://github.com/evansiroky/timezone-boundary-builder" target="_blank" rel="noopener noreffer ">Timezone boundary builder</a> decided to create a test project using fastapi and postgis to do the timezone lookup using the latitude and longitude.</p>]]></description></item></channel></rss>