[{"data":1,"prerenderedAt":3962},["ShallowReactive",2],{"post-api-first-principles":3,"rel-api-first-principles":747,"sib-api-first-principles":3890},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"layout":11,"subtitle":12,"image":13,"optimized_image":13,"category":14,"tags":15,"author":18,"paginate":6,"body":19,"_type":741,"_id":742,"_source":743,"_file":744,"_stem":745,"_extension":746},"/posts/api-first-principles","posts",false,"","API First principles","API First principles explained with examples","2023-09-01 22:15:18","post","Exploring OpenAPI with YAML","/assets/img/uploads/connection-train.jpg","code",[16,17],"api-first","openapi","jaimedearcos",{"type":20,"children":21,"toc":736},"root",[22,30,37,42,48,53,58,63,709,714,720,725,730],{"type":23,"tag":24,"props":25,"children":26},"element","p",{},[27],{"type":28,"value":29},"text","In the ever-evolving world of software development, embracing the \"API First\" philosophy has become a pivotal strategy. This approach prioritizes the design and development of Application Programming Interfaces (APIs) at the forefront of any software project. It not only streamlines development processes but also fosters collaboration and innovation. In this post, we'll delve into the concept of API-First and explore OpenAPI, a powerful tool for defining, documenting, and managing APIs.",{"type":23,"tag":31,"props":32,"children":34},"h2",{"id":33},"understanding-api-first",[35],{"type":28,"value":36},"Understanding API First",{"type":23,"tag":24,"props":38,"children":39},{},[40],{"type":28,"value":41},"The API-First approach is a mindset that centers around designing APIs before any other aspect of a software project. It shifts the focus from coding to defining clear, standardized interfaces that different parts of the software can communicate through. This methodology promotes a structured and modular architecture, making it easier to adapt and scale applications over time.",{"type":23,"tag":31,"props":43,"children":45},{"id":44},"introducing-openapi",[46],{"type":28,"value":47},"Introducing OpenAPI",{"type":23,"tag":24,"props":49,"children":50},{},[51],{"type":28,"value":52},"OpenAPI, formerly known as Swagger, is a specification for building and documenting RESTful APIs. It offers a standardized way to define API endpoints, request/response formats, and authentication methods. OpenAPI enables teams to create clear, machine-readable API contracts, making it a fundamental part of the API-First philosophy.",{"type":23,"tag":24,"props":54,"children":55},{},[56],{"type":28,"value":57},"Example: YAML-based API Contract",{"type":23,"tag":24,"props":59,"children":60},{},[61],{"type":28,"value":62},"Let's dive into a practical example of an API contract using YAML. Below is a simplified representation of an e-commerce API for managing products:",{"type":23,"tag":64,"props":65,"children":69},"pre",{"className":66,"code":67,"language":68,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-light","openapi: 3.0.0\ninfo:\n  title: E-Commerce API\n  version: 1.0.0\npaths:\n  /products:\n    get:\n      summary: Get a list of products\n      responses:\n        '200':\n          description: Successful response\n          content:\n            application/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#/components/schemas/Product'\n    post:\n      summary: Create a new product\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/Product'\n      responses:\n        '201':\n          description: Product created successfully\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Product'\ncomponents:\n  schemas:\n    Product:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n        price:\n          type: number\n","yaml",[70],{"type":23,"tag":14,"props":71,"children":72},{"__ignoreMap":7},[73,96,110,129,147,160,173,186,204,217,230,248,261,274,287,305,318,336,349,366,379,397,410,423,436,453,465,478,495,507,519,531,548,561,574,587,605,618,631,649,662,679,692],{"type":23,"tag":74,"props":75,"children":78},"span",{"class":76,"line":77},"line",1,[79,84,90],{"type":23,"tag":74,"props":80,"children":82},{"style":81},"--shiki-default:#85E89D;--shiki-light:#22863A",[83],{"type":28,"value":17},{"type":23,"tag":74,"props":85,"children":87},{"style":86},"--shiki-default:#E1E4E8;--shiki-light:#24292E",[88],{"type":28,"value":89},": ",{"type":23,"tag":74,"props":91,"children":93},{"style":92},"--shiki-default:#79B8FF;--shiki-light:#005CC5",[94],{"type":28,"value":95},"3.0.0\n",{"type":23,"tag":74,"props":97,"children":99},{"class":76,"line":98},2,[100,105],{"type":23,"tag":74,"props":101,"children":102},{"style":81},[103],{"type":28,"value":104},"info",{"type":23,"tag":74,"props":106,"children":107},{"style":86},[108],{"type":28,"value":109},":\n",{"type":23,"tag":74,"props":111,"children":113},{"class":76,"line":112},3,[114,119,123],{"type":23,"tag":74,"props":115,"children":116},{"style":81},[117],{"type":28,"value":118},"  title",{"type":23,"tag":74,"props":120,"children":121},{"style":86},[122],{"type":28,"value":89},{"type":23,"tag":74,"props":124,"children":126},{"style":125},"--shiki-default:#9ECBFF;--shiki-light:#032F62",[127],{"type":28,"value":128},"E-Commerce API\n",{"type":23,"tag":74,"props":130,"children":132},{"class":76,"line":131},4,[133,138,142],{"type":23,"tag":74,"props":134,"children":135},{"style":81},[136],{"type":28,"value":137},"  version",{"type":23,"tag":74,"props":139,"children":140},{"style":86},[141],{"type":28,"value":89},{"type":23,"tag":74,"props":143,"children":144},{"style":92},[145],{"type":28,"value":146},"1.0.0\n",{"type":23,"tag":74,"props":148,"children":150},{"class":76,"line":149},5,[151,156],{"type":23,"tag":74,"props":152,"children":153},{"style":81},[154],{"type":28,"value":155},"paths",{"type":23,"tag":74,"props":157,"children":158},{"style":86},[159],{"type":28,"value":109},{"type":23,"tag":74,"props":161,"children":163},{"class":76,"line":162},6,[164,169],{"type":23,"tag":74,"props":165,"children":166},{"style":81},[167],{"type":28,"value":168},"  /products",{"type":23,"tag":74,"props":170,"children":171},{"style":86},[172],{"type":28,"value":109},{"type":23,"tag":74,"props":174,"children":176},{"class":76,"line":175},7,[177,182],{"type":23,"tag":74,"props":178,"children":179},{"style":81},[180],{"type":28,"value":181},"    get",{"type":23,"tag":74,"props":183,"children":184},{"style":86},[185],{"type":28,"value":109},{"type":23,"tag":74,"props":187,"children":189},{"class":76,"line":188},8,[190,195,199],{"type":23,"tag":74,"props":191,"children":192},{"style":81},[193],{"type":28,"value":194},"      summary",{"type":23,"tag":74,"props":196,"children":197},{"style":86},[198],{"type":28,"value":89},{"type":23,"tag":74,"props":200,"children":201},{"style":125},[202],{"type":28,"value":203},"Get a list of products\n",{"type":23,"tag":74,"props":205,"children":207},{"class":76,"line":206},9,[208,213],{"type":23,"tag":74,"props":209,"children":210},{"style":81},[211],{"type":28,"value":212},"      responses",{"type":23,"tag":74,"props":214,"children":215},{"style":86},[216],{"type":28,"value":109},{"type":23,"tag":74,"props":218,"children":220},{"class":76,"line":219},10,[221,226],{"type":23,"tag":74,"props":222,"children":223},{"style":125},[224],{"type":28,"value":225},"        '200'",{"type":23,"tag":74,"props":227,"children":228},{"style":86},[229],{"type":28,"value":109},{"type":23,"tag":74,"props":231,"children":233},{"class":76,"line":232},11,[234,239,243],{"type":23,"tag":74,"props":235,"children":236},{"style":81},[237],{"type":28,"value":238},"          description",{"type":23,"tag":74,"props":240,"children":241},{"style":86},[242],{"type":28,"value":89},{"type":23,"tag":74,"props":244,"children":245},{"style":125},[246],{"type":28,"value":247},"Successful response\n",{"type":23,"tag":74,"props":249,"children":251},{"class":76,"line":250},12,[252,257],{"type":23,"tag":74,"props":253,"children":254},{"style":81},[255],{"type":28,"value":256},"          content",{"type":23,"tag":74,"props":258,"children":259},{"style":86},[260],{"type":28,"value":109},{"type":23,"tag":74,"props":262,"children":264},{"class":76,"line":263},13,[265,270],{"type":23,"tag":74,"props":266,"children":267},{"style":81},[268],{"type":28,"value":269},"            application/json",{"type":23,"tag":74,"props":271,"children":272},{"style":86},[273],{"type":28,"value":109},{"type":23,"tag":74,"props":275,"children":277},{"class":76,"line":276},14,[278,283],{"type":23,"tag":74,"props":279,"children":280},{"style":81},[281],{"type":28,"value":282},"              schema",{"type":23,"tag":74,"props":284,"children":285},{"style":86},[286],{"type":28,"value":109},{"type":23,"tag":74,"props":288,"children":290},{"class":76,"line":289},15,[291,296,300],{"type":23,"tag":74,"props":292,"children":293},{"style":81},[294],{"type":28,"value":295},"                type",{"type":23,"tag":74,"props":297,"children":298},{"style":86},[299],{"type":28,"value":89},{"type":23,"tag":74,"props":301,"children":302},{"style":125},[303],{"type":28,"value":304},"array\n",{"type":23,"tag":74,"props":306,"children":308},{"class":76,"line":307},16,[309,314],{"type":23,"tag":74,"props":310,"children":311},{"style":81},[312],{"type":28,"value":313},"                items",{"type":23,"tag":74,"props":315,"children":316},{"style":86},[317],{"type":28,"value":109},{"type":23,"tag":74,"props":319,"children":321},{"class":76,"line":320},17,[322,327,331],{"type":23,"tag":74,"props":323,"children":324},{"style":81},[325],{"type":28,"value":326},"                  $ref",{"type":23,"tag":74,"props":328,"children":329},{"style":86},[330],{"type":28,"value":89},{"type":23,"tag":74,"props":332,"children":333},{"style":125},[334],{"type":28,"value":335},"'#/components/schemas/Product'\n",{"type":23,"tag":74,"props":337,"children":339},{"class":76,"line":338},18,[340,345],{"type":23,"tag":74,"props":341,"children":342},{"style":81},[343],{"type":28,"value":344},"    post",{"type":23,"tag":74,"props":346,"children":347},{"style":86},[348],{"type":28,"value":109},{"type":23,"tag":74,"props":350,"children":352},{"class":76,"line":351},19,[353,357,361],{"type":23,"tag":74,"props":354,"children":355},{"style":81},[356],{"type":28,"value":194},{"type":23,"tag":74,"props":358,"children":359},{"style":86},[360],{"type":28,"value":89},{"type":23,"tag":74,"props":362,"children":363},{"style":125},[364],{"type":28,"value":365},"Create a new product\n",{"type":23,"tag":74,"props":367,"children":369},{"class":76,"line":368},20,[370,375],{"type":23,"tag":74,"props":371,"children":372},{"style":81},[373],{"type":28,"value":374},"      requestBody",{"type":23,"tag":74,"props":376,"children":377},{"style":86},[378],{"type":28,"value":109},{"type":23,"tag":74,"props":380,"children":382},{"class":76,"line":381},21,[383,388,392],{"type":23,"tag":74,"props":384,"children":385},{"style":81},[386],{"type":28,"value":387},"        required",{"type":23,"tag":74,"props":389,"children":390},{"style":86},[391],{"type":28,"value":89},{"type":23,"tag":74,"props":393,"children":394},{"style":92},[395],{"type":28,"value":396},"true\n",{"type":23,"tag":74,"props":398,"children":400},{"class":76,"line":399},22,[401,406],{"type":23,"tag":74,"props":402,"children":403},{"style":81},[404],{"type":28,"value":405},"        content",{"type":23,"tag":74,"props":407,"children":408},{"style":86},[409],{"type":28,"value":109},{"type":23,"tag":74,"props":411,"children":413},{"class":76,"line":412},23,[414,419],{"type":23,"tag":74,"props":415,"children":416},{"style":81},[417],{"type":28,"value":418},"          application/json",{"type":23,"tag":74,"props":420,"children":421},{"style":86},[422],{"type":28,"value":109},{"type":23,"tag":74,"props":424,"children":426},{"class":76,"line":425},24,[427,432],{"type":23,"tag":74,"props":428,"children":429},{"style":81},[430],{"type":28,"value":431},"            schema",{"type":23,"tag":74,"props":433,"children":434},{"style":86},[435],{"type":28,"value":109},{"type":23,"tag":74,"props":437,"children":439},{"class":76,"line":438},25,[440,445,449],{"type":23,"tag":74,"props":441,"children":442},{"style":81},[443],{"type":28,"value":444},"              $ref",{"type":23,"tag":74,"props":446,"children":447},{"style":86},[448],{"type":28,"value":89},{"type":23,"tag":74,"props":450,"children":451},{"style":125},[452],{"type":28,"value":335},{"type":23,"tag":74,"props":454,"children":456},{"class":76,"line":455},26,[457,461],{"type":23,"tag":74,"props":458,"children":459},{"style":81},[460],{"type":28,"value":212},{"type":23,"tag":74,"props":462,"children":463},{"style":86},[464],{"type":28,"value":109},{"type":23,"tag":74,"props":466,"children":468},{"class":76,"line":467},27,[469,474],{"type":23,"tag":74,"props":470,"children":471},{"style":125},[472],{"type":28,"value":473},"        '201'",{"type":23,"tag":74,"props":475,"children":476},{"style":86},[477],{"type":28,"value":109},{"type":23,"tag":74,"props":479,"children":481},{"class":76,"line":480},28,[482,486,490],{"type":23,"tag":74,"props":483,"children":484},{"style":81},[485],{"type":28,"value":238},{"type":23,"tag":74,"props":487,"children":488},{"style":86},[489],{"type":28,"value":89},{"type":23,"tag":74,"props":491,"children":492},{"style":125},[493],{"type":28,"value":494},"Product created successfully\n",{"type":23,"tag":74,"props":496,"children":498},{"class":76,"line":497},29,[499,503],{"type":23,"tag":74,"props":500,"children":501},{"style":81},[502],{"type":28,"value":256},{"type":23,"tag":74,"props":504,"children":505},{"style":86},[506],{"type":28,"value":109},{"type":23,"tag":74,"props":508,"children":510},{"class":76,"line":509},30,[511,515],{"type":23,"tag":74,"props":512,"children":513},{"style":81},[514],{"type":28,"value":269},{"type":23,"tag":74,"props":516,"children":517},{"style":86},[518],{"type":28,"value":109},{"type":23,"tag":74,"props":520,"children":522},{"class":76,"line":521},31,[523,527],{"type":23,"tag":74,"props":524,"children":525},{"style":81},[526],{"type":28,"value":282},{"type":23,"tag":74,"props":528,"children":529},{"style":86},[530],{"type":28,"value":109},{"type":23,"tag":74,"props":532,"children":534},{"class":76,"line":533},32,[535,540,544],{"type":23,"tag":74,"props":536,"children":537},{"style":81},[538],{"type":28,"value":539},"                $ref",{"type":23,"tag":74,"props":541,"children":542},{"style":86},[543],{"type":28,"value":89},{"type":23,"tag":74,"props":545,"children":546},{"style":125},[547],{"type":28,"value":335},{"type":23,"tag":74,"props":549,"children":551},{"class":76,"line":550},33,[552,557],{"type":23,"tag":74,"props":553,"children":554},{"style":81},[555],{"type":28,"value":556},"components",{"type":23,"tag":74,"props":558,"children":559},{"style":86},[560],{"type":28,"value":109},{"type":23,"tag":74,"props":562,"children":564},{"class":76,"line":563},34,[565,570],{"type":23,"tag":74,"props":566,"children":567},{"style":81},[568],{"type":28,"value":569},"  schemas",{"type":23,"tag":74,"props":571,"children":572},{"style":86},[573],{"type":28,"value":109},{"type":23,"tag":74,"props":575,"children":577},{"class":76,"line":576},35,[578,583],{"type":23,"tag":74,"props":579,"children":580},{"style":81},[581],{"type":28,"value":582},"    Product",{"type":23,"tag":74,"props":584,"children":585},{"style":86},[586],{"type":28,"value":109},{"type":23,"tag":74,"props":588,"children":590},{"class":76,"line":589},36,[591,596,600],{"type":23,"tag":74,"props":592,"children":593},{"style":81},[594],{"type":28,"value":595},"      type",{"type":23,"tag":74,"props":597,"children":598},{"style":86},[599],{"type":28,"value":89},{"type":23,"tag":74,"props":601,"children":602},{"style":125},[603],{"type":28,"value":604},"object\n",{"type":23,"tag":74,"props":606,"children":608},{"class":76,"line":607},37,[609,614],{"type":23,"tag":74,"props":610,"children":611},{"style":81},[612],{"type":28,"value":613},"      properties",{"type":23,"tag":74,"props":615,"children":616},{"style":86},[617],{"type":28,"value":109},{"type":23,"tag":74,"props":619,"children":621},{"class":76,"line":620},38,[622,627],{"type":23,"tag":74,"props":623,"children":624},{"style":81},[625],{"type":28,"value":626},"        id",{"type":23,"tag":74,"props":628,"children":629},{"style":86},[630],{"type":28,"value":109},{"type":23,"tag":74,"props":632,"children":634},{"class":76,"line":633},39,[635,640,644],{"type":23,"tag":74,"props":636,"children":637},{"style":81},[638],{"type":28,"value":639},"          type",{"type":23,"tag":74,"props":641,"children":642},{"style":86},[643],{"type":28,"value":89},{"type":23,"tag":74,"props":645,"children":646},{"style":125},[647],{"type":28,"value":648},"integer\n",{"type":23,"tag":74,"props":650,"children":652},{"class":76,"line":651},40,[653,658],{"type":23,"tag":74,"props":654,"children":655},{"style":81},[656],{"type":28,"value":657},"        name",{"type":23,"tag":74,"props":659,"children":660},{"style":86},[661],{"type":28,"value":109},{"type":23,"tag":74,"props":663,"children":665},{"class":76,"line":664},41,[666,670,674],{"type":23,"tag":74,"props":667,"children":668},{"style":81},[669],{"type":28,"value":639},{"type":23,"tag":74,"props":671,"children":672},{"style":86},[673],{"type":28,"value":89},{"type":23,"tag":74,"props":675,"children":676},{"style":125},[677],{"type":28,"value":678},"string\n",{"type":23,"tag":74,"props":680,"children":682},{"class":76,"line":681},42,[683,688],{"type":23,"tag":74,"props":684,"children":685},{"style":81},[686],{"type":28,"value":687},"        price",{"type":23,"tag":74,"props":689,"children":690},{"style":86},[691],{"type":28,"value":109},{"type":23,"tag":74,"props":693,"children":695},{"class":76,"line":694},43,[696,700,704],{"type":23,"tag":74,"props":697,"children":698},{"style":81},[699],{"type":28,"value":639},{"type":23,"tag":74,"props":701,"children":702},{"style":86},[703],{"type":28,"value":89},{"type":23,"tag":74,"props":705,"children":706},{"style":125},[707],{"type":28,"value":708},"number\n",{"type":23,"tag":24,"props":710,"children":711},{},[712],{"type":28,"value":713},"This YAML file defines the API endpoints, request/response structures, and data schemas for an e-commerce platform. It serves as a contract that developers, testers, and documentation teams can refer to, ensuring consistent implementation and clear communication.",{"type":23,"tag":31,"props":715,"children":717},{"id":716},"conclusion",[718],{"type":28,"value":719},"Conclusion",{"type":23,"tag":24,"props":721,"children":722},{},[723],{"type":28,"value":724},"Adopting the API-First philosophy and utilizing tools like OpenAPI with YAML-based contracts can greatly enhance your software development projects. It fosters collaboration, reduces development time, and ultimately results in more robust and scalable APIs. As the software landscape continues to evolve, embracing API-First practices becomes not just an option but a necessity for success.",{"type":23,"tag":24,"props":726,"children":727},{},[728],{"type":28,"value":729},"Start your journey towards API excellence today by making API-First development a core principle of your projects.",{"type":23,"tag":731,"props":732,"children":733},"style",{},[734],{"type":28,"value":735},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}",{"title":7,"searchDepth":98,"depth":98,"links":737},[738,739,740],{"id":33,"depth":98,"text":36},{"id":44,"depth":98,"text":47},{"id":716,"depth":98,"text":719},"markdown","content:posts:api-first-principles.md","content","posts/api-first-principles.md","posts/api-first-principles","md",[748,2163,3070],{"_path":749,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":750,"description":751,"date":752,"layout":11,"subtitle":753,"image":754,"optimized_image":754,"category":14,"tags":755,"author":18,"paginate":6,"body":761,"_type":741,"_id":2160,"_source":743,"_file":2161,"_stem":2162,"_extension":746},"/posts/gpt-sql-integration","Implementa un analizador de consultas en lenguaje natural para bases de datos SQL con GPT","Aprende a implementar un sistema que convierte consultas en lenguaje natural en sentencias SQL usando OpenAI GPT, con un tutorial paso a paso y ejemplos prácticos.","2025-01-15T11:00:00.000Z","Transforma preguntas naturales en consultas SQL automatizadas","/assets/img/uploads/gpt-sql-integration.png",[14,756,757,758,759,760],"gpt","openai","sql","ai","nlp",{"type":20,"children":762,"toc":2149},[763,772,778,798,804,809,852,865,881,887,892,1106,1112,1117,1450,1456,1461,1807,1813,1818,1877,1883,1888,2068,2074,2092,2098,2103,2110,2145],{"type":23,"tag":764,"props":765,"children":766},"blockquote",{},[767],{"type":23,"tag":24,"props":768,"children":769},{},[770],{"type":28,"value":771},"Convertir preguntas naturales en consultas SQL de forma automática simplifica la interacción con bases de datos, permitiendo que usuarios sin conocimientos técnicos extraigan datos relevantes. En este tutorial, aprenderás a implementar esta solución utilizando la API de OpenAI GPT.",{"type":23,"tag":31,"props":773,"children":775},{"id":774},"requisitos-previos",[776],{"type":28,"value":777},"Requisitos Previos",{"type":23,"tag":779,"props":780,"children":781},"ul",{},[782,788,793],{"type":23,"tag":783,"props":784,"children":785},"li",{},[786],{"type":28,"value":787},"Cuenta y clave API de OpenAI",{"type":23,"tag":783,"props":789,"children":790},{},[791],{"type":28,"value":792},"Python instalado en tu entorno",{"type":23,"tag":783,"props":794,"children":795},{},[796],{"type":28,"value":797},"Base de datos SQL (ej.: PostgreSQL, MySQL)",{"type":23,"tag":31,"props":799,"children":801},{"id":800},"paso-1-configuración-del-entorno",[802],{"type":28,"value":803},"Paso 1: Configuración del entorno",{"type":23,"tag":24,"props":805,"children":806},{},[807],{"type":28,"value":808},"Primero, instala las dependencias necesarias:",{"type":23,"tag":64,"props":810,"children":814},{"className":811,"code":812,"language":813,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark github-light","pip install openai python-dotenv sqlalchemy psycopg2-binary\n","bash",[815],{"type":23,"tag":14,"props":816,"children":817},{"__ignoreMap":7},[818],{"type":23,"tag":74,"props":819,"children":820},{"class":76,"line":77},[821,827,832,837,842,847],{"type":23,"tag":74,"props":822,"children":824},{"style":823},"--shiki-default:#B392F0;--shiki-light:#6F42C1",[825],{"type":28,"value":826},"pip",{"type":23,"tag":74,"props":828,"children":829},{"style":125},[830],{"type":28,"value":831}," install",{"type":23,"tag":74,"props":833,"children":834},{"style":125},[835],{"type":28,"value":836}," openai",{"type":23,"tag":74,"props":838,"children":839},{"style":125},[840],{"type":28,"value":841}," python-dotenv",{"type":23,"tag":74,"props":843,"children":844},{"style":125},[845],{"type":28,"value":846}," sqlalchemy",{"type":23,"tag":74,"props":848,"children":849},{"style":125},[850],{"type":28,"value":851}," psycopg2-binary\n",{"type":23,"tag":24,"props":853,"children":854},{},[855,857,863],{"type":28,"value":856},"Guarda tu clave API en un archivo ",{"type":23,"tag":14,"props":858,"children":860},{"className":859},[],[861],{"type":28,"value":862},".env",{"type":28,"value":864},":",{"type":23,"tag":64,"props":866,"children":870},{"className":867,"code":868,"language":869,"meta":7,"style":7},"language-env shiki shiki-themes github-dark github-light","OPENAI_API_KEY='tu-api-key'\n","env",[871],{"type":23,"tag":14,"props":872,"children":873},{"__ignoreMap":7},[874],{"type":23,"tag":74,"props":875,"children":876},{"class":76,"line":77},[877],{"type":23,"tag":74,"props":878,"children":879},{},[880],{"type":28,"value":868},{"type":23,"tag":31,"props":882,"children":884},{"id":883},"paso-2-conexión-a-la-base-de-datos",[885],{"type":28,"value":886},"Paso 2: Conexión a la base de datos",{"type":23,"tag":24,"props":888,"children":889},{},[890],{"type":28,"value":891},"Utiliza SQLAlchemy para conectarte a tu base de datos:",{"type":23,"tag":64,"props":893,"children":897},{"className":894,"code":895,"language":896,"meta":7,"style":7},"language-python shiki shiki-themes github-dark github-light","from sqlalchemy import create_engine\nfrom sqlalchemy.orm import sessionmaker\nimport os\nfrom dotenv import load_dotenv\n\nload_dotenv()\n\nDATABASE_URL = os.getenv(\"DATABASE_URL\")\nengine = create_engine(DATABASE_URL)\nSession = sessionmaker(bind=engine)\nsession = Session()\n","python",[898],{"type":23,"tag":14,"props":899,"children":900},{"__ignoreMap":7},[901,925,946,958,979,988,996,1003,1031,1057,1089],{"type":23,"tag":74,"props":902,"children":903},{"class":76,"line":77},[904,910,915,920],{"type":23,"tag":74,"props":905,"children":907},{"style":906},"--shiki-default:#F97583;--shiki-light:#D73A49",[908],{"type":28,"value":909},"from",{"type":23,"tag":74,"props":911,"children":912},{"style":86},[913],{"type":28,"value":914}," sqlalchemy ",{"type":23,"tag":74,"props":916,"children":917},{"style":906},[918],{"type":28,"value":919},"import",{"type":23,"tag":74,"props":921,"children":922},{"style":86},[923],{"type":28,"value":924}," create_engine\n",{"type":23,"tag":74,"props":926,"children":927},{"class":76,"line":98},[928,932,937,941],{"type":23,"tag":74,"props":929,"children":930},{"style":906},[931],{"type":28,"value":909},{"type":23,"tag":74,"props":933,"children":934},{"style":86},[935],{"type":28,"value":936}," sqlalchemy.orm ",{"type":23,"tag":74,"props":938,"children":939},{"style":906},[940],{"type":28,"value":919},{"type":23,"tag":74,"props":942,"children":943},{"style":86},[944],{"type":28,"value":945}," sessionmaker\n",{"type":23,"tag":74,"props":947,"children":948},{"class":76,"line":112},[949,953],{"type":23,"tag":74,"props":950,"children":951},{"style":906},[952],{"type":28,"value":919},{"type":23,"tag":74,"props":954,"children":955},{"style":86},[956],{"type":28,"value":957}," os\n",{"type":23,"tag":74,"props":959,"children":960},{"class":76,"line":131},[961,965,970,974],{"type":23,"tag":74,"props":962,"children":963},{"style":906},[964],{"type":28,"value":909},{"type":23,"tag":74,"props":966,"children":967},{"style":86},[968],{"type":28,"value":969}," dotenv ",{"type":23,"tag":74,"props":971,"children":972},{"style":906},[973],{"type":28,"value":919},{"type":23,"tag":74,"props":975,"children":976},{"style":86},[977],{"type":28,"value":978}," load_dotenv\n",{"type":23,"tag":74,"props":980,"children":981},{"class":76,"line":149},[982],{"type":23,"tag":74,"props":983,"children":985},{"emptyLinePlaceholder":984},true,[986],{"type":28,"value":987},"\n",{"type":23,"tag":74,"props":989,"children":990},{"class":76,"line":162},[991],{"type":23,"tag":74,"props":992,"children":993},{"style":86},[994],{"type":28,"value":995},"load_dotenv()\n",{"type":23,"tag":74,"props":997,"children":998},{"class":76,"line":175},[999],{"type":23,"tag":74,"props":1000,"children":1001},{"emptyLinePlaceholder":984},[1002],{"type":28,"value":987},{"type":23,"tag":74,"props":1004,"children":1005},{"class":76,"line":188},[1006,1011,1016,1021,1026],{"type":23,"tag":74,"props":1007,"children":1008},{"style":92},[1009],{"type":28,"value":1010},"DATABASE_URL",{"type":23,"tag":74,"props":1012,"children":1013},{"style":906},[1014],{"type":28,"value":1015}," =",{"type":23,"tag":74,"props":1017,"children":1018},{"style":86},[1019],{"type":28,"value":1020}," os.getenv(",{"type":23,"tag":74,"props":1022,"children":1023},{"style":125},[1024],{"type":28,"value":1025},"\"DATABASE_URL\"",{"type":23,"tag":74,"props":1027,"children":1028},{"style":86},[1029],{"type":28,"value":1030},")\n",{"type":23,"tag":74,"props":1032,"children":1033},{"class":76,"line":206},[1034,1039,1044,1049,1053],{"type":23,"tag":74,"props":1035,"children":1036},{"style":86},[1037],{"type":28,"value":1038},"engine ",{"type":23,"tag":74,"props":1040,"children":1041},{"style":906},[1042],{"type":28,"value":1043},"=",{"type":23,"tag":74,"props":1045,"children":1046},{"style":86},[1047],{"type":28,"value":1048}," create_engine(",{"type":23,"tag":74,"props":1050,"children":1051},{"style":92},[1052],{"type":28,"value":1010},{"type":23,"tag":74,"props":1054,"children":1055},{"style":86},[1056],{"type":28,"value":1030},{"type":23,"tag":74,"props":1058,"children":1059},{"class":76,"line":219},[1060,1065,1069,1074,1080,1084],{"type":23,"tag":74,"props":1061,"children":1062},{"style":86},[1063],{"type":28,"value":1064},"Session ",{"type":23,"tag":74,"props":1066,"children":1067},{"style":906},[1068],{"type":28,"value":1043},{"type":23,"tag":74,"props":1070,"children":1071},{"style":86},[1072],{"type":28,"value":1073}," sessionmaker(",{"type":23,"tag":74,"props":1075,"children":1077},{"style":1076},"--shiki-default:#FFAB70;--shiki-light:#E36209",[1078],{"type":28,"value":1079},"bind",{"type":23,"tag":74,"props":1081,"children":1082},{"style":906},[1083],{"type":28,"value":1043},{"type":23,"tag":74,"props":1085,"children":1086},{"style":86},[1087],{"type":28,"value":1088},"engine)\n",{"type":23,"tag":74,"props":1090,"children":1091},{"class":76,"line":232},[1092,1097,1101],{"type":23,"tag":74,"props":1093,"children":1094},{"style":86},[1095],{"type":28,"value":1096},"session ",{"type":23,"tag":74,"props":1098,"children":1099},{"style":906},[1100],{"type":28,"value":1043},{"type":23,"tag":74,"props":1102,"children":1103},{"style":86},[1104],{"type":28,"value":1105}," Session()\n",{"type":23,"tag":31,"props":1107,"children":1109},{"id":1108},"paso-3-obtener-esquema-de-la-base-de-datos",[1110],{"type":28,"value":1111},"Paso 3: Obtener esquema de la base de datos",{"type":23,"tag":24,"props":1113,"children":1114},{},[1115],{"type":28,"value":1116},"Genera una descripción del esquema que será utilizada por GPT:",{"type":23,"tag":64,"props":1118,"children":1120},{"className":894,"code":1119,"language":896,"meta":7,"style":7},"from sqlalchemy import inspect\n\ndef get_database_schema(engine):\n    inspector = inspect(engine)\n    schema_description = \"\"\n    for table_name in inspector.get_table_names():\n        schema_description += f\"Table: {table_name}\\n\"\n        for column in inspector.get_columns(table_name):\n            schema_description += f\"- {column['name']} ({column['type']})\\n\"\n        schema_description += \"\\n\"\n    return schema_description\n\nschema_description = get_database_schema(engine)\nprint(schema_description)\n",[1121],{"type":23,"tag":14,"props":1122,"children":1123},{"__ignoreMap":7},[1124,1144,1151,1169,1186,1203,1226,1269,1291,1376,1400,1413,1420,1437],{"type":23,"tag":74,"props":1125,"children":1126},{"class":76,"line":77},[1127,1131,1135,1139],{"type":23,"tag":74,"props":1128,"children":1129},{"style":906},[1130],{"type":28,"value":909},{"type":23,"tag":74,"props":1132,"children":1133},{"style":86},[1134],{"type":28,"value":914},{"type":23,"tag":74,"props":1136,"children":1137},{"style":906},[1138],{"type":28,"value":919},{"type":23,"tag":74,"props":1140,"children":1141},{"style":86},[1142],{"type":28,"value":1143}," inspect\n",{"type":23,"tag":74,"props":1145,"children":1146},{"class":76,"line":98},[1147],{"type":23,"tag":74,"props":1148,"children":1149},{"emptyLinePlaceholder":984},[1150],{"type":28,"value":987},{"type":23,"tag":74,"props":1152,"children":1153},{"class":76,"line":112},[1154,1159,1164],{"type":23,"tag":74,"props":1155,"children":1156},{"style":906},[1157],{"type":28,"value":1158},"def",{"type":23,"tag":74,"props":1160,"children":1161},{"style":823},[1162],{"type":28,"value":1163}," get_database_schema",{"type":23,"tag":74,"props":1165,"children":1166},{"style":86},[1167],{"type":28,"value":1168},"(engine):\n",{"type":23,"tag":74,"props":1170,"children":1171},{"class":76,"line":131},[1172,1177,1181],{"type":23,"tag":74,"props":1173,"children":1174},{"style":86},[1175],{"type":28,"value":1176},"    inspector ",{"type":23,"tag":74,"props":1178,"children":1179},{"style":906},[1180],{"type":28,"value":1043},{"type":23,"tag":74,"props":1182,"children":1183},{"style":86},[1184],{"type":28,"value":1185}," inspect(engine)\n",{"type":23,"tag":74,"props":1187,"children":1188},{"class":76,"line":149},[1189,1194,1198],{"type":23,"tag":74,"props":1190,"children":1191},{"style":86},[1192],{"type":28,"value":1193},"    schema_description ",{"type":23,"tag":74,"props":1195,"children":1196},{"style":906},[1197],{"type":28,"value":1043},{"type":23,"tag":74,"props":1199,"children":1200},{"style":125},[1201],{"type":28,"value":1202}," \"\"\n",{"type":23,"tag":74,"props":1204,"children":1205},{"class":76,"line":162},[1206,1211,1216,1221],{"type":23,"tag":74,"props":1207,"children":1208},{"style":906},[1209],{"type":28,"value":1210},"    for",{"type":23,"tag":74,"props":1212,"children":1213},{"style":86},[1214],{"type":28,"value":1215}," table_name ",{"type":23,"tag":74,"props":1217,"children":1218},{"style":906},[1219],{"type":28,"value":1220},"in",{"type":23,"tag":74,"props":1222,"children":1223},{"style":86},[1224],{"type":28,"value":1225}," inspector.get_table_names():\n",{"type":23,"tag":74,"props":1227,"children":1228},{"class":76,"line":175},[1229,1234,1239,1244,1249,1254,1259,1264],{"type":23,"tag":74,"props":1230,"children":1231},{"style":86},[1232],{"type":28,"value":1233},"        schema_description ",{"type":23,"tag":74,"props":1235,"children":1236},{"style":906},[1237],{"type":28,"value":1238},"+=",{"type":23,"tag":74,"props":1240,"children":1241},{"style":906},[1242],{"type":28,"value":1243}," f",{"type":23,"tag":74,"props":1245,"children":1246},{"style":125},[1247],{"type":28,"value":1248},"\"Table: ",{"type":23,"tag":74,"props":1250,"children":1251},{"style":92},[1252],{"type":28,"value":1253},"{",{"type":23,"tag":74,"props":1255,"children":1256},{"style":86},[1257],{"type":28,"value":1258},"table_name",{"type":23,"tag":74,"props":1260,"children":1261},{"style":92},[1262],{"type":28,"value":1263},"}\\n",{"type":23,"tag":74,"props":1265,"children":1266},{"style":125},[1267],{"type":28,"value":1268},"\"\n",{"type":23,"tag":74,"props":1270,"children":1271},{"class":76,"line":188},[1272,1277,1282,1286],{"type":23,"tag":74,"props":1273,"children":1274},{"style":906},[1275],{"type":28,"value":1276},"        for",{"type":23,"tag":74,"props":1278,"children":1279},{"style":86},[1280],{"type":28,"value":1281}," column ",{"type":23,"tag":74,"props":1283,"children":1284},{"style":906},[1285],{"type":28,"value":1220},{"type":23,"tag":74,"props":1287,"children":1288},{"style":86},[1289],{"type":28,"value":1290}," inspector.get_columns(table_name):\n",{"type":23,"tag":74,"props":1292,"children":1293},{"class":76,"line":206},[1294,1299,1303,1307,1312,1316,1321,1326,1331,1336,1341,1345,1349,1354,1358,1362,1367,1372],{"type":23,"tag":74,"props":1295,"children":1296},{"style":86},[1297],{"type":28,"value":1298},"            schema_description ",{"type":23,"tag":74,"props":1300,"children":1301},{"style":906},[1302],{"type":28,"value":1238},{"type":23,"tag":74,"props":1304,"children":1305},{"style":906},[1306],{"type":28,"value":1243},{"type":23,"tag":74,"props":1308,"children":1309},{"style":125},[1310],{"type":28,"value":1311},"\"- ",{"type":23,"tag":74,"props":1313,"children":1314},{"style":92},[1315],{"type":28,"value":1253},{"type":23,"tag":74,"props":1317,"children":1318},{"style":86},[1319],{"type":28,"value":1320},"column[",{"type":23,"tag":74,"props":1322,"children":1323},{"style":125},[1324],{"type":28,"value":1325},"'name'",{"type":23,"tag":74,"props":1327,"children":1328},{"style":86},[1329],{"type":28,"value":1330},"]",{"type":23,"tag":74,"props":1332,"children":1333},{"style":92},[1334],{"type":28,"value":1335},"}",{"type":23,"tag":74,"props":1337,"children":1338},{"style":125},[1339],{"type":28,"value":1340}," (",{"type":23,"tag":74,"props":1342,"children":1343},{"style":92},[1344],{"type":28,"value":1253},{"type":23,"tag":74,"props":1346,"children":1347},{"style":86},[1348],{"type":28,"value":1320},{"type":23,"tag":74,"props":1350,"children":1351},{"style":125},[1352],{"type":28,"value":1353},"'type'",{"type":23,"tag":74,"props":1355,"children":1356},{"style":86},[1357],{"type":28,"value":1330},{"type":23,"tag":74,"props":1359,"children":1360},{"style":92},[1361],{"type":28,"value":1335},{"type":23,"tag":74,"props":1363,"children":1364},{"style":125},[1365],{"type":28,"value":1366},")",{"type":23,"tag":74,"props":1368,"children":1369},{"style":92},[1370],{"type":28,"value":1371},"\\n",{"type":23,"tag":74,"props":1373,"children":1374},{"style":125},[1375],{"type":28,"value":1268},{"type":23,"tag":74,"props":1377,"children":1378},{"class":76,"line":219},[1379,1383,1387,1392,1396],{"type":23,"tag":74,"props":1380,"children":1381},{"style":86},[1382],{"type":28,"value":1233},{"type":23,"tag":74,"props":1384,"children":1385},{"style":906},[1386],{"type":28,"value":1238},{"type":23,"tag":74,"props":1388,"children":1389},{"style":125},[1390],{"type":28,"value":1391}," \"",{"type":23,"tag":74,"props":1393,"children":1394},{"style":92},[1395],{"type":28,"value":1371},{"type":23,"tag":74,"props":1397,"children":1398},{"style":125},[1399],{"type":28,"value":1268},{"type":23,"tag":74,"props":1401,"children":1402},{"class":76,"line":232},[1403,1408],{"type":23,"tag":74,"props":1404,"children":1405},{"style":906},[1406],{"type":28,"value":1407},"    return",{"type":23,"tag":74,"props":1409,"children":1410},{"style":86},[1411],{"type":28,"value":1412}," schema_description\n",{"type":23,"tag":74,"props":1414,"children":1415},{"class":76,"line":250},[1416],{"type":23,"tag":74,"props":1417,"children":1418},{"emptyLinePlaceholder":984},[1419],{"type":28,"value":987},{"type":23,"tag":74,"props":1421,"children":1422},{"class":76,"line":263},[1423,1428,1432],{"type":23,"tag":74,"props":1424,"children":1425},{"style":86},[1426],{"type":28,"value":1427},"schema_description ",{"type":23,"tag":74,"props":1429,"children":1430},{"style":906},[1431],{"type":28,"value":1043},{"type":23,"tag":74,"props":1433,"children":1434},{"style":86},[1435],{"type":28,"value":1436}," get_database_schema(engine)\n",{"type":23,"tag":74,"props":1438,"children":1439},{"class":76,"line":276},[1440,1445],{"type":23,"tag":74,"props":1441,"children":1442},{"style":92},[1443],{"type":28,"value":1444},"print",{"type":23,"tag":74,"props":1446,"children":1447},{"style":86},[1448],{"type":28,"value":1449},"(schema_description)\n",{"type":23,"tag":31,"props":1451,"children":1453},{"id":1452},"paso-4-preparar-la-consulta-con-gpt",[1454],{"type":28,"value":1455},"Paso 4: Preparar la consulta con GPT",{"type":23,"tag":24,"props":1457,"children":1458},{},[1459],{"type":28,"value":1460},"Utiliza la API de OpenAI para transformar preguntas en consultas SQL, incluyendo el esquema de la base de datos:",{"type":23,"tag":64,"props":1462,"children":1464},{"className":894,"code":1463,"language":896,"meta":7,"style":7},"import openai\nimport os\n\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\n\ndef generate_sql(question, schema):\n    response = openai.ChatCompletion.create(\n        model=\"gpt-4\",\n        messages=[\n            {\"role\": \"system\", \"content\": f\"Convierte preguntas en lenguaje natural a consultas SQL. Esquema de la base de datos:\\n{schema}\"},\n            {\"role\": \"user\", \"content\": question}\n        ]\n    )\n    sql_query = response.choices[0].message.content.strip()\n    return sql_query\n\nquery = generate_sql(\"¿Cuántos usuarios se registraron el último mes?\", schema_description)\nprint(query)\n",[1465],{"type":23,"tag":14,"props":1466,"children":1467},{"__ignoreMap":7},[1468,1480,1491,1498,1523,1530,1547,1564,1586,1603,1673,1706,1714,1722,1749,1761,1768,1795],{"type":23,"tag":74,"props":1469,"children":1470},{"class":76,"line":77},[1471,1475],{"type":23,"tag":74,"props":1472,"children":1473},{"style":906},[1474],{"type":28,"value":919},{"type":23,"tag":74,"props":1476,"children":1477},{"style":86},[1478],{"type":28,"value":1479}," openai\n",{"type":23,"tag":74,"props":1481,"children":1482},{"class":76,"line":98},[1483,1487],{"type":23,"tag":74,"props":1484,"children":1485},{"style":906},[1486],{"type":28,"value":919},{"type":23,"tag":74,"props":1488,"children":1489},{"style":86},[1490],{"type":28,"value":957},{"type":23,"tag":74,"props":1492,"children":1493},{"class":76,"line":112},[1494],{"type":23,"tag":74,"props":1495,"children":1496},{"emptyLinePlaceholder":984},[1497],{"type":28,"value":987},{"type":23,"tag":74,"props":1499,"children":1500},{"class":76,"line":131},[1501,1506,1510,1514,1519],{"type":23,"tag":74,"props":1502,"children":1503},{"style":86},[1504],{"type":28,"value":1505},"openai.api_key ",{"type":23,"tag":74,"props":1507,"children":1508},{"style":906},[1509],{"type":28,"value":1043},{"type":23,"tag":74,"props":1511,"children":1512},{"style":86},[1513],{"type":28,"value":1020},{"type":23,"tag":74,"props":1515,"children":1516},{"style":125},[1517],{"type":28,"value":1518},"\"OPENAI_API_KEY\"",{"type":23,"tag":74,"props":1520,"children":1521},{"style":86},[1522],{"type":28,"value":1030},{"type":23,"tag":74,"props":1524,"children":1525},{"class":76,"line":149},[1526],{"type":23,"tag":74,"props":1527,"children":1528},{"emptyLinePlaceholder":984},[1529],{"type":28,"value":987},{"type":23,"tag":74,"props":1531,"children":1532},{"class":76,"line":162},[1533,1537,1542],{"type":23,"tag":74,"props":1534,"children":1535},{"style":906},[1536],{"type":28,"value":1158},{"type":23,"tag":74,"props":1538,"children":1539},{"style":823},[1540],{"type":28,"value":1541}," generate_sql",{"type":23,"tag":74,"props":1543,"children":1544},{"style":86},[1545],{"type":28,"value":1546},"(question, schema):\n",{"type":23,"tag":74,"props":1548,"children":1549},{"class":76,"line":175},[1550,1555,1559],{"type":23,"tag":74,"props":1551,"children":1552},{"style":86},[1553],{"type":28,"value":1554},"    response ",{"type":23,"tag":74,"props":1556,"children":1557},{"style":906},[1558],{"type":28,"value":1043},{"type":23,"tag":74,"props":1560,"children":1561},{"style":86},[1562],{"type":28,"value":1563}," openai.ChatCompletion.create(\n",{"type":23,"tag":74,"props":1565,"children":1566},{"class":76,"line":188},[1567,1572,1576,1581],{"type":23,"tag":74,"props":1568,"children":1569},{"style":1076},[1570],{"type":28,"value":1571},"        model",{"type":23,"tag":74,"props":1573,"children":1574},{"style":906},[1575],{"type":28,"value":1043},{"type":23,"tag":74,"props":1577,"children":1578},{"style":125},[1579],{"type":28,"value":1580},"\"gpt-4\"",{"type":23,"tag":74,"props":1582,"children":1583},{"style":86},[1584],{"type":28,"value":1585},",\n",{"type":23,"tag":74,"props":1587,"children":1588},{"class":76,"line":206},[1589,1594,1598],{"type":23,"tag":74,"props":1590,"children":1591},{"style":1076},[1592],{"type":28,"value":1593},"        messages",{"type":23,"tag":74,"props":1595,"children":1596},{"style":906},[1597],{"type":28,"value":1043},{"type":23,"tag":74,"props":1599,"children":1600},{"style":86},[1601],{"type":28,"value":1602},"[\n",{"type":23,"tag":74,"props":1604,"children":1605},{"class":76,"line":219},[1606,1611,1616,1620,1625,1630,1635,1639,1644,1649,1654,1659,1663,1668],{"type":23,"tag":74,"props":1607,"children":1608},{"style":86},[1609],{"type":28,"value":1610},"            {",{"type":23,"tag":74,"props":1612,"children":1613},{"style":125},[1614],{"type":28,"value":1615},"\"role\"",{"type":23,"tag":74,"props":1617,"children":1618},{"style":86},[1619],{"type":28,"value":89},{"type":23,"tag":74,"props":1621,"children":1622},{"style":125},[1623],{"type":28,"value":1624},"\"system\"",{"type":23,"tag":74,"props":1626,"children":1627},{"style":86},[1628],{"type":28,"value":1629},", ",{"type":23,"tag":74,"props":1631,"children":1632},{"style":125},[1633],{"type":28,"value":1634},"\"content\"",{"type":23,"tag":74,"props":1636,"children":1637},{"style":86},[1638],{"type":28,"value":89},{"type":23,"tag":74,"props":1640,"children":1641},{"style":906},[1642],{"type":28,"value":1643},"f",{"type":23,"tag":74,"props":1645,"children":1646},{"style":125},[1647],{"type":28,"value":1648},"\"Convierte preguntas en lenguaje natural a consultas SQL. Esquema de la base de datos:",{"type":23,"tag":74,"props":1650,"children":1651},{"style":92},[1652],{"type":28,"value":1653},"\\n{",{"type":23,"tag":74,"props":1655,"children":1656},{"style":86},[1657],{"type":28,"value":1658},"schema",{"type":23,"tag":74,"props":1660,"children":1661},{"style":92},[1662],{"type":28,"value":1335},{"type":23,"tag":74,"props":1664,"children":1665},{"style":125},[1666],{"type":28,"value":1667},"\"",{"type":23,"tag":74,"props":1669,"children":1670},{"style":86},[1671],{"type":28,"value":1672},"},\n",{"type":23,"tag":74,"props":1674,"children":1675},{"class":76,"line":232},[1676,1680,1684,1688,1693,1697,1701],{"type":23,"tag":74,"props":1677,"children":1678},{"style":86},[1679],{"type":28,"value":1610},{"type":23,"tag":74,"props":1681,"children":1682},{"style":125},[1683],{"type":28,"value":1615},{"type":23,"tag":74,"props":1685,"children":1686},{"style":86},[1687],{"type":28,"value":89},{"type":23,"tag":74,"props":1689,"children":1690},{"style":125},[1691],{"type":28,"value":1692},"\"user\"",{"type":23,"tag":74,"props":1694,"children":1695},{"style":86},[1696],{"type":28,"value":1629},{"type":23,"tag":74,"props":1698,"children":1699},{"style":125},[1700],{"type":28,"value":1634},{"type":23,"tag":74,"props":1702,"children":1703},{"style":86},[1704],{"type":28,"value":1705},": question}\n",{"type":23,"tag":74,"props":1707,"children":1708},{"class":76,"line":250},[1709],{"type":23,"tag":74,"props":1710,"children":1711},{"style":86},[1712],{"type":28,"value":1713},"        ]\n",{"type":23,"tag":74,"props":1715,"children":1716},{"class":76,"line":263},[1717],{"type":23,"tag":74,"props":1718,"children":1719},{"style":86},[1720],{"type":28,"value":1721},"    )\n",{"type":23,"tag":74,"props":1723,"children":1724},{"class":76,"line":276},[1725,1730,1734,1739,1744],{"type":23,"tag":74,"props":1726,"children":1727},{"style":86},[1728],{"type":28,"value":1729},"    sql_query ",{"type":23,"tag":74,"props":1731,"children":1732},{"style":906},[1733],{"type":28,"value":1043},{"type":23,"tag":74,"props":1735,"children":1736},{"style":86},[1737],{"type":28,"value":1738}," response.choices[",{"type":23,"tag":74,"props":1740,"children":1741},{"style":92},[1742],{"type":28,"value":1743},"0",{"type":23,"tag":74,"props":1745,"children":1746},{"style":86},[1747],{"type":28,"value":1748},"].message.content.strip()\n",{"type":23,"tag":74,"props":1750,"children":1751},{"class":76,"line":289},[1752,1756],{"type":23,"tag":74,"props":1753,"children":1754},{"style":906},[1755],{"type":28,"value":1407},{"type":23,"tag":74,"props":1757,"children":1758},{"style":86},[1759],{"type":28,"value":1760}," sql_query\n",{"type":23,"tag":74,"props":1762,"children":1763},{"class":76,"line":307},[1764],{"type":23,"tag":74,"props":1765,"children":1766},{"emptyLinePlaceholder":984},[1767],{"type":28,"value":987},{"type":23,"tag":74,"props":1769,"children":1770},{"class":76,"line":320},[1771,1776,1780,1785,1790],{"type":23,"tag":74,"props":1772,"children":1773},{"style":86},[1774],{"type":28,"value":1775},"query ",{"type":23,"tag":74,"props":1777,"children":1778},{"style":906},[1779],{"type":28,"value":1043},{"type":23,"tag":74,"props":1781,"children":1782},{"style":86},[1783],{"type":28,"value":1784}," generate_sql(",{"type":23,"tag":74,"props":1786,"children":1787},{"style":125},[1788],{"type":28,"value":1789},"\"¿Cuántos usuarios se registraron el último mes?\"",{"type":23,"tag":74,"props":1791,"children":1792},{"style":86},[1793],{"type":28,"value":1794},", schema_description)\n",{"type":23,"tag":74,"props":1796,"children":1797},{"class":76,"line":338},[1798,1802],{"type":23,"tag":74,"props":1799,"children":1800},{"style":92},[1801],{"type":28,"value":1444},{"type":23,"tag":74,"props":1803,"children":1804},{"style":86},[1805],{"type":28,"value":1806},"(query)\n",{"type":23,"tag":31,"props":1808,"children":1810},{"id":1809},"paso-5-ejecutar-consultas-generadas",[1811],{"type":28,"value":1812},"Paso 5: Ejecutar consultas generadas",{"type":23,"tag":24,"props":1814,"children":1815},{},[1816],{"type":28,"value":1817},"Ejecuta la consulta generada y obtiene resultados:",{"type":23,"tag":64,"props":1819,"children":1821},{"className":894,"code":1820,"language":896,"meta":7,"style":7},"result = session.execute(query)\nfor row in result:\n    print(row)\n",[1822],{"type":23,"tag":14,"props":1823,"children":1824},{"__ignoreMap":7},[1825,1842,1864],{"type":23,"tag":74,"props":1826,"children":1827},{"class":76,"line":77},[1828,1833,1837],{"type":23,"tag":74,"props":1829,"children":1830},{"style":86},[1831],{"type":28,"value":1832},"result ",{"type":23,"tag":74,"props":1834,"children":1835},{"style":906},[1836],{"type":28,"value":1043},{"type":23,"tag":74,"props":1838,"children":1839},{"style":86},[1840],{"type":28,"value":1841}," session.execute(query)\n",{"type":23,"tag":74,"props":1843,"children":1844},{"class":76,"line":98},[1845,1850,1855,1859],{"type":23,"tag":74,"props":1846,"children":1847},{"style":906},[1848],{"type":28,"value":1849},"for",{"type":23,"tag":74,"props":1851,"children":1852},{"style":86},[1853],{"type":28,"value":1854}," row ",{"type":23,"tag":74,"props":1856,"children":1857},{"style":906},[1858],{"type":28,"value":1220},{"type":23,"tag":74,"props":1860,"children":1861},{"style":86},[1862],{"type":28,"value":1863}," result:\n",{"type":23,"tag":74,"props":1865,"children":1866},{"class":76,"line":112},[1867,1872],{"type":23,"tag":74,"props":1868,"children":1869},{"style":92},[1870],{"type":28,"value":1871},"    print",{"type":23,"tag":74,"props":1873,"children":1874},{"style":86},[1875],{"type":28,"value":1876},"(row)\n",{"type":23,"tag":31,"props":1878,"children":1880},{"id":1879},"paso-6-manejo-de-errores-y-seguridad",[1881],{"type":28,"value":1882},"Paso 6: Manejo de errores y seguridad",{"type":23,"tag":24,"props":1884,"children":1885},{},[1886],{"type":28,"value":1887},"Para evitar problemas con consultas inseguras o errores, siempre valida las consultas generadas por GPT antes de ejecutarlas directamente:",{"type":23,"tag":64,"props":1889,"children":1891},{"className":894,"code":1890,"language":896,"meta":7,"style":7},"def execute_safe_query(sql_query):\n    try:\n        result = session.execute(sql_query)\n        return result.fetchall()\n    except Exception as e:\n        print(f\"Error al ejecutar consulta: {e}\")\n        return None\n\nresults = execute_safe_query(query)\nprint(results)\n",[1892],{"type":23,"tag":14,"props":1893,"children":1894},{"__ignoreMap":7},[1895,1912,1924,1941,1954,1977,2020,2032,2039,2056],{"type":23,"tag":74,"props":1896,"children":1897},{"class":76,"line":77},[1898,1902,1907],{"type":23,"tag":74,"props":1899,"children":1900},{"style":906},[1901],{"type":28,"value":1158},{"type":23,"tag":74,"props":1903,"children":1904},{"style":823},[1905],{"type":28,"value":1906}," execute_safe_query",{"type":23,"tag":74,"props":1908,"children":1909},{"style":86},[1910],{"type":28,"value":1911},"(sql_query):\n",{"type":23,"tag":74,"props":1913,"children":1914},{"class":76,"line":98},[1915,1920],{"type":23,"tag":74,"props":1916,"children":1917},{"style":906},[1918],{"type":28,"value":1919},"    try",{"type":23,"tag":74,"props":1921,"children":1922},{"style":86},[1923],{"type":28,"value":109},{"type":23,"tag":74,"props":1925,"children":1926},{"class":76,"line":112},[1927,1932,1936],{"type":23,"tag":74,"props":1928,"children":1929},{"style":86},[1930],{"type":28,"value":1931},"        result ",{"type":23,"tag":74,"props":1933,"children":1934},{"style":906},[1935],{"type":28,"value":1043},{"type":23,"tag":74,"props":1937,"children":1938},{"style":86},[1939],{"type":28,"value":1940}," session.execute(sql_query)\n",{"type":23,"tag":74,"props":1942,"children":1943},{"class":76,"line":131},[1944,1949],{"type":23,"tag":74,"props":1945,"children":1946},{"style":906},[1947],{"type":28,"value":1948},"        return",{"type":23,"tag":74,"props":1950,"children":1951},{"style":86},[1952],{"type":28,"value":1953}," result.fetchall()\n",{"type":23,"tag":74,"props":1955,"children":1956},{"class":76,"line":149},[1957,1962,1967,1972],{"type":23,"tag":74,"props":1958,"children":1959},{"style":906},[1960],{"type":28,"value":1961},"    except",{"type":23,"tag":74,"props":1963,"children":1964},{"style":92},[1965],{"type":28,"value":1966}," Exception",{"type":23,"tag":74,"props":1968,"children":1969},{"style":906},[1970],{"type":28,"value":1971}," as",{"type":23,"tag":74,"props":1973,"children":1974},{"style":86},[1975],{"type":28,"value":1976}," e:\n",{"type":23,"tag":74,"props":1978,"children":1979},{"class":76,"line":162},[1980,1985,1990,1994,1999,2003,2008,2012,2016],{"type":23,"tag":74,"props":1981,"children":1982},{"style":92},[1983],{"type":28,"value":1984},"        print",{"type":23,"tag":74,"props":1986,"children":1987},{"style":86},[1988],{"type":28,"value":1989},"(",{"type":23,"tag":74,"props":1991,"children":1992},{"style":906},[1993],{"type":28,"value":1643},{"type":23,"tag":74,"props":1995,"children":1996},{"style":125},[1997],{"type":28,"value":1998},"\"Error al ejecutar consulta: ",{"type":23,"tag":74,"props":2000,"children":2001},{"style":92},[2002],{"type":28,"value":1253},{"type":23,"tag":74,"props":2004,"children":2005},{"style":86},[2006],{"type":28,"value":2007},"e",{"type":23,"tag":74,"props":2009,"children":2010},{"style":92},[2011],{"type":28,"value":1335},{"type":23,"tag":74,"props":2013,"children":2014},{"style":125},[2015],{"type":28,"value":1667},{"type":23,"tag":74,"props":2017,"children":2018},{"style":86},[2019],{"type":28,"value":1030},{"type":23,"tag":74,"props":2021,"children":2022},{"class":76,"line":175},[2023,2027],{"type":23,"tag":74,"props":2024,"children":2025},{"style":906},[2026],{"type":28,"value":1948},{"type":23,"tag":74,"props":2028,"children":2029},{"style":92},[2030],{"type":28,"value":2031}," None\n",{"type":23,"tag":74,"props":2033,"children":2034},{"class":76,"line":188},[2035],{"type":23,"tag":74,"props":2036,"children":2037},{"emptyLinePlaceholder":984},[2038],{"type":28,"value":987},{"type":23,"tag":74,"props":2040,"children":2041},{"class":76,"line":206},[2042,2047,2051],{"type":23,"tag":74,"props":2043,"children":2044},{"style":86},[2045],{"type":28,"value":2046},"results ",{"type":23,"tag":74,"props":2048,"children":2049},{"style":906},[2050],{"type":28,"value":1043},{"type":23,"tag":74,"props":2052,"children":2053},{"style":86},[2054],{"type":28,"value":2055}," execute_safe_query(query)\n",{"type":23,"tag":74,"props":2057,"children":2058},{"class":76,"line":219},[2059,2063],{"type":23,"tag":74,"props":2060,"children":2061},{"style":92},[2062],{"type":28,"value":1444},{"type":23,"tag":74,"props":2064,"children":2065},{"style":86},[2066],{"type":28,"value":2067},"(results)\n",{"type":23,"tag":31,"props":2069,"children":2071},{"id":2070},"buenas-prácticas",[2072],{"type":28,"value":2073},"Buenas prácticas",{"type":23,"tag":779,"props":2075,"children":2076},{},[2077,2082,2087],{"type":23,"tag":783,"props":2078,"children":2079},{},[2080],{"type":28,"value":2081},"Siempre revisa o limita el acceso de los usuarios a consultas críticas o sensibles.",{"type":23,"tag":783,"props":2083,"children":2084},{},[2085],{"type":28,"value":2086},"Implementa validaciones adicionales para asegurar la integridad y seguridad de tu base de datos.",{"type":23,"tag":783,"props":2088,"children":2089},{},[2090],{"type":28,"value":2091},"Utiliza tokens y modelos específicos de OpenAI optimizados para tareas SQL.",{"type":23,"tag":31,"props":2093,"children":2095},{"id":2094},"conclusión",[2096],{"type":28,"value":2097},"Conclusión",{"type":23,"tag":24,"props":2099,"children":2100},{},[2101],{"type":28,"value":2102},"Utilizar GPT para transformar consultas en lenguaje natural a SQL facilita enormemente la accesibilidad a los datos. Implementando este sistema, podrás ofrecer una experiencia de usuario más amigable y eficiente.",{"type":23,"tag":2104,"props":2105,"children":2107},"h1",{"id":2106},"recursos-adicionales",[2108],{"type":28,"value":2109},"Recursos adicionales",{"type":23,"tag":779,"props":2111,"children":2112},{},[2113,2125,2135],{"type":23,"tag":783,"props":2114,"children":2115},{},[2116],{"type":23,"tag":2117,"props":2118,"children":2122},"a",{"href":2119,"rel":2120},"https://platform.openai.com/docs/api-reference",[2121],"nofollow",[2123],{"type":28,"value":2124},"Documentación API OpenAI",{"type":23,"tag":783,"props":2126,"children":2127},{},[2128],{"type":23,"tag":2117,"props":2129,"children":2132},{"href":2130,"rel":2131},"https://docs.sqlalchemy.org/en/20/",[2121],[2133],{"type":28,"value":2134},"SQLAlchemy ORM Documentation",{"type":23,"tag":783,"props":2136,"children":2137},{},[2138],{"type":23,"tag":2117,"props":2139,"children":2142},{"href":2140,"rel":2141},"https://pypi.org/project/python-dotenv/",[2121],[2143],{"type":28,"value":2144},"Python Dotenv",{"type":23,"tag":731,"props":2146,"children":2147},{},[2148],{"type":28,"value":735},{"title":7,"searchDepth":98,"depth":98,"links":2150},[2151,2152,2153,2154,2155,2156,2157,2158,2159],{"id":774,"depth":98,"text":777},{"id":800,"depth":98,"text":803},{"id":883,"depth":98,"text":886},{"id":1108,"depth":98,"text":1111},{"id":1452,"depth":98,"text":1455},{"id":1809,"depth":98,"text":1812},{"id":1879,"depth":98,"text":1882},{"id":2070,"depth":98,"text":2073},{"id":2094,"depth":98,"text":2097},"content:posts:gpt-sql-integration.md","posts/gpt-sql-integration.md","posts/gpt-sql-integration",{"_path":2164,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":2165,"description":2166,"date":2167,"layout":11,"subtitle":2168,"image":2169,"optimized_image":2169,"category":14,"tags":2170,"author":18,"paginate":6,"body":2175,"_type":741,"_id":3067,"_source":743,"_file":3068,"_stem":3069,"_extension":746},"/posts/java-security-best-practices","Java Security Best Practices: Preventing Vulnerabilities and Threats","Explore essential security strategies for Java applications, addressing common vulnerabilities identified by OWASP Top 10 with practical examples.","2024-08-15T11:00:00.000Z","Practical Strategies to Safeguard Your Java Applications","/assets/img/uploads/java-security-best-practices.png",[14,2171,2172,2173,2174],"java","security","owasp","cybersecurity",{"type":20,"children":2176,"toc":3055},[2177,2185,2191,2196,2250,2255,2261,2266,2389,2394,2400,2405,2508,2514,2519,2642,2647,2653,2658,2683,2688,2694,2699,2715,2720,2726,2731,2814,2819,2825,2830,2949,2954,2960,2965,2998,3003,3007,3012,3018,3051],{"type":23,"tag":764,"props":2178,"children":2179},{},[2180],{"type":23,"tag":24,"props":2181,"children":2182},{},[2183],{"type":28,"value":2184},"Security is critical in software development. Java applications, like all software, face numerous potential vulnerabilities. In this article, we will explore essential security best practices, referencing the OWASP Top 10, and providing practical Java examples to help you protect your applications effectively.",{"type":23,"tag":31,"props":2186,"children":2188},{"id":2187},"understanding-owasp-top-10",[2189],{"type":28,"value":2190},"Understanding OWASP Top 10",{"type":23,"tag":24,"props":2192,"children":2193},{},[2194],{"type":28,"value":2195},"The OWASP Top 10 outlines the most critical web application security risks:",{"type":23,"tag":2197,"props":2198,"children":2199},"ol",{},[2200,2205,2210,2215,2220,2225,2230,2235,2240,2245],{"type":23,"tag":783,"props":2201,"children":2202},{},[2203],{"type":28,"value":2204},"Injection",{"type":23,"tag":783,"props":2206,"children":2207},{},[2208],{"type":28,"value":2209},"Broken Authentication",{"type":23,"tag":783,"props":2211,"children":2212},{},[2213],{"type":28,"value":2214},"Sensitive Data Exposure",{"type":23,"tag":783,"props":2216,"children":2217},{},[2218],{"type":28,"value":2219},"XML External Entities (XXE)",{"type":23,"tag":783,"props":2221,"children":2222},{},[2223],{"type":28,"value":2224},"Broken Access Control",{"type":23,"tag":783,"props":2226,"children":2227},{},[2228],{"type":28,"value":2229},"Security Misconfiguration",{"type":23,"tag":783,"props":2231,"children":2232},{},[2233],{"type":28,"value":2234},"Cross-Site Scripting (XSS)",{"type":23,"tag":783,"props":2236,"children":2237},{},[2238],{"type":28,"value":2239},"Insecure Deserialization",{"type":23,"tag":783,"props":2241,"children":2242},{},[2243],{"type":28,"value":2244},"Using Components with Known Vulnerabilities",{"type":23,"tag":783,"props":2246,"children":2247},{},[2248],{"type":28,"value":2249},"Insufficient Logging and Monitoring",{"type":23,"tag":24,"props":2251,"children":2252},{},[2253],{"type":28,"value":2254},"Let's delve into practical strategies and Java implementations for some of these threats.",{"type":23,"tag":31,"props":2256,"children":2258},{"id":2257},"_1-injection-prevention",[2259],{"type":28,"value":2260},"1. Injection Prevention",{"type":23,"tag":24,"props":2262,"children":2263},{},[2264],{"type":28,"value":2265},"Use Prepared Statements and parameterized queries:",{"type":23,"tag":64,"props":2267,"children":2270},{"className":2268,"code":2269,"language":2171,"meta":7,"style":7},"language-java shiki shiki-themes github-dark github-light","PreparedStatement stmt = connection.prepareStatement(\"SELECT * FROM users WHERE username=? AND password=?\");\nstmt.setString(1, username);\nstmt.setString(2, password);\nResultSet rs = stmt.executeQuery();\n",[2271],{"type":23,"tag":14,"props":2272,"children":2273},{"__ignoreMap":7},[2274,2310,2337,2362],{"type":23,"tag":74,"props":2275,"children":2276},{"class":76,"line":77},[2277,2282,2286,2291,2296,2300,2305],{"type":23,"tag":74,"props":2278,"children":2279},{"style":86},[2280],{"type":28,"value":2281},"PreparedStatement stmt ",{"type":23,"tag":74,"props":2283,"children":2284},{"style":906},[2285],{"type":28,"value":1043},{"type":23,"tag":74,"props":2287,"children":2288},{"style":86},[2289],{"type":28,"value":2290}," connection.",{"type":23,"tag":74,"props":2292,"children":2293},{"style":823},[2294],{"type":28,"value":2295},"prepareStatement",{"type":23,"tag":74,"props":2297,"children":2298},{"style":86},[2299],{"type":28,"value":1989},{"type":23,"tag":74,"props":2301,"children":2302},{"style":125},[2303],{"type":28,"value":2304},"\"SELECT * FROM users WHERE username=? AND password=?\"",{"type":23,"tag":74,"props":2306,"children":2307},{"style":86},[2308],{"type":28,"value":2309},");\n",{"type":23,"tag":74,"props":2311,"children":2312},{"class":76,"line":98},[2313,2318,2323,2327,2332],{"type":23,"tag":74,"props":2314,"children":2315},{"style":86},[2316],{"type":28,"value":2317},"stmt.",{"type":23,"tag":74,"props":2319,"children":2320},{"style":823},[2321],{"type":28,"value":2322},"setString",{"type":23,"tag":74,"props":2324,"children":2325},{"style":86},[2326],{"type":28,"value":1989},{"type":23,"tag":74,"props":2328,"children":2329},{"style":92},[2330],{"type":28,"value":2331},"1",{"type":23,"tag":74,"props":2333,"children":2334},{"style":86},[2335],{"type":28,"value":2336},", username);\n",{"type":23,"tag":74,"props":2338,"children":2339},{"class":76,"line":112},[2340,2344,2348,2352,2357],{"type":23,"tag":74,"props":2341,"children":2342},{"style":86},[2343],{"type":28,"value":2317},{"type":23,"tag":74,"props":2345,"children":2346},{"style":823},[2347],{"type":28,"value":2322},{"type":23,"tag":74,"props":2349,"children":2350},{"style":86},[2351],{"type":28,"value":1989},{"type":23,"tag":74,"props":2353,"children":2354},{"style":92},[2355],{"type":28,"value":2356},"2",{"type":23,"tag":74,"props":2358,"children":2359},{"style":86},[2360],{"type":28,"value":2361},", password);\n",{"type":23,"tag":74,"props":2363,"children":2364},{"class":76,"line":131},[2365,2370,2374,2379,2384],{"type":23,"tag":74,"props":2366,"children":2367},{"style":86},[2368],{"type":28,"value":2369},"ResultSet rs ",{"type":23,"tag":74,"props":2371,"children":2372},{"style":906},[2373],{"type":28,"value":1043},{"type":23,"tag":74,"props":2375,"children":2376},{"style":86},[2377],{"type":28,"value":2378}," stmt.",{"type":23,"tag":74,"props":2380,"children":2381},{"style":823},[2382],{"type":28,"value":2383},"executeQuery",{"type":23,"tag":74,"props":2385,"children":2386},{"style":86},[2387],{"type":28,"value":2388},"();\n",{"type":23,"tag":24,"props":2390,"children":2391},{},[2392],{"type":28,"value":2393},"This approach prevents SQL injection by ensuring that input data is treated as data, not executable code.",{"type":23,"tag":31,"props":2395,"children":2397},{"id":2396},"_2-secure-authentication",[2398],{"type":28,"value":2399},"2. Secure Authentication",{"type":23,"tag":24,"props":2401,"children":2402},{},[2403],{"type":28,"value":2404},"Implement robust authentication using secure password storage (bcrypt or Argon2):",{"type":23,"tag":64,"props":2406,"children":2408},{"className":2268,"code":2407,"language":2171,"meta":7,"style":7},"import org.springframework.security.crypto.bcrypt.BCrypt;\n\nString hashedPassword = BCrypt.hashpw(password, BCrypt.gensalt());\nif (BCrypt.checkpw(password, hashedPassword)) {\n    // authentication successful\n}\n",[2409],{"type":23,"tag":14,"props":2410,"children":2411},{"__ignoreMap":7},[2412,2424,2431,2468,2491,2500],{"type":23,"tag":74,"props":2413,"children":2414},{"class":76,"line":77},[2415,2419],{"type":23,"tag":74,"props":2416,"children":2417},{"style":906},[2418],{"type":28,"value":919},{"type":23,"tag":74,"props":2420,"children":2421},{"style":86},[2422],{"type":28,"value":2423}," org.springframework.security.crypto.bcrypt.BCrypt;\n",{"type":23,"tag":74,"props":2425,"children":2426},{"class":76,"line":98},[2427],{"type":23,"tag":74,"props":2428,"children":2429},{"emptyLinePlaceholder":984},[2430],{"type":28,"value":987},{"type":23,"tag":74,"props":2432,"children":2433},{"class":76,"line":112},[2434,2439,2443,2448,2453,2458,2463],{"type":23,"tag":74,"props":2435,"children":2436},{"style":86},[2437],{"type":28,"value":2438},"String hashedPassword ",{"type":23,"tag":74,"props":2440,"children":2441},{"style":906},[2442],{"type":28,"value":1043},{"type":23,"tag":74,"props":2444,"children":2445},{"style":86},[2446],{"type":28,"value":2447}," BCrypt.",{"type":23,"tag":74,"props":2449,"children":2450},{"style":823},[2451],{"type":28,"value":2452},"hashpw",{"type":23,"tag":74,"props":2454,"children":2455},{"style":86},[2456],{"type":28,"value":2457},"(password, BCrypt.",{"type":23,"tag":74,"props":2459,"children":2460},{"style":823},[2461],{"type":28,"value":2462},"gensalt",{"type":23,"tag":74,"props":2464,"children":2465},{"style":86},[2466],{"type":28,"value":2467},"());\n",{"type":23,"tag":74,"props":2469,"children":2470},{"class":76,"line":131},[2471,2476,2481,2486],{"type":23,"tag":74,"props":2472,"children":2473},{"style":906},[2474],{"type":28,"value":2475},"if",{"type":23,"tag":74,"props":2477,"children":2478},{"style":86},[2479],{"type":28,"value":2480}," (BCrypt.",{"type":23,"tag":74,"props":2482,"children":2483},{"style":823},[2484],{"type":28,"value":2485},"checkpw",{"type":23,"tag":74,"props":2487,"children":2488},{"style":86},[2489],{"type":28,"value":2490},"(password, hashedPassword)) {\n",{"type":23,"tag":74,"props":2492,"children":2493},{"class":76,"line":149},[2494],{"type":23,"tag":74,"props":2495,"children":2497},{"style":2496},"--shiki-default:#6A737D;--shiki-light:#6A737D",[2498],{"type":28,"value":2499},"    // authentication successful\n",{"type":23,"tag":74,"props":2501,"children":2502},{"class":76,"line":162},[2503],{"type":23,"tag":74,"props":2504,"children":2505},{"style":86},[2506],{"type":28,"value":2507},"}\n",{"type":23,"tag":31,"props":2509,"children":2511},{"id":2510},"_3-sensitive-data-exposure",[2512],{"type":28,"value":2513},"3. Sensitive Data Exposure",{"type":23,"tag":24,"props":2515,"children":2516},{},[2517],{"type":28,"value":2518},"Use encryption for sensitive data storage:",{"type":23,"tag":64,"props":2520,"children":2522},{"className":2268,"code":2521,"language":2171,"meta":7,"style":7},"Cipher cipher = Cipher.getInstance(\"AES/GCM/NoPadding\");\nSecretKey key = generateSecretKey();\ncipher.init(Cipher.ENCRYPT_MODE, key);\nbyte[] encryptedData = cipher.doFinal(plainData.getBytes(StandardCharsets.UTF_8));\n",[2523],{"type":23,"tag":14,"props":2524,"children":2525},{"__ignoreMap":7},[2526,2561,2582,2600],{"type":23,"tag":74,"props":2527,"children":2528},{"class":76,"line":77},[2529,2534,2538,2543,2548,2552,2557],{"type":23,"tag":74,"props":2530,"children":2531},{"style":86},[2532],{"type":28,"value":2533},"Cipher cipher ",{"type":23,"tag":74,"props":2535,"children":2536},{"style":906},[2537],{"type":28,"value":1043},{"type":23,"tag":74,"props":2539,"children":2540},{"style":86},[2541],{"type":28,"value":2542}," Cipher.",{"type":23,"tag":74,"props":2544,"children":2545},{"style":823},[2546],{"type":28,"value":2547},"getInstance",{"type":23,"tag":74,"props":2549,"children":2550},{"style":86},[2551],{"type":28,"value":1989},{"type":23,"tag":74,"props":2553,"children":2554},{"style":125},[2555],{"type":28,"value":2556},"\"AES/GCM/NoPadding\"",{"type":23,"tag":74,"props":2558,"children":2559},{"style":86},[2560],{"type":28,"value":2309},{"type":23,"tag":74,"props":2562,"children":2563},{"class":76,"line":98},[2564,2569,2573,2578],{"type":23,"tag":74,"props":2565,"children":2566},{"style":86},[2567],{"type":28,"value":2568},"SecretKey key ",{"type":23,"tag":74,"props":2570,"children":2571},{"style":906},[2572],{"type":28,"value":1043},{"type":23,"tag":74,"props":2574,"children":2575},{"style":823},[2576],{"type":28,"value":2577}," generateSecretKey",{"type":23,"tag":74,"props":2579,"children":2580},{"style":86},[2581],{"type":28,"value":2388},{"type":23,"tag":74,"props":2583,"children":2584},{"class":76,"line":112},[2585,2590,2595],{"type":23,"tag":74,"props":2586,"children":2587},{"style":86},[2588],{"type":28,"value":2589},"cipher.",{"type":23,"tag":74,"props":2591,"children":2592},{"style":823},[2593],{"type":28,"value":2594},"init",{"type":23,"tag":74,"props":2596,"children":2597},{"style":86},[2598],{"type":28,"value":2599},"(Cipher.ENCRYPT_MODE, key);\n",{"type":23,"tag":74,"props":2601,"children":2602},{"class":76,"line":131},[2603,2608,2613,2617,2622,2627,2632,2637],{"type":23,"tag":74,"props":2604,"children":2605},{"style":906},[2606],{"type":28,"value":2607},"byte",{"type":23,"tag":74,"props":2609,"children":2610},{"style":86},[2611],{"type":28,"value":2612},"[] encryptedData ",{"type":23,"tag":74,"props":2614,"children":2615},{"style":906},[2616],{"type":28,"value":1043},{"type":23,"tag":74,"props":2618,"children":2619},{"style":86},[2620],{"type":28,"value":2621}," cipher.",{"type":23,"tag":74,"props":2623,"children":2624},{"style":823},[2625],{"type":28,"value":2626},"doFinal",{"type":23,"tag":74,"props":2628,"children":2629},{"style":86},[2630],{"type":28,"value":2631},"(plainData.",{"type":23,"tag":74,"props":2633,"children":2634},{"style":823},[2635],{"type":28,"value":2636},"getBytes",{"type":23,"tag":74,"props":2638,"children":2639},{"style":86},[2640],{"type":28,"value":2641},"(StandardCharsets.UTF_8));\n",{"type":23,"tag":24,"props":2643,"children":2644},{},[2645],{"type":28,"value":2646},"Always encrypt data at rest and in transit (use HTTPS).",{"type":23,"tag":31,"props":2648,"children":2650},{"id":2649},"_4-security-misconfiguration",[2651],{"type":28,"value":2652},"4. Security Misconfiguration",{"type":23,"tag":24,"props":2654,"children":2655},{},[2656],{"type":28,"value":2657},"Adopt secure defaults, disable debugging, and avoid detailed error messages:",{"type":23,"tag":64,"props":2659,"children":2663},{"className":2660,"code":2661,"language":2662,"meta":7,"style":7},"language-properties shiki shiki-themes github-dark github-light","server.error.include-stacktrace=never\nserver.error.include-message=never\n","properties",[2664],{"type":23,"tag":14,"props":2665,"children":2666},{"__ignoreMap":7},[2667,2675],{"type":23,"tag":74,"props":2668,"children":2669},{"class":76,"line":77},[2670],{"type":23,"tag":74,"props":2671,"children":2672},{},[2673],{"type":28,"value":2674},"server.error.include-stacktrace=never\n",{"type":23,"tag":74,"props":2676,"children":2677},{"class":76,"line":98},[2678],{"type":23,"tag":74,"props":2679,"children":2680},{},[2681],{"type":28,"value":2682},"server.error.include-message=never\n",{"type":23,"tag":24,"props":2684,"children":2685},{},[2686],{"type":28,"value":2687},"Review and secure your Java application configuration regularly.",{"type":23,"tag":31,"props":2689,"children":2691},{"id":2690},"_5-cross-site-scripting-xss",[2692],{"type":28,"value":2693},"5. Cross-Site Scripting (XSS)",{"type":23,"tag":24,"props":2695,"children":2696},{},[2697],{"type":28,"value":2698},"Utilize proper encoding or frameworks that prevent XSS by default, such as Thymeleaf:",{"type":23,"tag":64,"props":2700,"children":2704},{"className":2701,"code":2702,"language":2703,"meta":7,"style":7},"language-html shiki shiki-themes github-dark github-light","\u003Cp th:text=\"${userInput}\">\u003C/p>\n","html",[2705],{"type":23,"tag":14,"props":2706,"children":2707},{"__ignoreMap":7},[2708],{"type":23,"tag":74,"props":2709,"children":2710},{"class":76,"line":77},[2711],{"type":23,"tag":74,"props":2712,"children":2713},{},[2714],{"type":28,"value":2702},{"type":23,"tag":24,"props":2716,"children":2717},{},[2718],{"type":28,"value":2719},"Avoid directly inserting user inputs into HTML without proper sanitization or encoding.",{"type":23,"tag":31,"props":2721,"children":2723},{"id":2722},"_6-insecure-deserialization",[2724],{"type":28,"value":2725},"6. Insecure Deserialization",{"type":23,"tag":24,"props":2727,"children":2728},{},[2729],{"type":28,"value":2730},"Limit deserialization to trusted sources only:",{"type":23,"tag":64,"props":2732,"children":2734},{"className":2268,"code":2733,"language":2171,"meta":7,"style":7},"ObjectInputStream ois = new ObjectInputStream(new FileInputStream(\"trusted_data.ser\"));\nMyObject obj = (MyObject) ois.readObject();\n",[2735],{"type":23,"tag":14,"props":2736,"children":2737},{"__ignoreMap":7},[2738,2788],{"type":23,"tag":74,"props":2739,"children":2740},{"class":76,"line":77},[2741,2746,2750,2755,2760,2764,2769,2774,2778,2783],{"type":23,"tag":74,"props":2742,"children":2743},{"style":86},[2744],{"type":28,"value":2745},"ObjectInputStream ois ",{"type":23,"tag":74,"props":2747,"children":2748},{"style":906},[2749],{"type":28,"value":1043},{"type":23,"tag":74,"props":2751,"children":2752},{"style":906},[2753],{"type":28,"value":2754}," new",{"type":23,"tag":74,"props":2756,"children":2757},{"style":823},[2758],{"type":28,"value":2759}," ObjectInputStream",{"type":23,"tag":74,"props":2761,"children":2762},{"style":86},[2763],{"type":28,"value":1989},{"type":23,"tag":74,"props":2765,"children":2766},{"style":906},[2767],{"type":28,"value":2768},"new",{"type":23,"tag":74,"props":2770,"children":2771},{"style":823},[2772],{"type":28,"value":2773}," FileInputStream",{"type":23,"tag":74,"props":2775,"children":2776},{"style":86},[2777],{"type":28,"value":1989},{"type":23,"tag":74,"props":2779,"children":2780},{"style":125},[2781],{"type":28,"value":2782},"\"trusted_data.ser\"",{"type":23,"tag":74,"props":2784,"children":2785},{"style":86},[2786],{"type":28,"value":2787},"));\n",{"type":23,"tag":74,"props":2789,"children":2790},{"class":76,"line":98},[2791,2796,2800,2805,2810],{"type":23,"tag":74,"props":2792,"children":2793},{"style":86},[2794],{"type":28,"value":2795},"MyObject obj ",{"type":23,"tag":74,"props":2797,"children":2798},{"style":906},[2799],{"type":28,"value":1043},{"type":23,"tag":74,"props":2801,"children":2802},{"style":86},[2803],{"type":28,"value":2804}," (MyObject) ois.",{"type":23,"tag":74,"props":2806,"children":2807},{"style":823},[2808],{"type":28,"value":2809},"readObject",{"type":23,"tag":74,"props":2811,"children":2812},{"style":86},[2813],{"type":28,"value":2388},{"type":23,"tag":24,"props":2815,"children":2816},{},[2817],{"type":28,"value":2818},"Always validate deserialized data.",{"type":23,"tag":31,"props":2820,"children":2822},{"id":2821},"_7-component-vulnerabilities",[2823],{"type":28,"value":2824},"7. Component Vulnerabilities",{"type":23,"tag":24,"props":2826,"children":2827},{},[2828],{"type":28,"value":2829},"Regularly update libraries and dependencies, and use tools like OWASP Dependency-Check to identify vulnerabilities:",{"type":23,"tag":64,"props":2831,"children":2835},{"className":2832,"code":2833,"language":2834,"meta":7,"style":7},"language-xml shiki shiki-themes github-dark github-light","\u003Cplugin>\n    \u003CgroupId>org.owasp\u003C/groupId>\n    \u003CartifactId>dependency-check-maven\u003C/artifactId>\n    \u003Cversion>9.0.9\u003C/version>\n\u003C/plugin>\n","xml",[2836],{"type":23,"tag":14,"props":2837,"children":2838},{"__ignoreMap":7},[2839,2857,2883,2908,2933],{"type":23,"tag":74,"props":2840,"children":2841},{"class":76,"line":77},[2842,2847,2852],{"type":23,"tag":74,"props":2843,"children":2844},{"style":86},[2845],{"type":28,"value":2846},"\u003C",{"type":23,"tag":74,"props":2848,"children":2849},{"style":81},[2850],{"type":28,"value":2851},"plugin",{"type":23,"tag":74,"props":2853,"children":2854},{"style":86},[2855],{"type":28,"value":2856},">\n",{"type":23,"tag":74,"props":2858,"children":2859},{"class":76,"line":98},[2860,2865,2870,2875,2879],{"type":23,"tag":74,"props":2861,"children":2862},{"style":86},[2863],{"type":28,"value":2864},"    \u003C",{"type":23,"tag":74,"props":2866,"children":2867},{"style":81},[2868],{"type":28,"value":2869},"groupId",{"type":23,"tag":74,"props":2871,"children":2872},{"style":86},[2873],{"type":28,"value":2874},">org.owasp\u003C/",{"type":23,"tag":74,"props":2876,"children":2877},{"style":81},[2878],{"type":28,"value":2869},{"type":23,"tag":74,"props":2880,"children":2881},{"style":86},[2882],{"type":28,"value":2856},{"type":23,"tag":74,"props":2884,"children":2885},{"class":76,"line":112},[2886,2890,2895,2900,2904],{"type":23,"tag":74,"props":2887,"children":2888},{"style":86},[2889],{"type":28,"value":2864},{"type":23,"tag":74,"props":2891,"children":2892},{"style":81},[2893],{"type":28,"value":2894},"artifactId",{"type":23,"tag":74,"props":2896,"children":2897},{"style":86},[2898],{"type":28,"value":2899},">dependency-check-maven\u003C/",{"type":23,"tag":74,"props":2901,"children":2902},{"style":81},[2903],{"type":28,"value":2894},{"type":23,"tag":74,"props":2905,"children":2906},{"style":86},[2907],{"type":28,"value":2856},{"type":23,"tag":74,"props":2909,"children":2910},{"class":76,"line":131},[2911,2915,2920,2925,2929],{"type":23,"tag":74,"props":2912,"children":2913},{"style":86},[2914],{"type":28,"value":2864},{"type":23,"tag":74,"props":2916,"children":2917},{"style":81},[2918],{"type":28,"value":2919},"version",{"type":23,"tag":74,"props":2921,"children":2922},{"style":86},[2923],{"type":28,"value":2924},">9.0.9\u003C/",{"type":23,"tag":74,"props":2926,"children":2927},{"style":81},[2928],{"type":28,"value":2919},{"type":23,"tag":74,"props":2930,"children":2931},{"style":86},[2932],{"type":28,"value":2856},{"type":23,"tag":74,"props":2934,"children":2935},{"class":76,"line":149},[2936,2941,2945],{"type":23,"tag":74,"props":2937,"children":2938},{"style":86},[2939],{"type":28,"value":2940},"\u003C/",{"type":23,"tag":74,"props":2942,"children":2943},{"style":81},[2944],{"type":28,"value":2851},{"type":23,"tag":74,"props":2946,"children":2947},{"style":86},[2948],{"type":28,"value":2856},{"type":23,"tag":24,"props":2950,"children":2951},{},[2952],{"type":28,"value":2953},"Execute dependency checks regularly in your CI/CD pipeline.",{"type":23,"tag":31,"props":2955,"children":2957},{"id":2956},"_8-logging-and-monitoring",[2958],{"type":28,"value":2959},"8. Logging and Monitoring",{"type":23,"tag":24,"props":2961,"children":2962},{},[2963],{"type":28,"value":2964},"Implement comprehensive logging and monitoring to detect and respond to security incidents:",{"type":23,"tag":64,"props":2966,"children":2968},{"className":2268,"code":2967,"language":2171,"meta":7,"style":7},"logger.warn(\"Failed login attempt for user: {}\", username);\n",[2969],{"type":23,"tag":14,"props":2970,"children":2971},{"__ignoreMap":7},[2972],{"type":23,"tag":74,"props":2973,"children":2974},{"class":76,"line":77},[2975,2980,2985,2989,2994],{"type":23,"tag":74,"props":2976,"children":2977},{"style":86},[2978],{"type":28,"value":2979},"logger.",{"type":23,"tag":74,"props":2981,"children":2982},{"style":823},[2983],{"type":28,"value":2984},"warn",{"type":23,"tag":74,"props":2986,"children":2987},{"style":86},[2988],{"type":28,"value":1989},{"type":23,"tag":74,"props":2990,"children":2991},{"style":125},[2992],{"type":28,"value":2993},"\"Failed login attempt for user: {}\"",{"type":23,"tag":74,"props":2995,"children":2996},{"style":86},[2997],{"type":28,"value":2336},{"type":23,"tag":24,"props":2999,"children":3000},{},[3001],{"type":28,"value":3002},"Aggregate logs centrally, and set up alerts for suspicious activities.",{"type":23,"tag":31,"props":3004,"children":3005},{"id":716},[3006],{"type":28,"value":719},{"type":23,"tag":24,"props":3008,"children":3009},{},[3010],{"type":28,"value":3011},"Adopting these best practices can greatly enhance the security posture of your Java applications. Stay proactive by regularly reviewing security measures, updating dependencies, and monitoring your systems. Security is a continuous process, not a one-time setup.",{"type":23,"tag":2104,"props":3013,"children":3015},{"id":3014},"further-reading",[3016],{"type":28,"value":3017},"Further Reading",{"type":23,"tag":779,"props":3019,"children":3020},{},[3021,3031,3041],{"type":23,"tag":783,"props":3022,"children":3023},{},[3024],{"type":23,"tag":2117,"props":3025,"children":3028},{"href":3026,"rel":3027},"https://owasp.org/www-project-top-ten/",[2121],[3029],{"type":28,"value":3030},"OWASP Top 10",{"type":23,"tag":783,"props":3032,"children":3033},{},[3034],{"type":23,"tag":2117,"props":3035,"children":3038},{"href":3036,"rel":3037},"https://spring.io/projects/spring-security",[2121],[3039],{"type":28,"value":3040},"Spring Security",{"type":23,"tag":783,"props":3042,"children":3043},{},[3044],{"type":23,"tag":2117,"props":3045,"children":3048},{"href":3046,"rel":3047},"https://owasp.org/www-project-dependency-check/",[2121],[3049],{"type":28,"value":3050},"OWASP Dependency Check",{"type":23,"tag":731,"props":3052,"children":3053},{},[3054],{"type":28,"value":735},{"title":7,"searchDepth":98,"depth":98,"links":3056},[3057,3058,3059,3060,3061,3062,3063,3064,3065,3066],{"id":2187,"depth":98,"text":2190},{"id":2257,"depth":98,"text":2260},{"id":2396,"depth":98,"text":2399},{"id":2510,"depth":98,"text":2513},{"id":2649,"depth":98,"text":2652},{"id":2690,"depth":98,"text":2693},{"id":2722,"depth":98,"text":2725},{"id":2821,"depth":98,"text":2824},{"id":2956,"depth":98,"text":2959},{"id":716,"depth":98,"text":719},"content:posts:java-security-best-practices.md","posts/java-security-best-practices.md","posts/java-security-best-practices",{"_path":3071,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":3072,"description":3073,"date":3074,"layout":11,"subtitle":3075,"image":3076,"optimized_image":3076,"category":14,"tags":3077,"author":18,"paginate":6,"body":3081,"_type":741,"_id":3887,"_source":743,"_file":3888,"_stem":3889,"_extension":746},"/posts/circuit-breaking-resilience","Circuit Breaking in Distributed Systems","An expert guide to understanding and implementing circuit breakers in distributed systems, with practical Java examples using Resilience4j and best practices.","2024-07-15T11:00:00.000Z","Enhancing Resilience with Circuit Breaker Patterns","/assets/img/uploads/circuit-breaking-resilience.png",[14,2171,3078,3079,3080],"resilience","circuit-breaker","distributed-systems",{"type":20,"children":3082,"toc":3875},[3083,3091,3097,3102,3136,3141,3147,3152,3170,3176,3183,3188,3298,3304,3508,3514,3519,3686,3692,3697,3791,3796,3802,3825,3829,3834,3838,3871],{"type":23,"tag":764,"props":3084,"children":3085},{},[3086],{"type":23,"tag":24,"props":3087,"children":3088},{},[3089],{"type":28,"value":3090},"In modern distributed systems, failures are inevitable. The circuit breaker pattern helps maintain system stability by preventing failures from cascading across service boundaries. In this post, we'll dive deep into circuit breakers, explore their importance, and demonstrate practical implementation using Resilience4j in Java.",{"type":23,"tag":31,"props":3092,"children":3094},{"id":3093},"understanding-the-circuit-breaker-pattern",[3095],{"type":28,"value":3096},"Understanding the Circuit Breaker Pattern",{"type":23,"tag":24,"props":3098,"children":3099},{},[3100],{"type":28,"value":3101},"The circuit breaker pattern prevents a service from making repeated calls to an external service that is experiencing issues. It has three main states:",{"type":23,"tag":779,"props":3103,"children":3104},{},[3105,3116,3126],{"type":23,"tag":783,"props":3106,"children":3107},{},[3108,3114],{"type":23,"tag":3109,"props":3110,"children":3111},"strong",{},[3112],{"type":28,"value":3113},"Closed:",{"type":28,"value":3115}," All requests pass through normally.",{"type":23,"tag":783,"props":3117,"children":3118},{},[3119,3124],{"type":23,"tag":3109,"props":3120,"children":3121},{},[3122],{"type":28,"value":3123},"Open:",{"type":28,"value":3125}," Requests fail fast, bypassing the problematic service.",{"type":23,"tag":783,"props":3127,"children":3128},{},[3129,3134],{"type":23,"tag":3109,"props":3130,"children":3131},{},[3132],{"type":28,"value":3133},"Half-Open:",{"type":28,"value":3135}," A limited number of requests test if the external service has recovered.",{"type":23,"tag":24,"props":3137,"children":3138},{},[3139],{"type":28,"value":3140},"This mechanism helps improve the resilience and responsiveness of your systems.",{"type":23,"tag":31,"props":3142,"children":3144},{"id":3143},"when-to-use-circuit-breakers",[3145],{"type":28,"value":3146},"When to Use Circuit Breakers",{"type":23,"tag":24,"props":3148,"children":3149},{},[3150],{"type":28,"value":3151},"Circuit breakers are essential when:",{"type":23,"tag":779,"props":3153,"children":3154},{},[3155,3160,3165],{"type":23,"tag":783,"props":3156,"children":3157},{},[3158],{"type":28,"value":3159},"Your system relies on remote calls (microservices architecture, external APIs).",{"type":23,"tag":783,"props":3161,"children":3162},{},[3163],{"type":28,"value":3164},"You need to prevent failure propagation.",{"type":23,"tag":783,"props":3166,"children":3167},{},[3168],{"type":28,"value":3169},"You aim to improve user experience by quickly responding to failures.",{"type":23,"tag":31,"props":3171,"children":3173},{"id":3172},"implementing-circuit-breakers-with-resilience4j",[3174],{"type":28,"value":3175},"Implementing Circuit Breakers with Resilience4j",{"type":23,"tag":3177,"props":3178,"children":3180},"h3",{"id":3179},"step-1-adding-dependencies",[3181],{"type":28,"value":3182},"Step 1: Adding Dependencies",{"type":23,"tag":24,"props":3184,"children":3185},{},[3186],{"type":28,"value":3187},"Add Resilience4j dependencies to your project (Maven example):",{"type":23,"tag":64,"props":3189,"children":3191},{"className":2832,"code":3190,"language":2834,"meta":7,"style":7},"\u003Cdependency>\n    \u003CgroupId>io.github.resilience4j\u003C/groupId>\n    \u003CartifactId>resilience4j-circuitbreaker\u003C/artifactId>\n    \u003Cversion>2.0.2\u003C/version>\n\u003C/dependency>\n",[3192],{"type":23,"tag":14,"props":3193,"children":3194},{"__ignoreMap":7},[3195,3211,3235,3259,3283],{"type":23,"tag":74,"props":3196,"children":3197},{"class":76,"line":77},[3198,3202,3207],{"type":23,"tag":74,"props":3199,"children":3200},{"style":86},[3201],{"type":28,"value":2846},{"type":23,"tag":74,"props":3203,"children":3204},{"style":81},[3205],{"type":28,"value":3206},"dependency",{"type":23,"tag":74,"props":3208,"children":3209},{"style":86},[3210],{"type":28,"value":2856},{"type":23,"tag":74,"props":3212,"children":3213},{"class":76,"line":98},[3214,3218,3222,3227,3231],{"type":23,"tag":74,"props":3215,"children":3216},{"style":86},[3217],{"type":28,"value":2864},{"type":23,"tag":74,"props":3219,"children":3220},{"style":81},[3221],{"type":28,"value":2869},{"type":23,"tag":74,"props":3223,"children":3224},{"style":86},[3225],{"type":28,"value":3226},">io.github.resilience4j\u003C/",{"type":23,"tag":74,"props":3228,"children":3229},{"style":81},[3230],{"type":28,"value":2869},{"type":23,"tag":74,"props":3232,"children":3233},{"style":86},[3234],{"type":28,"value":2856},{"type":23,"tag":74,"props":3236,"children":3237},{"class":76,"line":112},[3238,3242,3246,3251,3255],{"type":23,"tag":74,"props":3239,"children":3240},{"style":86},[3241],{"type":28,"value":2864},{"type":23,"tag":74,"props":3243,"children":3244},{"style":81},[3245],{"type":28,"value":2894},{"type":23,"tag":74,"props":3247,"children":3248},{"style":86},[3249],{"type":28,"value":3250},">resilience4j-circuitbreaker\u003C/",{"type":23,"tag":74,"props":3252,"children":3253},{"style":81},[3254],{"type":28,"value":2894},{"type":23,"tag":74,"props":3256,"children":3257},{"style":86},[3258],{"type":28,"value":2856},{"type":23,"tag":74,"props":3260,"children":3261},{"class":76,"line":131},[3262,3266,3270,3275,3279],{"type":23,"tag":74,"props":3263,"children":3264},{"style":86},[3265],{"type":28,"value":2864},{"type":23,"tag":74,"props":3267,"children":3268},{"style":81},[3269],{"type":28,"value":2919},{"type":23,"tag":74,"props":3271,"children":3272},{"style":86},[3273],{"type":28,"value":3274},">2.0.2\u003C/",{"type":23,"tag":74,"props":3276,"children":3277},{"style":81},[3278],{"type":28,"value":2919},{"type":23,"tag":74,"props":3280,"children":3281},{"style":86},[3282],{"type":28,"value":2856},{"type":23,"tag":74,"props":3284,"children":3285},{"class":76,"line":149},[3286,3290,3294],{"type":23,"tag":74,"props":3287,"children":3288},{"style":86},[3289],{"type":28,"value":2940},{"type":23,"tag":74,"props":3291,"children":3292},{"style":81},[3293],{"type":28,"value":3206},{"type":23,"tag":74,"props":3295,"children":3296},{"style":86},[3297],{"type":28,"value":2856},{"type":23,"tag":3177,"props":3299,"children":3301},{"id":3300},"step-2-configuring-circuit-breaker",[3302],{"type":28,"value":3303},"Step 2: Configuring Circuit Breaker",{"type":23,"tag":64,"props":3305,"children":3307},{"className":2268,"code":3306,"language":2171,"meta":7,"style":7},"CircuitBreakerConfig config = CircuitBreakerConfig.custom()\n    .failureRateThreshold(50)\n    .waitDurationInOpenState(Duration.ofMillis(1000))\n    .permittedNumberOfCallsInHalfOpenState(2)\n    .minimumNumberOfCalls(5)\n    .build();\n\nCircuitBreaker circuitBreaker = CircuitBreaker.of(\"myService\", config);\n",[3308],{"type":23,"tag":14,"props":3309,"children":3310},{"__ignoreMap":7},[3311,3338,3364,3400,3424,3449,3465,3472],{"type":23,"tag":74,"props":3312,"children":3313},{"class":76,"line":77},[3314,3319,3323,3328,3333],{"type":23,"tag":74,"props":3315,"children":3316},{"style":86},[3317],{"type":28,"value":3318},"CircuitBreakerConfig config ",{"type":23,"tag":74,"props":3320,"children":3321},{"style":906},[3322],{"type":28,"value":1043},{"type":23,"tag":74,"props":3324,"children":3325},{"style":86},[3326],{"type":28,"value":3327}," CircuitBreakerConfig.",{"type":23,"tag":74,"props":3329,"children":3330},{"style":823},[3331],{"type":28,"value":3332},"custom",{"type":23,"tag":74,"props":3334,"children":3335},{"style":86},[3336],{"type":28,"value":3337},"()\n",{"type":23,"tag":74,"props":3339,"children":3340},{"class":76,"line":98},[3341,3346,3351,3355,3360],{"type":23,"tag":74,"props":3342,"children":3343},{"style":86},[3344],{"type":28,"value":3345},"    .",{"type":23,"tag":74,"props":3347,"children":3348},{"style":823},[3349],{"type":28,"value":3350},"failureRateThreshold",{"type":23,"tag":74,"props":3352,"children":3353},{"style":86},[3354],{"type":28,"value":1989},{"type":23,"tag":74,"props":3356,"children":3357},{"style":92},[3358],{"type":28,"value":3359},"50",{"type":23,"tag":74,"props":3361,"children":3362},{"style":86},[3363],{"type":28,"value":1030},{"type":23,"tag":74,"props":3365,"children":3366},{"class":76,"line":112},[3367,3371,3376,3381,3386,3390,3395],{"type":23,"tag":74,"props":3368,"children":3369},{"style":86},[3370],{"type":28,"value":3345},{"type":23,"tag":74,"props":3372,"children":3373},{"style":823},[3374],{"type":28,"value":3375},"waitDurationInOpenState",{"type":23,"tag":74,"props":3377,"children":3378},{"style":86},[3379],{"type":28,"value":3380},"(Duration.",{"type":23,"tag":74,"props":3382,"children":3383},{"style":823},[3384],{"type":28,"value":3385},"ofMillis",{"type":23,"tag":74,"props":3387,"children":3388},{"style":86},[3389],{"type":28,"value":1989},{"type":23,"tag":74,"props":3391,"children":3392},{"style":92},[3393],{"type":28,"value":3394},"1000",{"type":23,"tag":74,"props":3396,"children":3397},{"style":86},[3398],{"type":28,"value":3399},"))\n",{"type":23,"tag":74,"props":3401,"children":3402},{"class":76,"line":131},[3403,3407,3412,3416,3420],{"type":23,"tag":74,"props":3404,"children":3405},{"style":86},[3406],{"type":28,"value":3345},{"type":23,"tag":74,"props":3408,"children":3409},{"style":823},[3410],{"type":28,"value":3411},"permittedNumberOfCallsInHalfOpenState",{"type":23,"tag":74,"props":3413,"children":3414},{"style":86},[3415],{"type":28,"value":1989},{"type":23,"tag":74,"props":3417,"children":3418},{"style":92},[3419],{"type":28,"value":2356},{"type":23,"tag":74,"props":3421,"children":3422},{"style":86},[3423],{"type":28,"value":1030},{"type":23,"tag":74,"props":3425,"children":3426},{"class":76,"line":149},[3427,3431,3436,3440,3445],{"type":23,"tag":74,"props":3428,"children":3429},{"style":86},[3430],{"type":28,"value":3345},{"type":23,"tag":74,"props":3432,"children":3433},{"style":823},[3434],{"type":28,"value":3435},"minimumNumberOfCalls",{"type":23,"tag":74,"props":3437,"children":3438},{"style":86},[3439],{"type":28,"value":1989},{"type":23,"tag":74,"props":3441,"children":3442},{"style":92},[3443],{"type":28,"value":3444},"5",{"type":23,"tag":74,"props":3446,"children":3447},{"style":86},[3448],{"type":28,"value":1030},{"type":23,"tag":74,"props":3450,"children":3451},{"class":76,"line":162},[3452,3456,3461],{"type":23,"tag":74,"props":3453,"children":3454},{"style":86},[3455],{"type":28,"value":3345},{"type":23,"tag":74,"props":3457,"children":3458},{"style":823},[3459],{"type":28,"value":3460},"build",{"type":23,"tag":74,"props":3462,"children":3463},{"style":86},[3464],{"type":28,"value":2388},{"type":23,"tag":74,"props":3466,"children":3467},{"class":76,"line":175},[3468],{"type":23,"tag":74,"props":3469,"children":3470},{"emptyLinePlaceholder":984},[3471],{"type":28,"value":987},{"type":23,"tag":74,"props":3473,"children":3474},{"class":76,"line":188},[3475,3480,3484,3489,3494,3498,3503],{"type":23,"tag":74,"props":3476,"children":3477},{"style":86},[3478],{"type":28,"value":3479},"CircuitBreaker circuitBreaker ",{"type":23,"tag":74,"props":3481,"children":3482},{"style":906},[3483],{"type":28,"value":1043},{"type":23,"tag":74,"props":3485,"children":3486},{"style":86},[3487],{"type":28,"value":3488}," CircuitBreaker.",{"type":23,"tag":74,"props":3490,"children":3491},{"style":823},[3492],{"type":28,"value":3493},"of",{"type":23,"tag":74,"props":3495,"children":3496},{"style":86},[3497],{"type":28,"value":1989},{"type":23,"tag":74,"props":3499,"children":3500},{"style":125},[3501],{"type":28,"value":3502},"\"myService\"",{"type":23,"tag":74,"props":3504,"children":3505},{"style":86},[3506],{"type":28,"value":3507},", config);\n",{"type":23,"tag":3177,"props":3509,"children":3511},{"id":3510},"step-3-using-circuit-breaker",[3512],{"type":28,"value":3513},"Step 3: Using Circuit Breaker",{"type":23,"tag":24,"props":3515,"children":3516},{},[3517],{"type":28,"value":3518},"Wrap service calls using the circuit breaker:",{"type":23,"tag":64,"props":3520,"children":3522},{"className":2268,"code":3521,"language":2171,"meta":7,"style":7},"Supplier\u003CString> decoratedSupplier = CircuitBreaker.decorateSupplier(circuitBreaker, () -> myService.remoteCall());\n\nTry.ofSupplier(decoratedSupplier)\n    .recover(throwable -> \"Fallback response\")\n    .onSuccess(result -> System.out.println(\"Response: \" + result));\n",[3523],{"type":23,"tag":14,"props":3524,"children":3525},{"__ignoreMap":7},[3526,3581,3588,3606,3636],{"type":23,"tag":74,"props":3527,"children":3528},{"class":76,"line":77},[3529,3534,3539,3544,3548,3552,3557,3562,3567,3572,3577],{"type":23,"tag":74,"props":3530,"children":3531},{"style":86},[3532],{"type":28,"value":3533},"Supplier\u003C",{"type":23,"tag":74,"props":3535,"children":3536},{"style":906},[3537],{"type":28,"value":3538},"String",{"type":23,"tag":74,"props":3540,"children":3541},{"style":86},[3542],{"type":28,"value":3543},"> decoratedSupplier ",{"type":23,"tag":74,"props":3545,"children":3546},{"style":906},[3547],{"type":28,"value":1043},{"type":23,"tag":74,"props":3549,"children":3550},{"style":86},[3551],{"type":28,"value":3488},{"type":23,"tag":74,"props":3553,"children":3554},{"style":823},[3555],{"type":28,"value":3556},"decorateSupplier",{"type":23,"tag":74,"props":3558,"children":3559},{"style":86},[3560],{"type":28,"value":3561},"(circuitBreaker, () ",{"type":23,"tag":74,"props":3563,"children":3564},{"style":906},[3565],{"type":28,"value":3566},"->",{"type":23,"tag":74,"props":3568,"children":3569},{"style":86},[3570],{"type":28,"value":3571}," myService.",{"type":23,"tag":74,"props":3573,"children":3574},{"style":823},[3575],{"type":28,"value":3576},"remoteCall",{"type":23,"tag":74,"props":3578,"children":3579},{"style":86},[3580],{"type":28,"value":2467},{"type":23,"tag":74,"props":3582,"children":3583},{"class":76,"line":98},[3584],{"type":23,"tag":74,"props":3585,"children":3586},{"emptyLinePlaceholder":984},[3587],{"type":28,"value":987},{"type":23,"tag":74,"props":3589,"children":3590},{"class":76,"line":112},[3591,3596,3601],{"type":23,"tag":74,"props":3592,"children":3593},{"style":86},[3594],{"type":28,"value":3595},"Try.",{"type":23,"tag":74,"props":3597,"children":3598},{"style":823},[3599],{"type":28,"value":3600},"ofSupplier",{"type":23,"tag":74,"props":3602,"children":3603},{"style":86},[3604],{"type":28,"value":3605},"(decoratedSupplier)\n",{"type":23,"tag":74,"props":3607,"children":3608},{"class":76,"line":131},[3609,3613,3618,3623,3627,3632],{"type":23,"tag":74,"props":3610,"children":3611},{"style":86},[3612],{"type":28,"value":3345},{"type":23,"tag":74,"props":3614,"children":3615},{"style":823},[3616],{"type":28,"value":3617},"recover",{"type":23,"tag":74,"props":3619,"children":3620},{"style":86},[3621],{"type":28,"value":3622},"(throwable ",{"type":23,"tag":74,"props":3624,"children":3625},{"style":906},[3626],{"type":28,"value":3566},{"type":23,"tag":74,"props":3628,"children":3629},{"style":125},[3630],{"type":28,"value":3631}," \"Fallback response\"",{"type":23,"tag":74,"props":3633,"children":3634},{"style":86},[3635],{"type":28,"value":1030},{"type":23,"tag":74,"props":3637,"children":3638},{"class":76,"line":149},[3639,3643,3648,3653,3657,3662,3667,3671,3676,3681],{"type":23,"tag":74,"props":3640,"children":3641},{"style":86},[3642],{"type":28,"value":3345},{"type":23,"tag":74,"props":3644,"children":3645},{"style":823},[3646],{"type":28,"value":3647},"onSuccess",{"type":23,"tag":74,"props":3649,"children":3650},{"style":86},[3651],{"type":28,"value":3652},"(result ",{"type":23,"tag":74,"props":3654,"children":3655},{"style":906},[3656],{"type":28,"value":3566},{"type":23,"tag":74,"props":3658,"children":3659},{"style":86},[3660],{"type":28,"value":3661}," System.out.",{"type":23,"tag":74,"props":3663,"children":3664},{"style":823},[3665],{"type":28,"value":3666},"println",{"type":23,"tag":74,"props":3668,"children":3669},{"style":86},[3670],{"type":28,"value":1989},{"type":23,"tag":74,"props":3672,"children":3673},{"style":125},[3674],{"type":28,"value":3675},"\"Response: \"",{"type":23,"tag":74,"props":3677,"children":3678},{"style":906},[3679],{"type":28,"value":3680}," +",{"type":23,"tag":74,"props":3682,"children":3683},{"style":86},[3684],{"type":28,"value":3685}," result));\n",{"type":23,"tag":31,"props":3687,"children":3689},{"id":3688},"monitoring-and-metrics",[3690],{"type":28,"value":3691},"Monitoring and Metrics",{"type":23,"tag":24,"props":3693,"children":3694},{},[3695],{"type":28,"value":3696},"Resilience4j provides built-in support for metrics and monitoring:",{"type":23,"tag":64,"props":3698,"children":3700},{"className":2268,"code":3699,"language":2171,"meta":7,"style":7},"CircuitBreakerRegistry registry = CircuitBreakerRegistry.ofDefaults();\nregistry.getEventPublisher()\n    .onStateTransition(event -> System.out.println(event.getStateTransition()));\n",[3701],{"type":23,"tag":14,"props":3702,"children":3703},{"__ignoreMap":7},[3704,3730,3747],{"type":23,"tag":74,"props":3705,"children":3706},{"class":76,"line":77},[3707,3712,3716,3721,3726],{"type":23,"tag":74,"props":3708,"children":3709},{"style":86},[3710],{"type":28,"value":3711},"CircuitBreakerRegistry registry ",{"type":23,"tag":74,"props":3713,"children":3714},{"style":906},[3715],{"type":28,"value":1043},{"type":23,"tag":74,"props":3717,"children":3718},{"style":86},[3719],{"type":28,"value":3720}," CircuitBreakerRegistry.",{"type":23,"tag":74,"props":3722,"children":3723},{"style":823},[3724],{"type":28,"value":3725},"ofDefaults",{"type":23,"tag":74,"props":3727,"children":3728},{"style":86},[3729],{"type":28,"value":2388},{"type":23,"tag":74,"props":3731,"children":3732},{"class":76,"line":98},[3733,3738,3743],{"type":23,"tag":74,"props":3734,"children":3735},{"style":86},[3736],{"type":28,"value":3737},"registry.",{"type":23,"tag":74,"props":3739,"children":3740},{"style":823},[3741],{"type":28,"value":3742},"getEventPublisher",{"type":23,"tag":74,"props":3744,"children":3745},{"style":86},[3746],{"type":28,"value":3337},{"type":23,"tag":74,"props":3748,"children":3749},{"class":76,"line":112},[3750,3754,3759,3764,3768,3772,3776,3781,3786],{"type":23,"tag":74,"props":3751,"children":3752},{"style":86},[3753],{"type":28,"value":3345},{"type":23,"tag":74,"props":3755,"children":3756},{"style":823},[3757],{"type":28,"value":3758},"onStateTransition",{"type":23,"tag":74,"props":3760,"children":3761},{"style":86},[3762],{"type":28,"value":3763},"(event ",{"type":23,"tag":74,"props":3765,"children":3766},{"style":906},[3767],{"type":28,"value":3566},{"type":23,"tag":74,"props":3769,"children":3770},{"style":86},[3771],{"type":28,"value":3661},{"type":23,"tag":74,"props":3773,"children":3774},{"style":823},[3775],{"type":28,"value":3666},{"type":23,"tag":74,"props":3777,"children":3778},{"style":86},[3779],{"type":28,"value":3780},"(event.",{"type":23,"tag":74,"props":3782,"children":3783},{"style":823},[3784],{"type":28,"value":3785},"getStateTransition",{"type":23,"tag":74,"props":3787,"children":3788},{"style":86},[3789],{"type":28,"value":3790},"()));\n",{"type":23,"tag":24,"props":3792,"children":3793},{},[3794],{"type":28,"value":3795},"Integrate with Prometheus, Grafana, or other observability tools for comprehensive monitoring.",{"type":23,"tag":31,"props":3797,"children":3799},{"id":3798},"best-practices-for-circuit-breaking",[3800],{"type":28,"value":3801},"Best Practices for Circuit Breaking",{"type":23,"tag":779,"props":3803,"children":3804},{},[3805,3810,3815,3820],{"type":23,"tag":783,"props":3806,"children":3807},{},[3808],{"type":28,"value":3809},"Configure sensible thresholds to avoid premature circuit opening.",{"type":23,"tag":783,"props":3811,"children":3812},{},[3813],{"type":28,"value":3814},"Always define fallback mechanisms.",{"type":23,"tag":783,"props":3816,"children":3817},{},[3818],{"type":28,"value":3819},"Regularly monitor circuit breaker states and metrics.",{"type":23,"tag":783,"props":3821,"children":3822},{},[3823],{"type":28,"value":3824},"Test thoroughly to ensure reliability under failure conditions.",{"type":23,"tag":31,"props":3826,"children":3827},{"id":716},[3828],{"type":28,"value":719},{"type":23,"tag":24,"props":3830,"children":3831},{},[3832],{"type":28,"value":3833},"Implementing circuit breakers using Resilience4j significantly enhances the resilience of your Java-based distributed systems. This proactive approach ensures your systems gracefully handle failures, maintaining service availability and user satisfaction.",{"type":23,"tag":2104,"props":3835,"children":3836},{"id":3014},[3837],{"type":28,"value":3017},{"type":23,"tag":779,"props":3839,"children":3840},{},[3841,3851,3861],{"type":23,"tag":783,"props":3842,"children":3843},{},[3844],{"type":23,"tag":2117,"props":3845,"children":3848},{"href":3846,"rel":3847},"https://resilience4j.readme.io/docs",[2121],[3849],{"type":28,"value":3850},"Resilience4j Official Documentation",{"type":23,"tag":783,"props":3852,"children":3853},{},[3854],{"type":23,"tag":2117,"props":3855,"children":3858},{"href":3856,"rel":3857},"https://martinfowler.com/bliki/CircuitBreaker.html",[2121],[3859],{"type":28,"value":3860},"Circuit Breaker Pattern by Martin Fowler",{"type":23,"tag":783,"props":3862,"children":3863},{},[3864],{"type":23,"tag":2117,"props":3865,"children":3868},{"href":3866,"rel":3867},"https://microservices.io/patterns/reliability/circuit-breaker.html",[2121],[3869],{"type":28,"value":3870},"Microservices Patterns by Chris Richardson",{"type":23,"tag":731,"props":3872,"children":3873},{},[3874],{"type":28,"value":735},{"title":7,"searchDepth":98,"depth":98,"links":3876},[3877,3878,3879,3884,3885,3886],{"id":3093,"depth":98,"text":3096},{"id":3143,"depth":98,"text":3146},{"id":3172,"depth":98,"text":3175,"children":3880},[3881,3882,3883],{"id":3179,"depth":112,"text":3182},{"id":3300,"depth":112,"text":3303},{"id":3510,"depth":112,"text":3513},{"id":3688,"depth":98,"text":3691},{"id":3798,"depth":98,"text":3801},{"id":716,"depth":98,"text":719},"content:posts:circuit-breaking-resilience.md","posts/circuit-breaking-resilience.md","posts/circuit-breaking-resilience",[3891,3892,3893,3894,3898,3902,3906,3910,3914,3918,3922,3926,3930,3934,3938,3939,3943,3947,3950,3954,3958],{"_path":749,"title":750,"date":752},{"_path":2164,"title":2165,"date":2167},{"_path":3071,"title":3072,"date":3074},{"_path":3895,"title":3896,"date":3897},"/posts/maven-and-github-actions","Automating Java Builds with Maven and GitHub Actions CI/CD","2024-06-15T11:00:00.000Z",{"_path":3899,"title":3900,"date":3901},"/posts/pattern-matching-sealed-classes-java21","A Guide to Pattern Matching and Sealed Classes in Java 21","2024-05-15T11:00:00.000Z",{"_path":3903,"title":3904,"date":3905},"/posts/async-java-completable-vs-reactive","Asynchronous Programming in Java: CompletableFuture vs Reactive Streams","2024-04-15T11:00:00.000Z",{"_path":3907,"title":3908,"date":3909},"/posts/mastering-concurrency","Mastering Concurrency in Java: Threads, Executors, and Virtual Threads","2024-03-15T11:00:00.000Z",{"_path":3911,"title":3912,"date":3913},"/posts/microservices-mistakes","Common Mistakes When Developing Microservices","2024-02-15T11:00:00.000Z",{"_path":3915,"title":3916,"date":3917},"/posts/tdd-testing","Test-Driven Development (TDD) in Java with JUnit and Mockito","2024-01-15T11:00:00.000Z",{"_path":3919,"title":3920,"date":3921},"/posts/single-table-design","Single Table Design","2023-12-27T11:00:00.000Z",{"_path":3923,"title":3924,"date":3925},"/posts/java-17","Exploring Java 17's New Features","2023-10-08T11:00:00.000Z",{"_path":3927,"title":3928,"date":3929},"/posts/hexagonal-architecture","Introduction to Hexagonal Architecture","2023-10-02 18:00:00",{"_path":3931,"title":3932,"date":3933},"/posts/terraform","Unleashing the Power of Infrastructure as Code (IaC)","2023-09-24 18:00:00",{"_path":3935,"title":3936,"date":3937},"/posts/python-virtual-environments","Python Virtual Environments (venv)","2023-09-17 22:00:00",{"_path":4,"title":8,"date":10},{"_path":3940,"title":3941,"date":3942},"/posts/how-to-configure-ssh-key-based-authentication","How To Configure SSH Key-Based Authentication","2021-02-21 03:46:12",{"_path":3944,"title":3945,"date":3946},"/posts/algorithms-binary-search-tree","Algorithms - Binary Search Tree in kotlin","2020-12-06T11:00:00.000Z",{"_path":3948,"title":3949,"date":3946},"/posts/how-to-create-a-twitter-bot","How to create a Twitter bot",{"_path":3951,"title":3952,"date":3953},"/posts/manage-aws-infrastructure-with-terraform","Bootstrap complete Java application infrastructure in AWS with Terraform","2020-12-02T11:00:00.000Z",{"_path":3955,"title":3956,"date":3957},"/posts/algorithms-working-with-trees","Algorithms - Binary tree traversals in kotlin","2020-11-24T11:00:00.000Z",{"_path":3959,"title":3960,"date":3961},"/posts/playing-with-ocr-libraries","Playing with OCR libraries","2020-11-22T11:00:00.000Z",1790510065910]