✅ Day 66 of #100DaysOfCode — Building My Own REST API with Flask! Today, I learned how to design and implement a complete RESTful API from scratch using Flask and SQLAlchemy. I explored all the key HTTP methods — GET, POST, PATCH, and DELETE — while connecting the API to a real SQLite database. Here’s what I built : A “Cafe API” where you can: Fetch all or random cafes Search by location Add a new cafe Update coffee prices dynamically Delete closed cafes (with API key authentication) Key Takeaways: REST principles & CRUD operations API documentation & Postman testing Handling JSON requests and responses Using SQLAlchemy ORM for clean data management Building this REST API really helped me understand how backend servers communicate with clients and manage data securely. #Python #Flask #RESTAPI #WebDevelopment #100DaysOfCode #APIDevelopment #SQLAlchemy #LearningJourney
Krupansh Desai’s Post
More Relevant Posts
-
☕ Built a Flask REST API that manages cafés across cities — complete with CRUD operations, SQLAlchemy ORM, and JSON responses. You can fetch random cafés, search by location, update prices, or add new ones — all from clean, RESTful endpoints. 💡 Highlights: Full CRUD API (GET, POST, PATCH, DELETE) SQLAlchemy ORM + SQLite JSON data responses Secure delete with API key 💻 Stack: Flask | SQLAlchemy | SQLite | REST API 📂 GitHub: https://lnkd.in/g4eqsVKt 📁 Folder: CafeAPI Simple. Scalable. Developer-friendly. #Python #Flask #API #WebDevelopment #RESTAPI #SQLAlchemy #BackendDevelopment #FullStack #100DaysOfCode
To view or add a comment, sign in
-
-
The Power of Dependency Injection (DI) in FastAPI Most developers love FastAPI for its speed, but few fully leverage one of its most underrated superpowers: Dependency Injection (DI). Dependency Injection in FastAPI isn’t just about organizing code, it’s about maintainability, scalability, and testability at scale. Here’s why 👇 When you define reusable logic (like database connections, authentication, or configuration) as dependencies using Depends(), you’re separating infrastructure from logic. This makes your API more modular, and drastically easier to test. Example: from fastapi import Depends, FastAPI from sqlalchemy.orm import Session from .database import get_db from .models import User app = FastAPI() def get_current_user(db: Session = Depends(get_db)): return db.query(User).first() @app.get("/profile") def read_profile(user = Depends(get_current_user)): return {"username": user.username} 🔍 Why it matters: Your database logic is isolated. Your routes remain clean and focused. You can mock dependencies during testing — no real DB needed. In large backend systems or microservices, this pattern keeps your code decoupled and future-proof. 🧠 Takeaway: Dependency Injection isn’t just a feature, it’s a mindset for building backend systems that scale without turning into spaghetti code. #FastAPI #BackendEngineering #Python #CleanArchitecture #Microservices #API #SoftwareDesign #ScalableSystems
To view or add a comment, sign in
-
-
(SOUND ON!) Over the past few days, I’ve been working on a project that combines multiple technologies into a fully automated and scalable data pipeline. I built a Django application that imports movie titles from a file, fetches their information from the OMDb API, scrapes Metacritic scores using Selenium in a headless Chrome running inside Docker, and then generates a clean Excel report with all results. All of this runs asynchronously through Celery and Redis, with real-time monitoring in Flower, and data persistence handled by PostgreSQL. In the video below, you can see the entire process running with my explanation, from uploading the movie list, to parallel task execution, database updates, and finally the automated report generation. It was a great challenge to integrate APIs, web scraping, async task orchestration, and Dockerized services into one cohesive system. Full project available here: https://lnkd.in/gnKWbVqu #SoftwareEngineering #DockerizedApps #ScalableArchitecture #PythonDeveloper #DistributedSystems
To view or add a comment, sign in
-
📚 Built my own mini digital library from scratch — powered by Flask + SQLAlchemy! Ever wanted to track what books you’ve read (and rate them)? Now you can. This app lets you add, edit, and delete books with live updates — all stored in a clean SQLite database, styled with Bootstrap. 💡 Highlights: Full CRUD (Create, Read, Update, Delete) Declarative Base + SQLAlchemy ORM Lightweight, elegant Flask setup 💻 Tech Stack: Flask | SQLAlchemy | Bootstrap | SQLite 📂 GitHub: https://lnkd.in/g4eqsVKt 📁 Folder: LibraryManager No raw SQL. Just Python classes managing your database. It’s simple — and surprisingly powerful. #Python #Flask #SQLAlchemy #WebDevelopment #FullStack #Database #DeveloperPortfolio #BackendDevelopment #CRUD #CodingJourney #GitHub #100DaysOfCode
To view or add a comment, sign in
-
We recently ran chaos tests on our PostgreSQL setup using Pumba, adding artificial latency to simulate a degraded network. Everything worked fine—until it didn’t. Under heavy delay, we found that async SQLAlchemy sessions were leaking connections after cancellations. The root cause was a subtle race condition in asyncpg: the CancelRequest wasn’t finishing before the session closed, leaving connections stuck. A simple 100ms delay and shielding cleanup from cancellation completely solved it. We wrote about what happened, why it matters, and how we fixed it: 👉 https://lnkd.in/dTXZvSkv If you’re working with async SQLAlchemy, network timeouts, or chaos testing, this might save you a few hours of debugging. #Python #SQLAlchemy #PostgreSQL #BackendEngineering #ChaosTesting #ResilienceEngineering
To view or add a comment, sign in
-
🚀 Hands-On with FastAPI: My First CRUD App Over the past few days, In the process to learn about Fast-API I developed a basic CRUD API to dive deep into backend development. This project was purely for learning, but it gave me hands-on experience with key technologies and concepts. Technologies I worked with: FastAPI – RESTful APIs with automatic documentation and type safety Pydantic – Data validation and serialization with request/response models SQLAlchemy – ORM integration for database operations and relationships Uvicorn – ASGI server for async application execution SQLite – Database setup, sessions, and dependency injection What I learned: ✅ Structuring a FastAPI project with models, schemas, CRUD operations, and database config ✅ Difference between Pydantic models (validation) and SQLAlchemy models (database) ✅ Database session management and lifecycle ✅ Power of FastAPI’s automatic Swagger UI for instant API testing ✅ Importance of type hints in Python for building robust APIs Even though this project is Basic, it helped me understand how different backend technologies work together. Sometimes, learning and sharing small wins is just as important as tackling complex projects. 📂 GitHub Repo: https://lnkd.in/gfT6DVrK #FastAPI #Python #BackendDevelopment #SQLAlchemy #Pydantic #RESTfulAPI #LearningToCode #SoftwareEngineering
To view or add a comment, sign in
-
Solving LeetCode - 1164. Product Price at a Given Date IN SQl - WITH cte AS (SELECT * FROM Products WHERE change_date <= '2019-08-16'), cte1 AS (SELECT *, RANK() OVER (PARTITION BY product_id ORDER BY change_date DESC) AS rnk FROM cte) SELECT product_id, new_price AS price FROM cte1 WHERE rnk = 1 UNION SELECT product_id, 10 AS price FROM Products WHERE product_id NOT IN (SELECT product_id FROM cte1); IN PANDAS- import pandas as pd def price_at_given_date(products: pd.DataFrame) -> pd.DataFrame: filtered = products[products['change_date'] <= '2019-08-16'] filtered = filtered.sort_values(['product_id', 'change_date'], ascending=[True, False]) latest = filtered.drop_duplicates(subset=['product_id'], keep='first') all_products = products['product_id'].unique() latest_ids = latest['product_id'].unique() missing_ids = set(all_products) - set(latest_ids) missing_df = pd.DataFrame({'product_id': list(missing_ids), 'price': 10}) latest = latest[['product_id', 'new_price']].rename(columns={'new_price': 'price'}) result = pd.concat([latest, missing_df], ignore_index=True) return result.sort_values('product_id').reset_index(drop=True) #LeetCode #Python #Pandas #SQL #DataEngineering #CodingPractice #ProblemSolving #DataAnalysis #SQLtoPandas #googleanalytics
To view or add a comment, sign in
-
Today I spent some time improving the code quality and maintainability of our data pipelines using Pylint — a simple but powerful tool that often gets overlooked in Data Engineering projects. 🔍 What is Pylint? Pylint is a Python static code analysis tool that checks for: 1. Code errors and bad practices 2. Style consistency (PEP8) 3. Unused imports or variables 4. Docstring and naming issues 5. Complexity and maintainability scores It’s like having a code reviewer that never gets tired — catching small issues before they become big problems. 🧩 Example 1: Bad vs Good Code ❌ Bad Code: def getdata(x,y): return x+y ✅ Good Code (Pylint-friendly): def get_data(x: int, y: int) -> int: """Return the sum of two numbers.""" return x + y ✅ Pylint flags missing docstrings, poor naming (getdata → get_data), and missing type hints — nudging you toward clean, readable code. 🧩 Example 2: Unused Imports ❌ Bad Code: import pandas as pd import numpy as np def square(x): return x * x ✅ Good Code: def square(x: int) -> int: """Return square of a number.""" return x * x ✅ Pylint detects that pandas and numpy aren’t used and suggests removing them — helping keep the code lightweight and efficient. 💡 Why This Matters for Data Engineers? We often discuss Spark, Snowflake, Hadoop, Kafka, and other big data technologies — but we rarely talk about code observability and quality. Yet, as our pipelines grow in complexity, maintainable, readable, and testable code becomes just as important as scalability and performance. Tools like Pylint, along with unit testing, type hints, and linting pipelines in CI/CD, make a huge difference in the long run. You can check the documentation here: https://lnkd.in/gUeMKzae 👨💻 Let’s remember — writing good data engineering code isn’t just about moving data fast, it’s about making it future-proof. #DataEngineering #Python #Pylint #CleanCode #SoftwareEngineering #Spark #Snowflake #CodeQuality #BestPractices #GenAi
To view or add a comment, sign in
-
May I present? A simple Apache Airflow Forkbomb 💣! Okay, okay, I know this isn't a forkbomb technically, and you can achieve the same with @continuous and a regular Dag, but it's a great way to illustrate how Airflow assets work and how to get your instance sweating a bit 😉. Take a look at the code, this actually works and creates a cyclic scheduling dependency, running infinitely by triggering itself. Here's the magic behind it, which is crucial for understanding Airflow's asset-aware paradigm: 💡 @asset is a declarative shorthand that creates a Dag, a single task, and an asset as an outlet, taking the function name as the asset name by default. So, @asset def lets_go(): produces an asset named lets_go. 💡 Asset(...) creates a reference to an asset by its name. So, schedule=Asset("lets_go") tells the Dag to run whenever the asset named lets_go is updated. When you combine them, the Dag ends up scheduling itself. It's a perfect demonstration that in Airflow, asset identity is based on its name, not the Python object instance. This also highlights a fundamental concept: Airflow prevents cycles at the authoring level, but it allows them at the scheduling level. It's a fun way to annoy your data engineering peers on a Monday morning and a fantastic lesson on how assets really work. Have fun, but seriously, consider adding a sleep(...) to the function if you try this 🤣! #ApacheAirflow #DataEngineering #Orchestration #Python #DataPipelines #TechHumor #Forkbomb
To view or add a comment, sign in
-
-
🔧 Learning System Design from Scratch — One Microservice at a Time As I dive deeper into system design fundamentals, I’ve found that the best way to learn is by building real, working components — and that’s exactly what I did with a recent mini-project: a URL Shortener API. Instead of just reading theory, I chose to implement a small backend service using FastAPI and SQLite to understand how lightweight services are architected, validated, and deployed. Here’s why I picked these tools: 🚀 FastAPI: A modern Python framework that made it super easy to build clean, async-ready REST endpoints (POST /shorten, GET /{short_id}) with built-in data validation and auto-generated Swagger docs. Perfect for quick iteration and clarity. 🧱 SQLite: A serverless, file-based database that let me persist short URLs with zero setup. Lightweight, fast, and perfect for small-scale systems like this one — especially when paired with SQLAlchemy for ORM support. This project helped me grasp core concepts like: ✔ Designing RESTful endpoints ✔ Input validation using Pydantic ✔ Connecting APIs to persistent storage ✔ Testing with Postman & understanding local-to-remote communication ✔ Thinking about the trade-offs of architecture choices (e.g., async vs sync, file-based DBs vs hosted ones) 💡 Takeaway: System design isn’t just about handling millions of users — it’s about making the right technical choices for the problem at hand. FastAPI + SQLite was the right stack here, and it taught me how to think practically about designing backend systems from the ground up. Github Repo: https://lnkd.in/gnYgesCV #SystemDesign #BackendDevelopment #FullStackDeveloper #FastAPI #SQLite #Microservices #Python #LearningInPublic #BuildInPublic #DeveloperJourney
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development