<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Flask REST API - Redis, Celery & MongoDB]]></title><description><![CDATA[Flask REST API - Redis, Celery & MongoDB]]></description><link>https://flask-rest-api-redis-celery-and-mongodb.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 23 Oct 2026 20:02:47 GMT</lastBuildDate><atom:link href="https://flask-rest-api-redis-celery-and-mongodb.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[🚀 Flask InkCircle: Beyond CRUD - Scalable Flask REST API with MongoDB, Celery, Redis & Nginx]]></title><description><![CDATA[Building robust and production-grade backend APIs is not just about CRUD operations it’s about scalability, modularity, and performance.In this project, I…]]></description><link>https://flask-rest-api-redis-celery-and-mongodb.hashnode.dev/flask-inkcircle-beyond-crud-scalable-flask-rest-api-with-mongodb-celery-redis-and-nginx</link><guid isPermaLink="true">https://flask-rest-api-redis-celery-and-mongodb.hashnode.dev/flask-inkcircle-beyond-crud-scalable-flask-rest-api-with-mongodb-celery-redis-and-nginx</guid><category><![CDATA[Flask Framework]]></category><category><![CDATA[celery]]></category><category><![CDATA[REST API]]></category><category><![CDATA[nginx]]></category><category><![CDATA[Python]]></category><category><![CDATA[AWS]]></category><category><![CDATA[pymongo]]></category><dc:creator><![CDATA[Kuldeep Ghorpade]]></dc:creator><pubDate>Wed, 12 Nov 2025 13:41:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1762954750202/c2760cec-e99c-4407-9b46-6a38670fb118.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<h1 id="heading-flask-rest-api-with-redis-celery-amp-mongodb">Flask REST API with Redis, Celery &amp; MongoDB</h1>
<p>Building robust and production-grade backend APIs is not just about CRUD operations it’s about <strong>scalability, modularity, and performance</strong>.<br />In this project, I built <strong>Flask InkCircle</strong>, a backend REST API setup that goes <em>beyond CRUD</em>, using <strong>Flask + MongoDB + Celery + Redis</strong>, containerized via <strong>Docker</strong> and deployed securely with <strong>Nginx + Let’s Encrypt + DuckDNS</strong> on <strong>AWS EC2</strong>.</p>
<hr />
<h2 id="heading-project-overview">🧩 Project Overview</h2>
<p><strong>🔗 Repo:</strong> <a target="_blank" href="https://github.com/kuldeepghorpade05/flask-InkCircle-beyond-crud">github.com/kuldeepghorpade05/flask-InkCircle-beyond-crud</a></p>
<p>This project represents a <strong>production-ready Flask backend architecture</strong> complete with authentication, background task handling, and a CI-friendly folder structure.<br />It’s built from scratch with modular design and scalability in mind.</p>
<hr />
<h2 id="heading-tech-stack-breakdown">⚙️ Tech Stack Breakdown</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Category</td><td>Tools / Technologies Used</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Framework</strong></td><td>🧠 Flask (Python)</td></tr>
<tr>
<td><strong>Database (ODMs)</strong></td><td>🗃️ MongoDB with PyMongo</td></tr>
<tr>
<td><strong>Task Queue</strong></td><td>⚡ Celery with Redis as Broker</td></tr>
<tr>
<td><strong>Web Server</strong></td><td>🌐 Nginx as Reverse Proxy</td></tr>
<tr>
<td><strong>SSL &amp; DNS</strong></td><td>🔒 Let’s Encrypt + DuckDNS</td></tr>
<tr>
<td><strong>Containerization</strong></td><td>🐳 Docker + Docker Compose</td></tr>
<tr>
<td><strong>Package Manager</strong></td><td>📦 Poetry</td></tr>
<tr>
<td><strong>Version Control</strong></td><td>🔀 Git (with Branching Strategy)</td></tr>
<tr>
<td><strong>Hosting</strong></td><td>☁️ AWS EC2 (Ubuntu)</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-project-structure">🧱 Project Structure</h2>
<pre><code class="lang-bash">flask-InkCircle-beyond-crud/
│
├── celery_tasks.py               <span class="hljs-comment"># Celery background task definitions</span>
├── docker-compose.yml            <span class="hljs-comment"># Multi-container orchestration</span>
├── Dockerfile                    <span class="hljs-comment"># Flask app Docker build</span>
├── poetry.lock                   <span class="hljs-comment"># Poetry lock file for dependencies</span>
├── pyproject.toml                <span class="hljs-comment"># Project + dependency management</span>
├── requirements.txt              <span class="hljs-comment"># Exported dependencies (for fallback)</span>
├── run.py                        <span class="hljs-comment"># Flask app entry point</span>
├── README.md                     <span class="hljs-comment"># Project documentation</span>
│
└── src/
    ├── app.py                    <span class="hljs-comment"># Application factory &amp; route registration</span>
    ├── config.py                 <span class="hljs-comment"># App configuration (env, DB URI, etc.)</span>
    ├── extensions.py             <span class="hljs-comment"># Initialize DB, JWT, CORS, etc.</span>
    ├── errors.py                 <span class="hljs-comment"># Global error handlers</span>
    │
    ├── auth/                     <span class="hljs-comment"># Authentication module</span>
    │   ├── routes.py
    │   ├── service.py
    │   ├── schemas.py
    │   ├── utils.py
    │   ├── dependencies.py
    │   └── __init__.py
    │
    ├── books/                    <span class="hljs-comment"># Book module (CRUD, search, etc.)</span>
    │   ├── routes.py
    │   ├── service.py
    │   ├── schemas.py
    │   └── __init__.py
    │
    ├── reviews/                  <span class="hljs-comment"># Review module</span>
    │   ├── routes.py
    │   ├── service.py
    │   ├── schemas.py
    │   └── __init__.py
    │
    ├── tags/                     <span class="hljs-comment"># Tag management module</span>
    │   ├── routes.py
    │   ├── service.py
    │   ├── schemas.py
    │   └── __init__.py
    │
    ├── db/                       <span class="hljs-comment"># Database layer (models, connection)</span>
    │   ├── models.py
    │   └── __init__.py
    │
    └── __init__.py
</code></pre>
<p><strong>Additional Files</strong></p>
<ul>
<li><p><code>run.py</code> → Flask entry command</p>
</li>
<li><p><code>celery_tasks.py</code> → Celery worker setup</p>
</li>
<li><p><code>Dockerfile</code> → Defines container build</p>
</li>
<li><p><code>docker-compose.yml</code> → Multi-container orchestration</p>
</li>
<li><p><code>.env</code> → Environment variables</p>
</li>
<li><p><code>pyproject.toml</code> → Poetry-managed dependencies</p>
</li>
</ul>
<hr />
<h2 id="heading-dependency-management-with-poetry">🐍 Dependency Management with Poetry</h2>
<p>Instead of <code>pip</code> and <code>requirements.txt</code>, I used <strong>Poetry</strong> for cleaner and reproducible environments.</p>
<p>✅ <strong>Advantages of Poetry</strong></p>
<ul>
<li><p>Automatically manages dependency versions</p>
</li>
<li><p>Creates isolated virtual environments</p>
</li>
<li><p>Simplifies build and deployment pipelines</p>
</li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># Install dependencies</span>
poetry install

<span class="hljs-comment"># Add new package</span>
poetry add flask pymongo redis celery flask-jwt-extended flask-cors
</code></pre>
<hr />
<h2 id="heading-dockerization">🐳 Dockerization</h2>
<p>The app is fully <strong>Dockerized</strong> with separate containers for:</p>
<ul>
<li><p>Flask app (<code>web</code>)</p>
</li>
<li><p>Redis (message broker)</p>
</li>
<li><p>Celery worker (background task runner)</p>
</li>
</ul>
<h3 id="heading-docker-composeyml"><code>docker-compose.yml</code></h3>
<pre><code class="lang-yaml"><span class="hljs-attr">version:</span> <span class="hljs-string">'3.8'</span>

<span class="hljs-attr">services:</span>
  <span class="hljs-attr">web:</span>
    <span class="hljs-attr">build:</span> <span class="hljs-string">.</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">flask_inkcircle_app</span>
    <span class="hljs-attr">restart:</span> <span class="hljs-string">always</span>
    <span class="hljs-attr">env_file:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">.env</span>
    <span class="hljs-attr">ports:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">"8000:8000"</span>
    <span class="hljs-attr">depends_on:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">redis</span>
    <span class="hljs-attr">networks:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">app-network</span>
    <span class="hljs-attr">volumes:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">./src:/app/src</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">./celery_tasks.py:/app/celery_tasks.py</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">./run.py:/app/run.py</span>
    <span class="hljs-attr">command:</span> <span class="hljs-string">python</span> <span class="hljs-string">run.py</span>

  <span class="hljs-attr">redis:</span>
    <span class="hljs-attr">image:</span> <span class="hljs-string">redis:7-alpine</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">redis</span>
    <span class="hljs-attr">restart:</span> <span class="hljs-string">always</span>
    <span class="hljs-attr">ports:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">"6379:6379"</span>
    <span class="hljs-attr">networks:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">app-network</span>
    <span class="hljs-attr">volumes:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">redis_data:/data</span>

  <span class="hljs-attr">celery:</span>
    <span class="hljs-attr">build:</span> <span class="hljs-string">.</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">celery_worker</span>
    <span class="hljs-attr">env_file:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">.env</span>
    <span class="hljs-attr">command:</span> <span class="hljs-string">celery</span> <span class="hljs-string">-A</span> <span class="hljs-string">celery_tasks.celery</span> <span class="hljs-string">worker</span> <span class="hljs-string">--loglevel=info</span>
    <span class="hljs-attr">depends_on:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">redis</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">web</span>
    <span class="hljs-attr">networks:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">app-network</span>
    <span class="hljs-attr">volumes:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">./src:/app/src</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">./celery_tasks.py:/app/celery_tasks.py</span>

<span class="hljs-attr">networks:</span>
  <span class="hljs-attr">app-network:</span>
    <span class="hljs-attr">driver:</span> <span class="hljs-string">bridge</span>

<span class="hljs-attr">volumes:</span>
  <span class="hljs-attr">redis_data:</span>
</code></pre>
<h3 id="heading-run-the-app">🔁 Run the App</h3>
<pre><code class="lang-bash">docker-compose up -d --build
</code></pre>
<p>This builds and runs all containers in the background.</p>
<hr />
<h2 id="heading-deployment-amp-https-setup">🔐 Deployment &amp; HTTPS Setup</h2>
<p>The entire stack was deployed on <strong>AWS EC2 (Ubuntu)</strong> with Nginx as a reverse proxy.</p>
<h3 id="heading-key-steps">Key steps:</h3>
<ol>
<li><p>Installed <strong>Nginx</strong> and configured reverse proxy</p>
</li>
<li><p>Used <strong>Certbot</strong> (Let’s Encrypt) for automatic SSL</p>
</li>
<li><p>Mapped custom domain using <strong>DuckDNS</strong></p>
</li>
<li><p>Redirected all HTTP → HTTPS for security</p>
</li>
</ol>
<pre><code class="lang-bash">sudo certbot --nginx -d kuldeepghorpade-flask-inkcircle.duckdns.org
</code></pre>
<p>✅ SSL renewed automatically via Certbot<br />✅ Nginx forwards all requests to port 8000 (Flask inside Docker)</p>
<hr />
<h2 id="heading-authentication-amp-security">🔑 Authentication &amp; Security</h2>
<ul>
<li><p>JWT-based Authentication (<code>flask-jwt-extended</code>)</p>
</li>
<li><p>API key security can be integrated for frontend access control</p>
</li>
<li><p>HTTPS enforced via Nginx</p>
</li>
<li><p>Tokens expire periodically, requiring re-login for safety</p>
</li>
</ul>
<hr />
<h2 id="heading-frontend-integration">🌐 Frontend Integration</h2>
<p>A minimal <strong>frontend (React or Vanilla JS)</strong> can easily consume these REST APIs.<br />Even if hosted separately (e.g., <strong>Netlify or Vercel</strong>), HTTPS ensures secure communication.</p>
<hr />
<h2 id="heading-git-branching-amp-ci-readiness">🔀 Git Branching &amp; CI-Readiness</h2>
<ul>
<li><p><code>main</code> → stable production code</p>
</li>
<li><p><code>dockerized-app</code> → container-focused branch for CI/CD</p>
</li>
<li><p>Used <code>git merge dockerized-app</code> to sync production-ready setup</p>
</li>
<li><p>Ready for pipeline integration with GitHub Actions</p>
</li>
</ul>
<hr />
<h2 id="heading-conclusion">🚀 Conclusion</h2>
<p>With <strong>Flask InkCircle</strong>, I built a complete backend architecture not just for CRUD, but for <em>scalable, synchronous, and secure backend development.</em></p>
<p>It’s a great foundation for any Flask-based microservice or API-first application.</p>
<hr />
<h3 id="heading-highlights">💡 Highlights</h3>
<ul>
<li><p>🧠 Modular Flask REST architecture</p>
</li>
<li><p>📦 Poetry-managed dependencies</p>
</li>
<li><p>🐳 Dockerized setup with Redis &amp; Celery</p>
</li>
<li><p>🌐 Nginx reverse proxy + HTTPS (Let’s Encrypt)</p>
</li>
<li><p>☁️ Deployed on AWS EC2 with DuckDNS</p>
</li>
<li><p>🔒 JWT Auth + Secure HTTPS endpoints</p>
</li>
<li><p>🔀 Git branching for CI/CD readiness</p>
</li>
</ul>
<hr />
<p>🟢 <strong>Live:</strong> <a target="_blank" href="https://kuldeepghorpade-flask-inkcircle.duckdns.org/docs">https://kuldeepghorpade-flask-inkcircle.duckdns.org/</a></p>
<p>📘 <strong>Docs:</strong> <a target="_blank" href="https://kuldeepghorpade-flask-inkcircle.duckdns.org/docs">https://kuldeepghorpade-flask-inkcircle.duckdns.org/docs</a></p>
<h2 id="heading-connect-with-me"><strong>Connect with me</strong></h2>
<ul>
<li><p><a target="_blank" href="https://github.com/kuldeepghorpade05"><strong>GitHub</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/kuldeep-ghorpade/"><strong>LinkedIn</strong></a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>