<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Maciej Krawczyk on Medium]]></title>
        <description><![CDATA[Stories by Maciej Krawczyk on Medium]]></description>
        <link>https://medium.com/@maciejrokrawczyk?source=rss-c2efbfe5288a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uPymsSJg6cReXQKCexHGSw.png</url>
            <title>Stories by Maciej Krawczyk on Medium</title>
            <link>https://medium.com/@maciejrokrawczyk?source=rss-c2efbfe5288a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:32:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maciejrokrawczyk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Shipping the First Version Should Change the Plan]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@maciejrokrawczyk/shipping-the-first-version-should-change-the-plan-512e4a5fa698?source=rss-c2efbfe5288a------2"><img src="https://cdn-images-1.medium.com/max/1536/1*OnzFr6qC0eCoBtZK36le-Q.png" width="1536"></a></p><p class="medium-feed-snippet">A strange thing happens in many software projects after the first working version ships.</p><p class="medium-feed-link"><a href="https://medium.com/@maciejrokrawczyk/shipping-the-first-version-should-change-the-plan-512e4a5fa698?source=rss-c2efbfe5288a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@maciejrokrawczyk/shipping-the-first-version-should-change-the-plan-512e4a5fa698?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/512e4a5fa698</guid>
            <category><![CDATA[product-development]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[build-in-public]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 06:43:02 GMT</pubDate>
            <atom:updated>2026-08-05T06:43:02.481Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Good Documentation Explains the Decision, Not Just the Code]]></title>
            <link>https://medium.com/@maciejrokrawczyk/good-documentation-explains-the-decision-not-just-the-code-80c8bdcb25a7?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/80c8bdcb25a7</guid>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[engineering-leadership]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 11:56:10 GMT</pubDate>
            <atom:updated>2026-07-29T11:56:10.095Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_awTqstj-ZQu7wsDyVOTXA.png" /></figure><p>A pattern I’ve seen many times in software projects is that documentation starts too late and documents the wrong thing.</p><p>A team ships a feature, the code works, the tests pass, and everyone moves on. Maybe someone adds a README section, maybe not. If they do, it usually explains how to run something, how to call an endpoint, or what a component does. That kind of documentation is useful, but it often misses the part future developers need most.</p><p>It misses the decision.</p><p>Six months later, someone opens the same part of the codebase and asks the usual questions. Why is this data model shaped like this? Why is this rule handled in the backend instead of the frontend? Why is this integration synchronous? Why does this permission check live here? Why did the team choose this simple approach instead of something more flexible?</p><p>The code can show what exists, but it rarely explains why it exists. That is where a lot of engineering context disappears.</p><h3>The Problem Is Not Always Missing Documentation</h3><p>When people complain about documentation, the usual diagnosis is that there is not enough of it. The README is outdated. The setup instructions are incomplete. The API docs are missing examples. The architecture diagram no longer matches reality.</p><p>All of those problems are real. But I think there is another documentation problem that is easier to miss: the docs describe the system without preserving the reasoning behind it.</p><p>This matters because software is full of trade-offs. A piece of code may look strange because it was written badly, but it may also look strange because it was solving a constraint that is no longer visible. Maybe the team chose a simpler data model because they were still validating the product. Maybe they avoided a generic abstraction because they had only one real use case. Maybe they accepted duplication because the two workflows looked similar but were expected to diverge.</p><p>Without the reasoning, future developers have to guess.</p><p>That guessing creates waste. Sometimes they refactor something that should have stayed stable. Sometimes they preserve complexity that no longer has a purpose. Sometimes they repeat the same debate the original team already had, only with less context.</p><h3>Code Tells You What, Not Why</h3><p>There is a limit to how much intent code can express. Good naming helps. Clear boundaries help. Tests help. Types help. A well-designed system communicates a lot through structure. But even very good code cannot capture every product constraint, customer conversation, deadline, risk, rejected option, or uncertainty that shaped the decision.</p><p>For example, imagine a SaaS product where permissions are implemented with a relatively simple role model: owner, admin, member. A new developer joins later and sees that the model is too simple for some enterprise scenarios. They may assume the original implementation was naive.</p><p>But maybe the team considered custom roles and intentionally rejected them. Maybe early users did not need that complexity. Maybe the product was still validating whether teams wanted collaboration features at all. Maybe the decision was not “we do not understand permissions,” but “we are not ready to pay the complexity cost yet.”</p><p>That difference matters. The same code can look careless or disciplined depending on the missing context. Documentation should help preserve that context.</p><h3>The Documentation That Actually Helps Later</h3><p>The most useful documentation I’ve seen is often short. It does not try to explain every line of code. It explains the decision behind the code.</p><p>A good decision note answers a few practical questions:</p><ul><li>What did we choose?</li><li>Why did we choose it now?</li><li>What alternatives did we consider?</li><li>What trade-off did we accept?</li><li>What would make us revisit this later?</li></ul><p>That is usually enough.</p><p>The goal is not to create a bureaucratic architecture process. The goal is to leave a trail of reasoning for the next person. That next person might be a teammate, a contractor, a future hire, or you three months later when you no longer remember why the obvious solution was rejected.</p><p>This is especially important in small teams and early-stage products. In those environments, decisions are often made quickly and informally. A lot of important reasoning lives in chat messages, calls, pull request comments, or someone’s memory. That works while the context is fresh. It breaks down when the product grows.</p><p>If a decision affects future work, it deserves a small explanation.</p><h3>A Simple Example: Choosing Not to Build Flexibility</h3><p>One of the hardest decisions to document is the decision not to build something.</p><p>Teams often document what they add, but they rarely document what they intentionally leave out. This is a problem because future developers may see the missing functionality as an oversight instead of a choice.</p><p>Imagine you are building notification preferences. The flexible version might support multiple channels, custom schedules, per-event configuration, team defaults, quiet hours, digest frequency, and user-level overrides. The simple version might support only email notifications for a small set of events.</p><p>If you ship the simple version without explanation, someone later may look at it and think: “This is under-designed.” They might be right. But they might also be missing the original product reasoning.</p><p>Maybe the team did not yet know which notifications users cared about. Maybe adding full configurability would have slowed down validation. Maybe the most important question was not “can users customize notifications?” but “do users care about these notifications at all?”</p><p>That context changes how future work should proceed. A useful note might say:</p><blockquote>We are starting with email-only notifications for three core events. We considered per-event preferences and Slack integration, but we do not yet know which notifications users value. We will revisit this after we see usage patterns or receive repeated requests for control.</blockquote><p>That is not a long document. But it helps the next developer understand the shape of the decision.</p><p>It also prevents accidental overcorrection. Instead of immediately building a complex preference system, the team can ask whether the original signal has changed.</p><h3>Documentation as Decision Memory</h3><p>I like thinking about documentation as decision memory.</p><p>Not every detail needs to be remembered. Some things are obvious from the code. Some things change too quickly. Some things are better expressed through tests or examples. But decisions that shape future work should not rely entirely on memory.</p><p>This is where lightweight architecture decision records can help, but I do not think the exact format matters as much as the habit. A decision can be captured in a pull request description, an issue, a README section, a short decision log, or a project note. The best location is the place your team will actually find later.</p><p>The important part is that the decision is close enough to the work to be maintained. A folder full of formal documents nobody reads is not much better than no documentation. A short note in the pull request that explains the trade-off may be more useful than a polished architecture document that goes stale immediately. The format should serve the team, not the other way around.</p><h3>Why Developers Avoid Writing This Down</h3><p>There are understandable reasons developers skip this kind of documentation.</p><p>Sometimes the decision feels obvious in the moment. Sometimes the team is moving fast. Sometimes writing down the reasoning feels like extra work. Sometimes the decision was messy, uncertain, or political, and nobody wants to make that visible.</p><p>But that discomfort is often a signal that the decision is worth documenting.</p><p>If the reasoning is obvious, it should be easy to summarize. If it is hard to summarize, the team may not actually agree on the decision. If the trade-off feels uncomfortable, future developers will probably need to know why it was accepted.</p><p>I have also noticed that developers sometimes avoid documenting uncertainty because they think documentation should sound confident. I think that is backwards. Good documentation should be honest about uncertainty.</p><p>It is useful to write:</p><blockquote>We are not sure this model will hold if teams need custom permissions. For now, we are optimizing for the simpler collaboration use case. Revisit this if we see repeated requests for role customization.</blockquote><p>That kind of note does not make the team look weak. It makes the decision understandable.</p><h3>What Not to Document</h3><p>There is a trap here. Once you start thinking about documentation, it is easy to document too much.</p><p>Not every implementation detail needs an explanation. Not every helper function needs a comment. Not every small choice deserves a decision record. Over-documentation creates its own maintenance burden, and stale documentation can be worse than missing documentation because it creates false confidence.</p><p>A good filter is to ask whether the decision will matter to someone changing the system later.</p><p>If the answer is no, the code and tests are probably enough. If the answer is yes, write down the reasoning. The more expensive the decision is to reverse, the more valuable the explanation becomes.</p><p>This is especially true for decisions around:</p><ul><li>data ownership</li><li>permission models</li><li>billing boundaries</li><li>external integrations</li><li>infrastructure constraints</li><li>domain concepts</li><li>product assumptions</li><li>security trade-offs</li><li>major abstractions</li><li>intentionally postponed complexity</li></ul><p>These are the areas where future teams lose the most time when context disappears.</p><h3>A Practical Habit</h3><p>The habit I would recommend is simple: before merging a meaningful change, add a small decision note.</p><p>It can be as short as this:</p><blockquote>Decision: We chose X.</blockquote><blockquote>Reason: Y matters right now because of Z.</blockquote><blockquote>Trade-off: We are accepting A instead of B.</blockquote><blockquote>Revisit when: C happens.</blockquote><p>That structure is intentionally small. It does not require a new process, a meeting, or a formal architecture board. It can live in the pull request description. If the decision becomes foundational, you can later copy it into a decision log or architecture note.</p><p>The point is to capture the reasoning while it is still fresh.</p><p>This also improves code review. Instead of reviewers guessing why a design was chosen, they can review the decision directly. They can challenge the assumption, suggest a missing alternative, or agree with the trade-off. The conversation becomes less about personal preference and more about the actual constraint. That is a healthier engineering discussion.</p><h3>How This Connects to Product Thinking</h3><p>One reason I care about this topic is that many technical decisions are not purely technical.</p><p>A data model reflects product assumptions. A permission system reflects how you think teams will collaborate. A billing boundary reflects what you believe customers will pay for. An onboarding flow reflects what you think users need to understand before seeing value.</p><p>If those assumptions are not written down, the codebase starts carrying product decisions that nobody can see clearly.</p><p>This is one of the themes behind <a href="https://gohakkle.con/">Hakkle</a>. I am building it around the idea that developers do not only need help typing code. They often need help thinking through planning, architecture, prioritization, and trade-offs while building real software.</p><p>Documentation fits into that because good documentation preserves judgment. It helps a project remember why it moved in a certain direction. It helps future work start from understanding instead of archaeology.</p><p>That is valuable even when the original decision turns out to be wrong. In fact, it may be most valuable then. If you know why a decision was made, you can tell whether the situation changed. If you do not know why, you may only know that the code feels wrong.</p><h3>What I’m Taking From This</h3><p>The lesson I keep coming back to is that documentation does not need to be large to be useful. It needs to preserve the right information.</p><p>A setup guide helps someone run the project. API docs help someone use the system. Comments help explain local complexity. But decision notes help future developers understand the path that led to the current design.</p><p>Software is not only a collection of files. It is a sequence of decisions made under constraints. Some decisions are technical. Some are product-driven. Some are temporary. Some are compromises. Some are bets. If we do not write down the important ones, the codebase becomes a history with missing chapters.</p><p>The next time I make a technical decision that affects future work, I want to leave behind just enough context for the next person to understand it. Not a perfect document. Not a long essay. Just the reasoning that would otherwise disappear.</p><p>Future developers do not need to know everything I was thinking. But they should not have to guess the decision from the code alone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80c8bdcb25a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hardest Architecture Decision Is Knowing What Not to Decide Yet]]></title>
            <link>https://medium.com/@maciejrokrawczyk/the-hardest-architecture-decision-is-knowing-what-not-to-decide-yet-f6ea567cb44a?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6ea567cb44a</guid>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Wed, 22 Jul 2026 10:54:23 GMT</pubDate>
            <atom:updated>2026-07-22T10:54:23.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOylgzAgaRYYQoCs_oZOEQ.png" /></figure><p>A common mistake in software projects is trying to make every important architecture decision too early.</p><p>I understand why it happens. At the beginning of a project, everything feels connected. You want the system to be clean. You want to avoid future rewrites. You want to prove to yourself, your team, or your client that the foundation is solid. So you start thinking ahead: scaling, permissions, integrations, data ownership, billing, admin tools, observability, deployment pipelines, internal abstractions, API boundaries.</p><p>Some of that thinking is useful. Some of it is necessary. But some of it is just guessing with architectural confidence.</p><p>While building products and mentoring developers, I’ve noticed that architecture problems often come from two opposite mistakes. The first is under-thinking decisions that are expensive to change later. The second is over-thinking decisions that would become much clearer after a small amount of real usage. Both mistakes can hurt a project. The hard part is telling them apart.</p><h3>Architecture Is Partly About Timing</h3><p>When developers talk about architecture, we usually talk about patterns, structure, scalability, maintainability, or technical debt. Those things matter, but they do not tell the whole story.</p><p>A decision can be technically correct and still be made too early. Another decision can feel uncomfortable to postpone and still be the right thing to delay. This is where architecture becomes less about diagrams and more about judgment.</p><p>For example, deciding how data ownership works in a multi-tenant SaaS product is usually not something you want to improvise late. If you get it wrong, you may end up rewriting core tables, changing authorization logic, migrating customer data, and fixing assumptions spread across the entire codebase.</p><p>On the other hand, designing a perfect internal analytics dashboard before anyone uses the product may be premature. The dashboard might feel important, but the actual questions you need to answer will probably change once real users start interacting with the system.</p><p>Both are architecture decisions. But they should not receive the same level of attention at the same time. That distinction is easy to miss.</p><h3>The Temptation to Design the Final System</h3><p>One of the most tempting things at the start of a project is to design the final version of the system.</p><p>It feels responsible. It feels mature. It feels like “real engineering.” You imagine the future version of the product and try to prepare for it. You add abstractions because you know the code might grow. You introduce configuration because different users might need different behavior. You create flexible data models because requirements might change. You separate modules because the system might become large.</p><p>Sometimes this pays off. Good early decisions can save months of pain later. But often, the future you are designing for is not the future that actually arrives. The product changes. Users behave differently than expected. The feature you thought would be central becomes secondary. The simple workflow turns out to be more valuable than the flexible one. A technical constraint you worried about never becomes a bottleneck.</p><p>The problem is not thinking ahead. The problem is treating speculation as certainty. That is how teams end up with complex systems built for requirements they never validated.</p><h3>The Opposite Mistake: Moving Too Fast Past Expensive Decisions</h3><p>Of course, the answer is not “just ship messy code and figure it out later.” That advice can be just as dangerous. Some decisions really do become painful when postponed too long. If you delay them because you want to move fast, you may create a hidden architecture debt that compounds quietly.</p><p>Authentication is a good example. At first, it can seem like a simple implementation detail. Add login, store users, protect routes. But authentication often connects to permissions, billing, organizations, invitations, account recovery, audit logs, integrations, and support workflows.</p><p>Data ownership is another example. If you are building a SaaS product, the question “who owns this record?” can become foundational. Is the data owned by a user, a team, an organization, a workspace, or a customer account? Can users belong to multiple organizations? Can records move between them? What happens when someone leaves?</p><p>These are not questions you want to discover accidentally after the product is already in use.</p><p>The same applies to billing boundaries, tenant isolation, permission models, compliance constraints, and certain integration contracts. These decisions shape the rest of the system. Changing them later often means changing not just code, but mental models. So the challenge is not to avoid architecture. The challenge is to identify which parts of the architecture are real constraints and which parts are guesses.</p><h3>A Simple Planning Model: Now, Soon, Later</h3><p>One practical habit I like is labeling decisions as now, soon, or later. It is a small exercise, but it forces a useful conversation before a project gets too deep into implementation.</p><p>Now decisions are expensive to reverse. They affect the foundation of the system and will be difficult to change once other work depends on them. Examples might include:</p><ul><li>data ownership</li><li>tenant boundaries</li><li>authentication model</li><li>authorization and permissions</li><li>billing structure</li><li>core domain model</li><li>external API contracts</li><li>deployment constraints</li></ul><p>These decisions deserve careful thought early. They do not need to be perfect, but they need to be intentional.</p><p>Soon decisions are important, but you do not yet have enough information to make them well. You know they matter, but deciding too early would involve too much guessing. Examples might include:</p><ul><li>reporting needs</li><li>admin workflows</li><li>advanced onboarding flows</li><li>detailed notification behavior</li><li>deeper integrations</li><li>team management features</li><li>internal tooling</li></ul><p>These decisions should not be ignored. They should be tracked. But the best next step may be to learn more before locking in a design.</p><p>Later decisions are mostly speculative. They may become important someday, but solving them now would add complexity without enough evidence. Examples might include:</p><ul><li>scaling strategies for traffic you do not have</li><li>plugin systems before extension points are clear</li><li>complex role hierarchies before roles are validated</li><li>generic workflow engines for two workflows</li><li>multi-region infrastructure before there is a real need</li><li>advanced customization before customers ask for it</li></ul><p>These are the decisions that often create premature architecture. They feel like preparation, but they can slow the project down and make the product harder to change.</p><h3>Why This Helps</h3><p>The value of the now / soon / later model is not that it gives you a perfect answer. It gives you a better conversation. Instead of debating whether something is “good architecture” in the abstract, you can ask more useful questions:</p><ul><li>What happens if we get this wrong?</li><li>How expensive is this to change later?</li><li>What other work will depend on this decision?</li><li>Do we have enough information to decide now?</li><li>Are we solving a current constraint or an imagined future one?</li><li>Can we design a smaller version that keeps the option open?</li></ul><p>These questions move the discussion away from personal preference. They make trade-offs visible. A senior engineer might want a cleaner abstraction. A founder might want to ship faster. A product person might want flexibility. A junior developer might want clearer guidance. None of those instincts are wrong, but they can pull the project in different directions.</p><p>Labeling decisions by timing gives everyone a shared language. It also reduces the emotional weight of postponing something. “Later” does not mean “we do not care.” It means “we do not have enough evidence to make this worth the complexity today.” That distinction matters.</p><h3>An Example: Building a New Feature</h3><p>Imagine you are building a feature that lets users invite teammates into a workspace. At first glance, this sounds straightforward. Add invitations, send emails, let users accept, and attach them to the workspace.</p><p>But quickly, architecture questions appear. Can a user belong to multiple workspaces? Are permissions workspace-specific or global? Can users invite others with equal permissions? What happens if an invited user already has an account? Can someone remove the original workspace owner? Does billing depend on seats, active users, or workspace members?</p><p>Some of these decisions are foundational. If you ignore workspace ownership or permission boundaries, you may create a system that works for the first demo but breaks as soon as real teams use it. Those are now decisions.</p><p>Other decisions might be important but not urgent. For example, maybe you will eventually need detailed audit logs, custom roles, domain-based access rules, or SSO. These could matter later, especially for larger customers. But if you are still validating whether teams want the product at all, building all of that immediately may be too much. Those are probably soon or later decisions, depending on your users.</p><p>The goal is not to build the smallest possible version blindly. The goal is to build the smallest version that does not trap you. That is a very different standard.</p><h3>The Cost of Premature Flexibility</h3><p>One reason this is difficult is that flexibility feels safe. A flexible system seems like it will protect you from future changes. If you add enough abstraction, configuration, and extension points, maybe you will not need to rewrite things later.</p><p>But flexibility has a cost. Every abstraction needs a name. Every configuration option needs to be understood. Every generic system creates more states to test. Every extension point can make the actual product behavior harder to reason about.</p><p>Premature flexibility often increases the surface area of the system before the team understands the problem deeply enough.</p><p>This does not mean abstractions are bad. Good abstractions are one of the best tools we have in software engineering. But the best abstractions usually emerge from repeated patterns, not imagined ones.</p><p>If you have built the same workflow three times and the shape is becoming obvious, abstraction can simplify the system. If you are building the first version and guessing about the next five, abstraction can hide uncertainty instead of solving it. That is where many projects accumulate accidental complexity.</p><h3>The Cost of Postponing Too Much</h3><p>There is also a cost to postponing too much. If every difficult decision gets pushed into the future, the system becomes a pile of local optimizations. Each feature works on its own, but the product becomes harder to extend. Concepts are duplicated. Data relationships become inconsistent. Permissions are patched in different places. The team starts saying things like “just be careful with that part of the codebase.”</p><p>This is often how technical debt appears. Not from one bad decision, but from many small decisions made without a shared model.</p><p>That is why “later” needs discipline. If a decision is postponed, it should still be visible. Write it down. Add a note to the planning document. Put it in the technical backlog. Mention what information would make the decision easier. Define what signal would move it from later to soon, or from soon to now.</p><p>Postponing a decision is only useful if the team remembers that it was postponed intentionally. Otherwise, it becomes avoidance.</p><h3>Architecture as Risk Management</h3><p>The more I think about this, the more I see architecture as a form of risk management. Not risk management in a bureaucratic sense. More like practical engineering risk: what can break, what can become expensive, what can slow learning, and what can make future work harder than it needs to be.</p><p>Good architecture does not eliminate uncertainty. It helps you move through uncertainty without creating unnecessary traps. Sometimes that means making a strong decision early. Sometimes it means keeping an option open. Sometimes it means building something simple because the product has not earned more complexity yet.</p><p>The skill is knowing which situation you are in. This is also why architecture cannot be separated from product thinking. A technically elegant design for the wrong product direction is still waste. A fast implementation that blocks necessary product evolution is also waste. Engineering judgment lives in the trade-off.</p><h3>What I’m Taking From This</h3><p>The practical takeaway is simple: before building a feature, make a short decision map. Write down the main decisions the feature touches. Then label each one:</p><ul><li>Now: expensive to reverse, needs early clarity</li><li>Soon: important, but more information would help</li><li>Later: speculative, not worth solving yet</li></ul><p>Then ask one more question for each decision:</p><blockquote>What would make this decision easier to make?</blockquote><p>For a now decision, the answer might be a short design review, a prototype, or a conversation with someone who has solved a similar problem before.</p><p>For a soon decision, the answer might be usage data, customer feedback, or a narrower first version.</p><p>For a later decision, the answer might be nothing yet. The right move may be to avoid adding complexity until the need becomes real.</p><p>This exercise does not need to be heavy. It can fit into a planning document, a GitHub issue, or a short architecture note. The point is not ceremony. The point is clarity.</p><h3>Why I Care About This While Building Hakkle</h3><p>This is one of the ideas behind <a href="https://gohakkle.com/">Hakkle</a>.</p><p>Not that developers need another tool to write more code. We already have a lot of help there. The harder problem is often deciding what should be built, what should be postponed, and which trade-offs are worth accepting.</p><p>While building Hakkle, I keep coming back to the same theme: software projects need better thinking around planning, architecture, prioritization, and momentum.</p><p>A developer can write good code and still get trapped by a bad sequence of decisions. A team can move fast and still spend months unwinding choices that were made too casually. A founder can ship quickly and still overbuild the wrong parts of the product.</p><p>The code matters. But the decisions around the code often matter more.</p><p>That is what makes software engineering difficult and interesting. It is not only about knowing patterns, tools, or frameworks. It is about knowing when to commit, when to wait, and when to keep the system simpler than your instincts want it to be. The next time I start planning a feature, I want to be more deliberate about that. Not by designing the perfect system upfront, and not by avoiding architecture altogether.</p><p>Just by asking a better question:</p><blockquote>Which decisions need to be made now, and which ones should earn their place later?</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6ea567cb44a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Can Generate Code. The Harder Problem Is Deciding What to Build.]]></title>
            <link>https://medium.com/@maciejrokrawczyk/ai-can-generate-code-the-harder-problem-is-deciding-what-to-build-01b4df7753e0?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/01b4df7753e0</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[decision-making]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Wed, 15 Jul 2026 11:45:05 GMT</pubDate>
            <atom:updated>2026-07-15T11:45:05.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2XpHplqr_EQ-du2UEsfRew.png" /></figure><h3>The moment a project really stalls</h3><p>A project can feel surprisingly close to moving forward and completely stuck at the same time. There is an idea worth pursuing, a backlog full of plausible tasks, and more than enough tools to implement any of them. The problem is not an inability to write the next piece of code; it is not knowing which piece of code deserves the next few days of work.</p><p>This is the point where many projects begin to drift. Should the next step be a small feature that might validate the idea, a technical improvement that will make later work easier, or a conversation with users before any more implementation? All three can sound reasonable in isolation, but choosing one means postponing the others.</p><p>AI has made the implementation side of this work much faster. It can generate a component, suggest a schema, explain an unfamiliar API, or help trace a failing test. What it cannot decide without meaningful context is whether that component, schema, integration, or test is the most useful thing for the project right now.</p><p>The difficult part of building software is often not producing code. It is making the decision that gives the code a purpose.</p><h3>Code generation solved a real problem — but not this one</h3><p>It would be a mistake to dismiss what coding assistants have changed. They are useful for the parts of software development that are often repetitive or slow: exploring an unfamiliar library, producing a first version of a component, writing tests, translating between languages, or narrowing down a bug. Used well, they reduce the time between an idea and a working experiment.</p><p>That speed is valuable, but it can also make an unresolved decision easier to postpone. When producing code is cheap, it becomes tempting to implement several possibilities rather than decide which one best serves the project. A fast implementation of the wrong feature is still time spent moving in the wrong direction.</p><p>The questions that matter most are usually less precise than a coding task. Is this feature necessary for the first release, or are we adding it because it is easy to imagine? Does this service boundary solve a problem we have today, or one we may never have? Is the right next step a technical change at all, or should we first learn whether anyone needs the outcome we are building toward?</p><p>These are not questions with universal answers. They depend on the project’s users, constraints, current stage, and the consequences of being wrong. A language model can contribute useful options and challenge assumptions, but it cannot supply the context or make the trade-off on the developer’s behalf.</p><p>The distinction matters because implementation and judgment require different kinds of support. One helps us produce an answer quickly; the other helps us decide whether we are asking the right question.</p><h3>Why these decisions are expensive</h3><p>In mentoring conversations, the recurring difficulty was rarely “How do I write this?” More often it was “Should I build this at all?”, “Is this enough architecture for now?”, or “What should I do next?” Those questions can look less urgent than a failing build or an unfinished feature, but they shape almost every hour that follows.</p><p>The cost of a weak decision is not limited to the first implementation. A feature that was unnecessary still needs to be maintained. A complicated abstraction still influences every later change. A premature infrastructure choice can turn a simple product question into a technical migration before there is evidence that the product needs it. Even when the code is clean, the time and attention spent on the wrong problem are difficult to recover.</p><p>There is also a momentum cost. When the next step is unclear, developers often respond by choosing work that feels concrete: refactoring, reorganising a backlog, adding flexibility, or building a feature that might be useful later. None of those actions is inherently wrong, but they can become a way of avoiding the harder decision about what the project needs now.</p><p>The most expensive mistakes are often not dramatic failures. They are reasonable-looking choices repeated for several weeks without a clear connection to an outcome. By the time the mismatch becomes visible, there is more code, more context to unwind, and less willingness to revisit the original assumption.</p><p>This is why making a decision explicit matters. It does not guarantee that the decision will be right, but it makes the reasoning visible enough to challenge, test, and change when new evidence arrives.</p><h3>A lightweight decision framework before opening the editor</h3><p>The goal is not to turn every product choice into a workshop. Most decisions do not need a long document, and a framework should not become another way to delay work. The useful version is small enough to write in a few minutes, but specific enough that someone else could understand why you chose a direction.</p><p>Before starting a meaningful piece of work, I find it useful to make five things explicit.</p><h3>1. Outcome</h3><p>Start with the change you want to create, not the feature you are tempted to build. “Add team roles” describes an implementation; “allow an account owner to control who can access sensitive project data” describes an outcome. The distinction matters because an outcome leaves room for simpler solutions.</p><p>A clear outcome also gives you a way to evaluate the work later. If the feature ships but the user’s situation does not improve, it is easier to see that the implementation may have been correct while the decision was not.</p><h3>2. Constraints</h3><p>Every project has constraints, even when they are not written down. Time to validate an idea, the number of people maintaining the system, an existing technology choice, reliability requirements, and the cost of a mistake all affect what a proportionate solution looks like.</p><p>Making those constraints visible prevents an abstract discussion about the “best” approach. There is rarely one. There is only an approach that is sensible for this project, with these limits, at this point in time.</p><h3>3. Options</h3><p>Write down two or three credible alternatives before committing. This does not mean generating a catalogue of every possible architecture; it means avoiding the assumption that the first workable approach is automatically the right one.</p><p>For example, an MVP that needs basic access control might consider a single owner/member distinction, a small set of fixed roles, or a fully configurable permissions system. Each option has a different cost, level of flexibility, and risk of becoming difficult to change later.</p><h3>4. Good enough</h3><p>This is usually the hardest question: what is the smallest decision that is safe and useful for the current stage? A mature product with complex enterprise requirements may need a flexible permission model. An early product trying to learn whether teams will collaborate at all may only need to distinguish an owner from everyone else.</p><p>“Good enough” is not an excuse for careless work. It is an acknowledgement that completeness has a cost, and that a decision should be proportionate to the evidence available today. The important part is to state what the solution deliberately does not cover and what evidence would justify revisiting it.</p><h3>5. Reversibility</h3><p>Finally, ask how difficult the choice will be to undo. Some decisions are cheap experiments: a copy change, a temporary workflow, or a limited feature flag. Others create data models, public APIs, operational dependencies, or user expectations that become expensive to unwind.</p><p>A decision that is easy to reverse does not need the same level of certainty as one that will shape the project for a year. This is a useful way to avoid both extremes: treating every choice as permanent, or treating a consequential choice as though it were a harmless experiment.</p><p>Applied to the permissions example, the reasoning might be simple: the immediate outcome is to let an account owner invite one collaborator; the constraint is a short validation window; the alternatives are owner/member roles or a configurable permission system; good enough is the owner/member model; and the decision is reversible if the data model does not assume there will only ever be two roles. That is not a perfect answer, but it is a decision with a visible rationale.</p><p>Writing this down does not make uncertainty disappear. It makes uncertainty concrete enough to discuss, challenge, and revisit. That is often more valuable than moving directly from a vague concern to a confident-looking implementation.</p><h3>Use AI after the decision is framed</h3><p>This is not an argument for using less AI. It is an argument for using it at a point where it has a better chance of being useful. Once the outcome, constraints, options, and level of reversibility are clear, an AI assistant can help examine the decision instead of filling a vacuum with a plausible-looking answer.</p><p>Consider the difference between asking:</p><blockquote><em>“Design the architecture for my SaaS.”</em></blockquote><p>That request contains almost none of the information that makes an architecture decision meaningful. The assistant has to invent the product’s needs, scale, constraints, team, and tolerance for operational complexity. It may produce a detailed answer, but detail is not evidence that the recommendation fits the project.</p><p>A more useful request gives the decision its context:</p><blockquote><em>“I am building an MVP for independent consultants who need to share project updates with clients. I need to validate whether they will use it within four weeks. I am working alone and want to keep operational complexity low. I am deciding between a single application with a relational database and a separate event-driven service for notifications. Which option is proportionate for this stage? What risks am I missing, and what would justify revisiting the decision later?”</em></blockquote><p>The second prompt is not better because it uses more words. It is better because it states what is being optimised for and what trade-off is actually under consideration. It gives the model enough material to identify assumptions, compare alternatives, and point out risks that the developer may have missed.</p><p>There are several useful roles for AI at this stage. It can challenge whether the stated outcome is specific enough, generate alternatives that deserve consideration, explain the consequences of each option, and help turn a choice into a short decision record. It can also identify questions that should be answered by users, measurement, or a small experiment rather than by technical reasoning alone.</p><p>None of this turns an LLM into a source of authority. The developer still needs to judge whether the context is accurate, whether the advice applies, and whether the resulting change is safe to make. The value is in making the reasoning more explicit and easier to examine — not in delegating responsibility for the decision.</p><h3>Why I’m building Hakkle</h3><p>This gap is what led me to build <a href="https://gohakkle.com/">Hakkle</a>. I kept returning to the same question: if implementation tools are becoming faster and more capable, what would help a developer make the decisions around that implementation with more clarity?</p><p>The hypothesis behind Hakkle is not that an AI should make those decisions for someone. It is that a project-aware technical coach could help a developer keep track of goals, constraints, prior choices, and open questions, then use that context to examine the next decision. The aim is to support planning, prioritisation, architecture discussions, and trade-offs without reducing them to a stream of isolated prompts.</p><p>It is still an early idea, and the distinction matters. A general-purpose LLM plus good notes may already be enough for many people and many projects. I am trying to learn where persistent project context and a more deliberate decision process provide real value, and where they simply add another tool to maintain.</p><p>For now, I am treating Hakkle as a validation exercise as much as a product. The useful outcome is not proving that every developer needs a technical coach; it is understanding which decisions developers find most difficult, how they currently work through them, and whether a tool can help without creating false confidence or additional friction.</p><h3>Closing reflection</h3><p>The conversation around AI often focuses on how quickly we can build. That is an important improvement, but speed only becomes valuable when it is applied in the right direction. Writing code has become cheaper than it has ever been. Time, attention, and good judgment have not.</p><p>Most successful projects are not defined by a single brilliant architectural decision or perfectly generated implementation. They are shaped by hundreds of small choices about what to build now, what to postpone, what assumptions to test, and what complexity can wait. Those decisions remain difficult because they depend on context, constraints, and goals that no model can infer on its own.</p><p>AI is an excellent partner for exploring ideas, comparing options, and accelerating execution once the problem is understood. But before asking it to write the next function or design the next service, it is worth spending a few minutes making the decision itself explicit. A clear question almost always leads to a better answer.</p><p>Better software does not come from generating the most code. It comes from making the next decision clearly enough that the code has a purpose. AI can accelerate implementation; the harder work is still deciding what deserves to be implemented.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01b4df7753e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Database Evolution Becomes a Machine Learning Problem]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@maciejrokrawczyk/when-database-evolution-becomes-a-machine-learning-problem-dc65a73baa33?source=rss-c2efbfe5288a------2"><img src="https://cdn-images-1.medium.com/max/1200/1*TcXm_wXJQRNR1xPTA49ceA.png" width="1200"></a></p><p class="medium-feed-snippet">Lessons from the Stone-Masters project on schema evolution, high-dimensional data, and the hidden costs of growing databases.</p><p class="medium-feed-link"><a href="https://medium.com/@maciejrokrawczyk/when-database-evolution-becomes-a-machine-learning-problem-dc65a73baa33?source=rss-c2efbfe5288a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@maciejrokrawczyk/when-database-evolution-becomes-a-machine-learning-problem-dc65a73baa33?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc65a73baa33</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[digital-humanities]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[archaeology]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Mon, 15 Jun 2026 12:01:00 GMT</pubDate>
            <atom:updated>2026-06-15T12:01:00.768Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[React 18 and Next.js mentorship plan]]></title>
            <link>https://medium.com/@maciejrokrawczyk/react-18-and-next-js-mentorship-plan-3094b6baac4d?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3094b6baac4d</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 18:26:31 GMT</pubDate>
            <atom:updated>2023-10-11T18:26:31.399Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>Just created one, feel free to use and share.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e1yHQgw_WiZtSgUH" /><figcaption>Photo by <a href="https://unsplash.com/@clarktibbs?utm_source=medium&amp;utm_medium=referral">Clark Tibbs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Intro</h3><p>Some time ago my boss asked me if I want to become a mentor for someone from our team. At first I was hesitant. Do I have all necessary skills. Do I have required knowledge? And most importantly, do I have all necessary soft skills to handle this job? But after all I did agree. Why? Because it’s a challenge for my interpersonal skills (yay, another introvert) and opportunity to learn. Also there’s always a hope that no one will want to become my mentee, right?</p><p>As always my assumptions were not right and there’s a person who wants to learn from me. Now what? After short panic attack I’ve decided that first I need to have some discussion with the guy and obtain knowledge on what he needs to learn and if I’ll even be able to help him. And after brief meeting I knew what I should prepare and what I will be able to do for my first mentee. Basically he needed a directions and some starter materials to kick-start his learning process about React 18 and Next.js.</p><h3>Plan and materials</h3><p>At first I have my doubts, how should it look? Should it be more formal or short talk is enough? In the end I decided on creating plan with list of some basic knowledge sources. Why? Because I can reuse it, for me it’s easier to create structured list than transfer this informations by talking. And that’s how this list started.</p><p>Beginning was hard as usual, how should I start? I believe that all people doing any writing or similar things knows what fear of blank page is. How to overcome it? Some time ago I found the solution that works for me. You don’t know how to start? Ask ChatGPT about it. Answer may be crappy, missing some parts or even straight wrong. But you have something, your page is not blank any more.</p><p>After some changes here or there, some tweeking I came with that list (supplemented by links to some great articles with additional knowledge about each topic):</p><ol><li>Getting Started with React 18:</li></ol><ul><li>Introduction to React 18 and its key features (Concurrent Mode, Suspense, Server Components) — <a href="https://medium.com/@vyakymenko/react-18-a-comprehensive-guide-to-the-latest-features-and-improvements-82825f209ae7">React 18: A Comprehensive Guide to the Latest Features and Improvements</a> by <a href="https://medium.com/@vyakymenko">Valentyn Yakymenko</a></li><li>Building a basic React 18 app with Concurrent Mode and Suspense. — <a href="https://geekpaul.medium.com/lets-build-a-react-from-scratch-part-3-react-suspense-and-concurrent-mode-5da8c12aed3f">Let’s build a React from scratch: Part 3 — React Suspense and Concurrent Mode</a> by <a href="https://geekpaul.medium.com/">Arindam Paul</a></li></ul><p>2. Deep Dive into React 18:</p><ul><li>Understanding the React 18 architecture and how it improves performance: <a href="https://legacy.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html">Introducing Zero-Bundle-Size React Server Components</a> by <a href="https://twitter.com/dan_abramov">Dan Abramov</a>, <a href="https://twitter.com/potetotes">Lauren Tan</a>, <a href="https://twitter.com/en_JS">Joseph Savona</a>, and <a href="https://twitter.com/sebmarkbage">Sebastian Markbåge</a>, <a href="https://vercel.com/blog/how-react-18-improves-application-performance">How React 18 Improves Application Performance</a> by <a href="https://x.com/lydiahallie">Lydia Hallie</a></li><li>Implementing Server Components and exploring their advantages: <a href="https://blog.saeloun.com/2023/07/20/what-are-react-server-components/">An In-Depth Look at React Server Components!</a> by <a href="https://blog.saeloun.com/authors/chetan/">Chetan Gawai</a></li></ul><p>3. Introduction to Next.js:</p><ul><li>Setting up a Next.js project and understanding its file-based routing system: <a href="https://medium.com/@alvarolosada/file-based-routing-in-next-js-13-ac7829f55372">Next.JS — Application Setup and File Based Routing</a> by <br><a href="https://medium.com/@alvarolosada">Alvaro Losada</a>, <a href="https://nextjs.org/docs/app/building-your-application/routing">Routing Fundamentals</a> from Next.js docs</li><li>Building a basic Next.js application with static and server-side rendering: <a href="https://tsh.io/blog/ssr-vs-ssg-in-nextjs/">SSR vs SSG in Next.js — a practical overview for CTOs and devs</a> by Norbert Sajdok</li></ul><p>4. Advanced Next.js Features:</p><ul><li>Implementing API routes in Next.js for serverless functions: <a href="https://blog.logrocket.com/build-api-serverless-functions-next-js/">Build an API with Serverless Functions in Next.js</a> by <a href="https://blog.logrocket.com/author/lawrenceoputa/">Lawrence Eagles</a></li><li>Adding authentication and authorization to a Next.js app: <a href="https://blog.logrocket.com/implement-authentication-authorization-next-js/">How to implement authentication and authorization in Next.js</a> by <a href="https://blog.logrocket.com/author/kingsleyubah/">Kingsley Ubah</a></li><li>Integrating popular databases and third-party APIs into Next.js applications: <a href="https://betterprogramming.pub/learn-how-to-build-apis-with-next-js-109d381f8b30">Learn How To Build APIs With Next.js</a> by <a href="https://medium.com/@colegawin?source=user_profile-------------------------------------">Cole Gawin</a>, <a href="https://medium.com/@masader-tech/serverless-functions-in-next-js-a-practical-guide-4499db842d26">Serverless Functions in Next.js: A Practical Guide</a> by <a href="https://medium.com/@masader-tech?source=user_profile-------------------------------------">Masader Tech</a></li></ul><p>5. Combining React 18 and Next.js:</p><ul><li>Integrating React 18 with Next.js applications for improved performance: <a href="https://www.codemotion.com/magazine/frontend/optimize-next-js-for-production/">How To Optimize Next.js for Production</a> by <a href="https://www.codemotion.com/magazine/author/antonello-zanini/">Antonello Zanini</a>, <a href="https://blog.logrocket.com/react-server-components-next-js-13/">React Server Components in Next.js 13</a> by <a href="https://blog.logrocket.com/author/chinwikemaduabuchi/">Chinwike Maduabuchi</a></li><li>Implementing Suspense and Concurrent Mode in Next.js: <a href="https://learnjsx.com/category/4/posts/nextjs-suspense">How to use React Suspense in Next.js</a> by Ali Bentaleb, <a href="https://ekqt.medium.com/understanding-suspense-with-next-13-4fb08457f1a">Understanding Suspense with Next 13</a> by <a href="https://ekqt.medium.com/?source=user_profile-------------------------------------">Héctor Sosa</a></li></ul><p>6. Deployment and Optimization:</p><ul><li>Deploying React 18 and Next.js applications to popular hosting platforms: <a href="https://blog.logrocket.com/8-ways-deploy-react-app-free/">8 ways to deploy a React app for free</a> by <a href="https://blog.logrocket.com/author/ashutoshsingh/">Ashutosh Singh</a></li><li>Performance optimization techniques for React 18 and Next.js: <a href="https://blog.logrocket.com/optimizing-performance-react-app/">Optimizing performance in a React app</a> by <a href="https://blog.logrocket.com/author/ibadehinmojeed/">Ibadehin Mojeed</a>, <a href="https://levelup.gitconnected.com/react-js-performance-optimization-techniques-39728d89e56e">React.js Performance Optimization Techniques</a> by <a href="https://mansimanhas.medium.com/?source=user_profile-------------------------------------">Mansi Manhas</a></li><li>Testing, monitoring, and scaling strategies for production-ready applications: <a href="https://www.freecodecamp.org/news/deployment-strategies-for-nextjs-apps/">How to Choose a Deployment Strategy for Your Next.js Application</a> by <a href="https://www.freecodecamp.org/news/author/tobezzi/">Tobenna Okeke</a></li></ul><h3>Summary</h3><p>Let’s sum up, this article describes my journey of embracing the role of a mentor. Despite initial doubts about my qualifications, I accepted the challenge with the goal of fostering both my interpersonal skills and personal growth. And maybe helping someone in the same time.</p><p>I hope the mentorship plan I’ve created covers essential topics, including React 18 and Next.js fundamentals, advanced features, integration strategies, and deployment practices. If you think that it’s missing something or need any other improvement just let me know in the comment.</p><p><strong>Now, it’s your turn!</strong> If you’re passionate about something particular in programming landscape, or mentoring, consider taking up the mantle of a mentor. Whether you’re an experienced developer or just starting, mentoring can be a mutually rewarding experience. Your mentorship could be the catalyst for someone else’s success. Get started today! Any comments about the plan I prepared? Treat this as an invitation to discussion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3094b6baac4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Went to an Archaeological Conference. What Can Software Engineers Learn From Humanities?]]></title>
            <link>https://medium.com/better-programming/i-went-to-an-archaeological-conference-what-can-software-engineers-learn-from-humanities-f57b89997e11?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f57b89997e11</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[archaeology]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 16:16:19 GMT</pubDate>
            <atom:updated>2023-04-27T16:16:19.934Z</atom:updated>
            <content:encoded><![CDATA[<h4>Last year, one of my colleagues asked if we wanted to present our application at a conference. Hesitantly, I agreed.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSYPnOq02MwvUH8A2sEG4g.jpeg" /><figcaption>CAA conference official banner, source: <a href="https://2023.caaconference.org/">https://2023.caaconference.org/</a></figcaption></figure><p>I have to start with a short disclaimer. Even though I work as a software engineer, and that’s the career path I settled for, I am an archaeologist.</p><p>I have a master’s degree in Archaeology and started my Ph.D. in that field but dropped out after a year or so. After some additional career changes, I found my path in software engineering and programming, but I still have a passion for archaeology left in me. Also, my wife is an archaeologist (a real one).</p><p>Based on that, I often get involved in side projects and co-operations with archaeologists. Mostly, I work on data-collecting applications for field work and further analysis for projects in archaeology and broader historical sciences. Back then, when I started with those kinds of applications, there were hardly any good open source solutions for such tasks — or so I thought. Also, it was at the beginning of my software engineering path. So, I settled for custom solutions each time. Sometimes, it was in requirements; sometimes, it was due to a lack of better existing solutions. But in most cases, it was my decision. And it was probably the wrong one.</p><h3>About the Conference</h3><p>Last year, one of my colleagues asked if we wanted to present our application at a conference. Hesitantly, I agreed. I was not sure if we would have something worth presenting and also if I would find other papers interesting. But after the conference, I can say it was worth every minute spent there. And that’s how I found myself in Amsterdam, <a href="https://2023.caaconference.org/">at CAA 2023</a>, at the beginning of April.</p><p>But what does CAA stand for? According to their website:</p><blockquote>Computer Applications and Quantitative Methods in Archaeology (CAA) is an international organisation bringing together archaeologists, mathematicians, and computer scientists. Its mission is to encourage and facilitate dialogue between these disciplines, to provide an overview of the present state of the discipline, and to stimulate discussion to progress the field. […]</blockquote><blockquote>CAA organises an annual international scientific conference covering a wide range of topics, including data acquisition and recording, conceptual modelling, semantic technologies, data analysis, data management, digital 3D object reconstruction, image visualisation in archaeology, geophysics, and GIS. The conference format includes thematic paper and poster sessions as well as round tables and workshops.</blockquote><p>And this was the 50th annual conference. Yup, the first one took place in 1972 (there was no conference in 2020 due to obvious reasons). Two years after Edgar F. Codd published his paper on relational data model, and two years before D.D. Chamberlin and R.F. Boyce published their paper on SQL (called SEQUEL back then). I was pretty surprised to find out that in that analog world, there were people with such vision to start going in a digital direction despite all of that seeming temporary. They were true early adopters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yd59bb6l0qiU8jwL5Imlqg.jpeg" /><figcaption>Photo by author</figcaption></figure><p>The conference took place in the lovely city of Amsterdam. It was fully packed with presentations about deep learning, 3D data modeling, web and mobile data collection solutions, GIS and mobile GIS, and gamification. The first day contained various workshops, and the other three contained presentations.</p><h4>Why</h4><p>Most sessions I attended were focused on collecting data (also in the field), creating tools for further analysis, and presenting the research results. To be honest, I wasn’t prepared for what I saw. The amount of clever and well-thought-out tools and solutions I saw a bit were overwhelming and exceeded my wildest expectations. Also, to be perfectly honest, I must mention that many of them caused a little sting of jealousy. The good kind that boosts your creativity, the one saying, “Whoa, that’s awesome. Why I haven’t thought about that?”</p><p>But also, many more topics were discussed at the conference, like deep learning, 3D modeling, or gamification. But they were not my primary interests, so I focused on the abovementioned ones.</p><h4>What I learned</h4><p>For me, there were three main outcomes of attending such a conference. First, and most importantly, I learned (or rather was reminded) that I don’t always have to go the custom path. Sometimes, it’s better to use existing solutions and even sacrifice a few planned features to use a more standardized approach. There was a terrific quote I saw in one of the presentations:</p><blockquote>“Standardized is better than perfect.”</blockquote><p>Sadly, I don’t remember whose presentation it was and where it was taken. And I’m sorry I can’t give proper credit to the person who said that. But it reminds us that creating software is a game of compromises between what we want, what clients want, what is even possible, and time and money constraints.</p><p>The second great outcome for me was a huge boost in creativity and motivation from all the examples of adapting tools and empowering work empowered by tools instead of being defined by them. For example, there was almost a whole session discussing the usage of LiDAR (Light Detection and Ranging) sensors in the latest versions of the iPhone to document the archaeological features in a three-dimensional way. Back in my day (that sounds awful), when I was still working in archaeology nine or ten years ago, tools used for that were extremely expensive and required trained operators. Now everyone can do this. That’s mind-blowing.</p><p>The last outcome for me was a great opportunity to confront my software development approach with effective, radically different, and no less creative approaches. The possibility to see less conservative, free-from-bias points of view helps us better understand our clients and their needs. Even though they rarely have a scientific background. Also, looking for a little science in our work helps us understand what we are doing and aiming for.</p><h4>What you can learn</h4><p>Based on what I saw at this conference and what I see in my day-to-day job, many development teams and software developers could benefit from a little change in approach. Being a bit scientific in our work can give us wider perspectives to solve problems. Also, it allows us to be more resourceful. Don’t get me wrong, I don’t want to criticize any development methodologies here. I don’t have anything against Agile and Scrum. Quite the opposite; I love them.</p><p>On the other hand, this kind of lean approach, working with what one has and using more complex solutions only when strictly necessary, can benefit everyone. Also, most importantly, it limits bloat in a project, which is great for development teams. To be honest, academias are one of the most bureaucratically-bloated organisations I’ve ever seen (so far). But when we give that to teams working on single projects, they can oppose that trend and work efficiently toward their goals.</p><p>Also, I believe this kind of conference is the best place to learn new, creative ideas, as it gives you access to the most creative usage of tools. Sometimes, we are so used to our expertise that we are blind to other solutions, and the only thing needed to realize that is a new perspective. That’s the easiest way to make us leave our cozy programming comfort zone — which is where the growth is.</p><h4>Why IT and science communities should meet more often</h4><p>Because it’s the best and easiest way to get a wider perspective to see your software differently. Also, this meeting can easily fuel your curiosity and creativity. Limiting ourselves to tech conferences can cripple our view of the tech landscape.</p><p>Why humanities and not, for example, math conferences? If you are not strictly math-oriented in your work, the entry threshold may be too high. Don’t get me wrong, I’m not saying that humanities are easier. You may not be able to get all the intricacies of problems discussed, but when you see the pyramid, you know what it is. Also, I believe that between us, there are a lot of people who don’t have a background in CS. And going back to your roots and previous passions can be most refreshing and beneficial.</p><p>If I can convince anyone to try that and be more scientific in their work, read something about that, or maybe attend conferences that bridge one’s interests and software, I would be the happiest person in the world.</p><h3>Summary</h3><p>I was amazed to learn that scientific communities are the best place to look if you are looking for true early adopters for your solutions. They may not have the largest budgets, but they have a huge curiosity.</p><p>Am I going to next year’s CAA conference? I’d love to, but due to logistic problems, it may not be possible. It will take place in Auckland in New Zealand, directly from my place to the other side of the globe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f57b89997e11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/i-went-to-an-archaeological-conference-what-can-software-engineers-learn-from-humanities-f57b89997e11">I Went to an Archaeological Conference. What Can Software Engineers Learn From Humanities?</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Your Own E-Commerce Keystone.js-Based System — Build a Cart]]></title>
            <link>https://medium.com/better-programming/creating-your-own-e-commerce-keystone-js-based-system-build-a-cart-8c433ccf5443?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c433ccf5443</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[keystonejs]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 13:09:46 GMT</pubDate>
            <atom:updated>2022-04-27T13:09:46.974Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating Your Own E-Commerce Keystone.js-Based System — Build a Cart</h3><h4>Next steps in our journey to create our own e-commerce system</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XL5juiHya_D7mse6" /><figcaption>Photo by <a href="https://unsplash.com/@neonbrand?utm_source=medium&amp;utm_medium=referral">Kenny Eliason</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Intro</h3><p>Some time ago I had a wild idea to use Kesytone.js to build an e-commerce system. This journey started a couple of weeks ago, and until now we’ve talked about <a href="https://betterprogramming.pub/build-your-own-e-commerce-keystone-js-based-system-requirements-and-architecture-3d639241b963">system requirements</a>, <a href="https://betterprogramming.pub/build-your-own-e-commerce-keystone-js-based-system-environment-setup-and-base-models-2c02a3e3a70b">environment setup and base models</a>, and <a href="https://betterprogramming.pub/building-your-own-e-commerce-keystone-js-based-system-access-control-1a366ed7e064">access control</a>. In this article, let’s focus on main cart functionalities. Also, the finished code for this article is available on my <a href="https://github.com/eabald/keystone-e-commerce/tree/Cart">GitHub</a>.</p><h3>Cart Flow</h3><p>In previous parts of this series, when we set up the basic schemas, we decided that each user would have only one cart, and it would contain all added products until the user created an order from that cart. Based on that, users can perform three kinds of operations on their cart. First, there’s the possibility to add an item to the cart, then remove it and change its quantity.</p><p>Also, there’s one major issue to consider, and it’s more of a business than a technical problem. Should we allow users to add more products to the cart than is currently available? I mean, in the case where the product has stock, for example, four items are available, but the user tries to add to cart five, what should happen in that case?</p><p>Of course, that issue should be secured in UI, but in some cases, it can happen anyway. Using SSR and Next.js has some drawbacks, and in the most basic case, the quantity of available products is only checked on page rendering. This may lead to cases when product availability may change in the time between render and the moment of adding a product to the cart.</p><p>There are two main solutions: first, block adding to the cart in that case or move this validation step forward and block creating orders with products out of stock. Despite our decision, this step is necessary from a security point of view.</p><p>I believe there’s a third solution to this problem — something in between the previously mentioned two. Stock schema includes information about the next delivery, so if there aren’t enough items in stock, but together it’s enough then the user can add it to the cart. But the order will be delayed because of that.</p><p>On the other hand, if there’s no next delivery information, it will be blocked. This solution should ensure better user retention and what’s more important is more interesting to implement.</p><p>With that out of the way, we can focus on each of these three operations. First, add a product to the cart. There are basically two steps in that. Validate stock and update products in the cart. The same applies when updating the quantity. Removing products is just an update to the cart model, right? Not exactly. Let’s take a look on our Cart schema:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32f6f49b4867a1e2b56d3cf9c1fba92a/href">https://medium.com/media/32f6f49b4867a1e2b56d3cf9c1fba92a/href</a></iframe><p>There is related to Product list, but there’s no way to store information about the quantity of added products. So, we have to create an intermediate list (called a pivot table in SQL nomenclature) to handle the many-to-many relationship and store the quantity information.</p><h3>Cart Items List</h3><p>The main purpose of this list is to store relationships between Cart and Product entities and quantity information. Basically, it should be only requested as a relation from Cart. There’s no point in requesting it directly. Let’s create cart-product.schema.ts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e631897e40004bbfed50dbc8e1a9a883/href">https://medium.com/media/e631897e40004bbfed50dbc8e1a9a883/href</a></iframe><p>But wait, there’s only two fields? It’s simple, this list doesn’t need to know anything about Cart or what these products belong to. But on the other hand, Cart model needs this information, so we have to update this list and change the relation from Product to CartProduct. Additionally, there&#39;s no longer a need to hide the possibility of creating this entity from Admin UI.</p><pre>products: relationship({<br>  ref: &#39;CartProduct&#39;,<br>  many: true,<br>}),</pre><p>OK, now we can update our flows:</p><ul><li>Adding to cart:<br> 1. Validate stock<br> 2. Create CartProduct entities<br> 3. Update Cart model</li><li>Remove product from cart:<br> 1. Remove CartProduct entity<br> 2. Update Cart</li><li>Change quantity in cart:<br> 1. Validate stock<br> 2. Update CartProduct entity<br> 3. Update Cart</li></ul><h3>A Word or Two on Framework Abstractions and Their Limitations</h3><p>But why all that trouble? Let’s take a look at the current ER diagram of our database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WP4DqRdyBPwnYiaWAgM3w.png" /></figure><p>We have our Cart, CartProduct, and Product tables, but also there’s _Cart_products table. We didn’t create the last one, right? Undelaying Prisma did that for us. That’s why it’s good to have a basic understanding of the tools we use.</p><p>Prisma has two ways of creating many-to-many relations (<a href="https://www.prisma.io/docs/concepts/components/prisma-schema/relations/many-to-many-relations#relational-databases">more information’s available in the docs</a> ), explicit or implicit. In the first one, we are responsible for creating pivot tables and relationships on other tables in our schema.prisma file. In the second one, we skip the pivot table and ORM creates it for us.</p><p>But in our case, we don’t have direct control over the schema.prisma file; Keystone takes care of that and uses the implicit method. In most cases, it’s perfectly fine, but sometimes it may have some drawbacks, like this unnecessary table here.</p><p>Frameworks usually hide many implementation details under the thick abstraction layer, which is a good thing in most cases. It allows developers to focus on business logic and work faster and more efficiently. But in some cases, we have to accept some issues.</p><h3>Hooks and Validation Flow</h3><p>To perform all the steps involved in each cart operation we need a tool that allows us to perform some side effects, including additional validation while updating Cart schema. Fortunately, Keystone has the perfect tool for that.</p><p>There’s Hooks API, which does exactly that on the whole schema or particular fields in it. There are five of them:</p><ul><li>resolveInput allows us to modify input data before validation on create or update operation.</li><li>validateInput and validateDelete gives us the possibility to return additional validation errors in the create/update and delete operations, respectively.</li><li>beforeOperation handles side effects before database operation</li><li>afterOperation does the same but after operation.</li></ul><p>Read more about hooks in the <a href="https://keystonejs.com/docs/guides/hooks">docs</a>.</p><p>OK, let’s get back to our system. The entire flow is simpler than it looks; we only need to use two hooks (the third is a bonus). First, let’s assume every updateCart mutation has to have all products currently in the cart (previously added too). That way, when we submit a list of products, cart content is set to this list. When there&#39;s an empty list, the cart content is cleared, and when there’s no product list, the cart content is not changed. So, for example, a mutation should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4263d81c13a780357c9c659501d2d252/href">https://medium.com/media/4263d81c13a780357c9c659501d2d252/href</a></iframe><p>In order to handle that, we have to remove all CartProduct entities and add a new one on each update. To do that, we need to use the beforeOperation hook in Cart schema:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60bbeb121d727ebd2c6a0fd949397f0d/href">https://medium.com/media/60bbeb121d727ebd2c6a0fd949397f0d/href</a></iframe><p>It’s quite simple — when there are products in the update mutation, then we query and remove all currently added products. After that, the current operation adds back all appropriate products with new/updated stocks. Also, when the data’s resolved and there’s an empty list of products, the cart content will be cleared.</p><p>OK, that’s the part about updating cart content, but what about stock validation. Shouldn’t it have happened before that? Yes, but it should happen in CartProduct schema, not directly in the cart. We are going to add the validateInput hook:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7538ba6cfaf4a2d29513071779eee43/href">https://medium.com/media/e7538ba6cfaf4a2d29513071779eee43/href</a></iframe><p>Here, it checks stock on each product and compares the requested amount with the combined stock and amount in the next delivery. If it’s not enough, we call the addValidationError function to create a validation error. This method is almost perfect. There’s only one issue: CartProduct entities are created before the cart is updated, and when there’s a validation error, the Cart entity won’t be updated.</p><p>But some rows in the first schema may have already been created, and it may leave orphan entries in CartProduct table. It’s a perfect example of a case when the transaction should be used, but for now, there’s no such option in Keystone. According to <a href="https://github.com/keystonejs/keystone/issues/7217">this</a> issue, it may change in the near future.</p><p>What about the last bonus hook? In Cart, there’s sum field containing information about the value of the entire cart, and we need a way to calculate it. The resolveInput hook works the best:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82e4057ac02a210b371954299564ece0/href">https://medium.com/media/82e4057ac02a210b371954299564ece0/href</a></iframe><p>It takes all products associated with this cart and sums up their amounts and prices. And after that, the data to save into the database is updated.</p><h3>Summary</h3><p>Now, we’ve finished the cart part of our e-commerce system. To be honest, this part of the application was harder to develop than I’d anticipated at first. But also, the implementation was not so difficult. Most of the work was thinking about the best way to solve that problem, not the problem itself.</p><p>For various reasons, it took me longer than I’d planned, and I hope you liked it. If you have any questions or comments, feel free to ask them.</p><p>A side project has one nasty characteristic: At first, they are exciting and interesting, but after some work, we don’t feel that way any longer. And I believe that’s why writing this part took me so long.</p><p>Don’t get me wrong, I’m still planning to finish this series and build this system, but in order to not lose the fun in it — and to prevent it from becoming a chore in the next article — I’ll take a break and write about something else.</p><p>See you there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c433ccf5443" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/creating-your-own-e-commerce-keystone-js-based-system-build-a-cart-8c433ccf5443">Creating Your Own E-Commerce Keystone.js-Based System — Build a Cart</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Your Own E-Commerce Keystone.js-Based System — Access Control]]></title>
            <link>https://medium.com/better-programming/building-your-own-e-commerce-keystone-js-based-system-access-control-1a366ed7e064?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a366ed7e064</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[keystonejs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Fri, 01 Apr 2022 00:59:15 GMT</pubDate>
            <atom:updated>2022-04-01T00:59:15.163Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Your Own E-Commerce Keystone.js-Based System — Access Control</h3><h4>Improving upon our e-commerce based system</h4><figure><img alt="A grocery store" src="https://cdn-images-1.medium.com/max/1024/0*FMA5fhf0VcWmhXIG" /><figcaption>Photo by <a href="https://unsplash.com/@nathaliarosa?utm_source=medium&amp;utm_medium=referral">Nathália Rosa</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>It’s time to continue our series on creating a Keystone.js-based e-commerce system. Previously, we focused on creating all basic models and environment setups. This time we will work on access control and users privileges. Let’s be honest, not all users should be allowed to access all data and have the ability to modify it. It is a serious security risk, so this time we are going to fix it. Also, the finished code for this article is available on my <a href="https://github.com/eabald/keystone-e-commerce/tree/Access-control">GitHub</a>.</p><h3>Requirements</h3><p>So, what are our requirements here? First, we need to restrict users&#39; access based on their role in the system. Basically, customers can only modify data associated with them, but admins have much more privileges. All of this should affect the system on three levels: first, restrict access to Admin UI, then filter access based on operation type to each schema, and lastly on the level of some fields in schemas.</p><h3>Access Control Implementation</h3><p>First, let’s update user roles in our system. In the previous article, we started with two of them — admin and customer. The basic assumption was that we need two different levels of security with user privileges, but after some consideration, I decided we need another one. So it’s time to update our roles.enum.ts and roles.const.ts and add the employee role. For now, privileges for admin and employee will stay the same, but with further system development it may change, as you can see below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/976e75db580718bfcfe6aafb0a69156b/href">https://medium.com/media/976e75db580718bfcfe6aafb0a69156b/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebd6d7cbfb7c7c407b82bc1b5d406f74/href">https://medium.com/media/ebd6d7cbfb7c7c407b82bc1b5d406f74/href</a></iframe><p>With that out of the way, we can focus on Admin UI access. For sure, all admins and employees should be able to use it; it’s necessary. But customers should not be able to access it. Of course, they need to log into the system and create sessions, but the Admin UI contains sensitive information that mustn’t be widely accessible.</p><p>Out of the box, Keystone offers the perfect solution for this kind of problem. To restrict certain users from accessing Admin UI, we just have to update our main config file, keystone.ts and ui.isAccessAllowed option. Its function with the context parameter will return a boolean value. Previously, we were only checking if users had valid session data. Now we have to check if the user has a valid session and if their role is not equal to customer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76568892340971f8ae5603adff7b19da/href">https://medium.com/media/76568892340971f8ae5603adff7b19da/href</a></iframe><p>And that’s all; only users with the right role will be able to access Admin UI. Now, it’s time to focus on access control at the level of each schema. Basically, there are two types of restrictions we are going to use: first, everyone can query but only internal users (admin and employee) can modify it. The second case covers a scenario when internal users have full access, but customer user can only query and update dates that belong to that user.</p><p>Let’s walk through all the schemas and update the access property on each of them. First, the Address list: it contains sensitive data so only admins and owners of specific records should be able to access it.</p><p>In Keystone.js’s access API, there are three levels of control (<a href="https://keystonejs.com/docs/apis/access-control">read more</a>), operation, filter, and item. First one, operation allows restricting what kind of operation can be done on the list (query, create, update, and delete). Second, filter allows adding specific GraphQL filters to every operation performed on this list with distinction to its type (same as before, but without create). Last one, item works more on the data level and allows us to inspect data passed to each operation, but it works only on mutations, so has no effect on queries.</p><p>All properties in this section of the list configuration are functions. The first and last should return boolean; the second one should return GraphQL filter.</p><p>In case of Address list on the operation level, we only need to check if the user is authenticated, but on the filter level, we have to check if the user is admin or employee. Then there’s no necessity for an additional filter.</p><p>But when the user’s role is customer, we have to create and add filters limiting results only to this user. These functions will be rather similar for each schema, so I’ve decided to move them to another file to prevent unnecessary repetition. I’ve created a shared folder and index.ts inside. Also, I’ve created a file for our new method called filter-customer-access.ts and added it into exports in index.ts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8144eec4d879a89d6d7786a71e9fbda9/href">https://medium.com/media/8144eec4d879a89d6d7786a71e9fbda9/href</a></iframe><p>Basically, it creates and returns new GraphQL filter checking if the user ID in the record we are trying to access is equal to the ID stored in the current session. Additionally, I’ve added an interface to describe the session parameter, mostly because, in core Keystone files, a session has a type any that is not so convenient.</p><p>We are going to use this method to add this filter to query, update, and delete operations, but not create. First, it’s not possible, and it needs a different approach. We are going to uralitize item level restrictions in this case. The function used here will also be reused, so I’ve created another file in the shared folder called filter-customer-access-create.ts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43bc64ebdad40c44279481772f641889/href">https://medium.com/media/43bc64ebdad40c44279481772f641889/href</a></iframe><p>It looks pretty similar to the previous one, but there are two main differences: first, it returns a boolean value, not filter, and secondly, it checks if the data passed to create mutation has information about the user and if it’s the same user to whom current session belongs. Also, I’ve added export for this method in index.ts. Now it’s time to add it to the Address schema config file and its access section, as you can see below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/351fc56612975a332b1b3c69e79fb49f/href">https://medium.com/media/351fc56612975a332b1b3c69e79fb49f/href</a></iframe><p>Order, Payment, Shipment has the exact same restrictions, so I’ve updated their schemas too. Additionally, in the Order schema, I’ve updated user and employee fields. Previously, they had an option to create a new entity from inside the list which is not really desired here. So I’ve added to this fields’ config:</p><pre>ui: {<br> hideCreate: true,<br>},<br>``</pre><p>Cart schema restrictions are pretty similar with some exceptions. First, there’s no check on the item level. Instead of that, I’ve added another config option — graphql. It contains options directly applied to GraphQL schema and allows disabling certain operations, create in our case.</p><p>Because of that, there’s no way to create new Cart entity via GraphQL API, and it’s something that we want. Cart for user can be created only once, on sign up process. More about that later. I’ve also updated some fields to block the possibility to create a new user and new products from inside this list. The last change was to add the default value to sum field. Here’s the whole updated schema:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32f6f49b4867a1e2b56d3cf9c1fba92a/href">https://medium.com/media/32f6f49b4867a1e2b56d3cf9c1fba92a/href</a></iframe><p>The next group of lists has much simpler restrictions: all users can query them (not authenticated too), but only internal users can create/modify them. This group contains Catgegory, ProductImage, Product, and Stock. In order to apply these restrictions, we have to add access rules on the operation level:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40202c3e1fe677b15c2d6f930eb48387/href">https://medium.com/media/40202c3e1fe677b15c2d6f930eb48387/href</a></iframe><p>In the Stock schema, I’ve also added an additional access rule on field level, amountInNextDelivery to be exact. Information about stock delivery may not be strictly confidential or sensitive, but competition is watching, so better keep it for authenticated users.</p><pre>amountInNextDelivery: integer({<br>  access: { read: ({ session }) =&gt; !!session },<br>}),</pre><p>The last updated schema is User; most changes are pretty similar to the Address list, but there are some exceptions. First, on the item level, we are not restricting the create operation. If we do, no one will be able to register.</p><p>Instead, I’ve added the same restriction to the update operation. Additionally, I’ve utilized hooks here, precisely the afterOperation one. We will talk more about hooks in further parts of this series, but for now, all we have to know is that they allow you to perform side effects in reference to operations performed on the current list.</p><p>Our hook first checks the type of current operation; if it was not the create operation, it returns undefined. But in the case of create, we want to proceed and create a corresponding Cart entity for that new user. But there’s a catch, previously when updating Cart schema I’ve disabled GraphQL API responsible for new cart creation, so we have to use prisma API (<a href="https://keystonejs.com/docs/apis/context#database-access">more about that</a>). It allows us to skip this restriction without the risk of allowing users to create carts independently. Here’s the updated User schema:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1834093289a15405e88eeb7706414355/href">https://medium.com/media/1834093289a15405e88eeb7706414355/href</a></iframe><p>There’s one thing left to do for this part. We need some test data — users in this case. Prisma.js included in Keystone has a nice way to import initial data (<a href="https://www.prisma.io/docs/guides/database/seed-database">more</a>), so let’s use this feature. Start with installing the ts-node package as devDependency:</p><pre>yarn add -D ts-node</pre><p>In the meantime, create the folder, seed-data, and two files inside: data.json and index.ts. The first one will be our source of test data; the second will import that data. But additionally, we have to make small changes to our tsconfig.josn in order to be able to directly import data from the JSON file. So, under compiler options, add:</p><pre>“resolveJsonModule”: true</pre><p>Now, let’s add our test data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fabe31446f6d1332171c8b51b5e8c2c/href">https://medium.com/media/1fabe31446f6d1332171c8b51b5e8c2c/href</a></iframe><p>The password used here is 1234ABcd@@ for each user. Next, we have to prepare import logic, so let&#39;s update index.ts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37be1634538cff8b9550065818b3c2d7/href">https://medium.com/media/37be1634538cff8b9550065818b3c2d7/href</a></iframe><p>There are two main parts to this importer: first, we are creating a main method responsible for importing data into the database, and the second part that calls this function in a safe way with proper error catching and the ability to disconnect the database after the job is done.</p><p>The basic importer logic is pretty simple; it loads user data from imported JSON then loops over it. For each iteration of this loop, it checks if that user exists in the database; if not it creates it. With that done, the last thing we need here is a way to start this import. So, let’s update our package.json and add:</p><pre>&quot;prisma&quot;: {<br>  &quot;seed&quot;: &quot;ts-node seed-data&quot;<br>},</pre><p>Additionally, we need to create a script to start all that using yarn, so under the scripts add:</p><pre>&quot;seed&quot;: &quot;keystone prisma db seed&quot;</pre><p>With that done, we are almost at the finish line of this part. We just need to create migrations for the updates we’ve done and import test data. So, let’s first start our database with the following command:</p><pre>docker-compose -f docker-compose.dev.yml up database</pre><p>Then, start our backend app outside the container. So in the backend folder run:</p><pre>yarn dev</pre><p>The script will detect changes in the database schema and create a migration for us. We only have to specify a name for it. For example, new_user_role_and_cart_default_values. After that we can stop this script and seed our test data:</p><pre>yarn seed</pre><p>With that done, we can restart the whole system and test it out with this command:</p><pre>docker-compose -f docker-compose.dev.yml up</pre><h3>Summary</h3><p>That’s all for this part. With that change, data security in our system improved much, and now we can safely proceed to the next tasks and work on the core elements of every e-commerce system — cart business logic.</p><p>I hope you liked it. If you have any questions or comments, feel free to ask them.</p><p>Have a nice day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a366ed7e064" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/building-your-own-e-commerce-keystone-js-based-system-access-control-1a366ed7e064">Building Your Own E-Commerce Keystone.js-Based System — Access Control</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own E-Commerce Keystone.js-Based System — Environment Setup and Base Models]]></title>
            <link>https://medium.com/better-programming/build-your-own-e-commerce-keystone-js-based-system-environment-setup-and-base-models-2c02a3e3a70b?source=rss-c2efbfe5288a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c02a3e3a70b</guid>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Maciej Krawczyk]]></dc:creator>
            <pubDate>Fri, 18 Mar 2022 16:24:55 GMT</pubDate>
            <atom:updated>2022-03-18T16:26:31.691Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build Your Own E-Commerce Keystone.js-Based System — Environment Setup and Base Models</h3><h4>This week, we are going to get our hands dirty and start coding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qfNa230Ta9ZJQZNc" /><figcaption>Photo by <a href="https://unsplash.com/@ludo_photos?utm_source=medium&amp;utm_medium=referral">Ludovic Charlet</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Last week&#39;s article was the first of the series about building an e-commerce system using Keystone.js, and it was mostly focused on <a href="https://betterprogramming.pub/build-your-own-e-commerce-keystone-js-based-system-requirements-and-architecture-3d639241b963">system requirements and its basic architecture</a>. This week we are going to get our hands dirty a little and start coding. First, we will talk about the development environment and its setup. Then about Keystone and Next setup, and lastly, about basic models setup. Also, the finished code for this article is available on my <a href="https://github.com/eabald/keystone-e-commerce/tree/Environment-setup-and-base-models">GitHub</a>.</p><h3>Dev Environment Setup</h3><p>Let’s start and create a project folder for our system, keystone-e-commerce, in my case, and create some necessary files. Run the following command in the console:</p><pre>mkdir keystone-e-commerce &amp;&amp; cd keystone-e-commerce<br>touch README.md docker-compose.dev.yml .gitignore .env.example .env</pre><p>According to the previous article, the data layer of this system contains two elements: database and search engine. The easiest way to use them locally in our development environment is to use Docker for that. So, it’s time to update our docker-compose.dev.yaml file. Just add the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c0ce4b56cac72d7d88809bd815bf017/href">https://medium.com/media/7c0ce4b56cac72d7d88809bd815bf017/href</a></iframe><p>Also, I’ve added here pgAdmin. This is a nice to have and very useful tool, especially in the dev environment. Next, the necessary thing is to set up environment variables for the system. The easiest way to do it is to create one .env file and use it across all containers. OK, let’s add all the necessary variables as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8336d09b1a95a0de7469abc469d575f/href">https://medium.com/media/e8336d09b1a95a0de7469abc469d575f/href</a></iframe><p>I’ve already added variables required by Cloudinary integration; we will get <br>back to them later. Next update the .gitgnore file. For now, this is enough. The following code will help:</p><pre>**/node_modules<br>.env</pre><p>Now, with this basic setup, we can start our containers with this command:</p><pre>docker-compose -f docker-compose.dev.yml up</pre><h3>Kesytone.js and Next.js Setup</h3><p>With this setup done, we can focus on other parts of the system. First, let’s create our Next.js client app. To be honest, here we are only going to create it and add it to our Docker setup. More work with it will be done in upcoming articles in this series. Let’s run the appropriate command:</p><pre>yarn create next-app --typescript</pre><p>The script will ask us for the name of the app. I’ve called mine client. After installation, we have to create Dockerfile.dev for this app to use with other containers. It’s a rather simple one, as you can see:</p><pre>FROM node:16</pre><pre>WORKDIR /usr/app</pre><pre>CMD yarn dev -p 3000</pre><p>Additionally, update the docker-compose.dev.yml file under services section with this code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bbd05ba42c2d440d75505c6f836f12e/href">https://medium.com/media/3bbd05ba42c2d440d75505c6f836f12e/href</a></iframe><p>A solution like this allows one main .env file, which is nice and gives centralized control of all system secrets. Also, it encapsulates the whole system in one closed docker network. And for now, that’s all about this part of the app. So, let’s switch to the backend part and set up Kesytone.js.</p><p>First, run the script to create the app. I’ve chosen backend as the folder name for it.</p><pre>yarn create keystone-app</pre><p>After that, it’s basically ready to use, but first, we have to update the database and other configurations. In keystone.ts, add credentials and update import for lists:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d52c5c9796fe2935d28d32a8248cc246/href">https://medium.com/media/d52c5c9796fe2935d28d32a8248cc246/href</a></iframe><p>Then, create additional folders in order to have a nice and easy to understand structure, with this code:</p><pre>mkdir consts enums schema</pre><p>Also, importing in the main config file requires us to add index.ts in schema folder to work properly. The last setup element left to do is to create Dockerfile.dev file and update docker-compose.dev.yml. It will be pretty similar to the previous one, as shown below:</p><pre>FROM node:16</pre><pre>WORKDIR /usr/app</pre><pre>CMD yarn dev</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26e786cb651eaf1f8891f964ba98dc4e/href">https://medium.com/media/26e786cb651eaf1f8891f964ba98dc4e/href</a></iframe><p>This will also allow us to start the entire system with one command.</p><h3>Models Setup</h3><p>With setup work done, we can start and create all necessary Keystone lists (and data models in our case). Let’s start with User model. Basically, it’s going to hold all user data including roles and privileges inside the system. Create user.schema.ts in schema folder. For now, we are only concerned by the fields property of the list. We have to add all necessary fields there, as you can see below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcb02446cfa45a72da7c735c08d119de/href">https://medium.com/media/dcb02446cfa45a72da7c735c08d119de/href</a></iframe><p>Fields name, email, and password are rather obvious. Its purpose is to identify user, and it is necessary for the authorization and authentication process. All three of them are required. Additionally, email has to be unique, and in Admin UI it can be used to filter all the users. More interesting is the role field. Its type is select and holds information about user privileges in the system. It will create enum column in the database to keep it nice and clean. I’ve moved the options values to a separate file in the consts folder.</p><p>Here’s the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97d1fb419c9a3aad00aea1a30aa2c1c2/href">https://medium.com/media/97d1fb419c9a3aad00aea1a30aa2c1c2/href</a></iframe><p>Also, I’ve moved all the values into the file in enums folder:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61d714175570da7485f720120460fa4c/href">https://medium.com/media/61d714175570da7485f720120460fa4c/href</a></iframe><p>For now, these two roles are sufficient. Later, we are going to need more of them. The last field holds a reference to Address list. Precisely, it is a one-to-many relationship. The next list contains all addresses associated with users; each one can have more than one. So, create address.schema.ts as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/babea5adab2edfb10d2581a060d35804/href">https://medium.com/media/babea5adab2edfb10d2581a060d35804/href</a></iframe><p>This list contains all of the necessary address information that will be needed in the shipment of user orders. Most fields are required in order to provide sufficient delivery information. Also, this list holds timestamps of the creation of the record and its last modification. The last field is a reference to user, owner of this address, and in this case, it is a many-to-one relationship.</p><p>Next, tightly associated with the user list is Cart model. It contains all the information about the products added to the cart by the user, their sum, and the date of the last modification. Each user has one Cart, so it is a one-to-one relationship. Here’s the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5736ba3d791d48328c8f4c5c3eb93def/href">https://medium.com/media/5736ba3d791d48328c8f4c5c3eb93def/href</a></iframe><p>In each Cart there can be many products added, and the same product can be added to multiple carts, so it creates a many-to-many relationship.</p><p>With that out of the way, we can focus on other models. Next, related to User and loosely coupled to Cart is Order list. It contains all the information about orders currently in processing and already processed. The first field is a reference to user, owner of this order, a one-to-may relationship. Each user can have multiple orders, but each order has only one owner.</p><p>The next field contains information about products in this order serialized into JSON. This way we can hold information about all the products in order, not only ones currently in stock, but also removed from offer too.</p><p>Next, two fields hold a relationship to Payment and Shipment lists, both one-to-one relationships. The last three fields contain information about the creation date, last modification, and order status. The last one is in select type, I moved all options and values to separate files like with user roles before.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45bc9c076c1a1f494644201991ca1ba4/href">https://medium.com/media/45bc9c076c1a1f494644201991ca1ba4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfc01a23c552b6cc6a7abc20699dec16/href">https://medium.com/media/bfc01a23c552b6cc6a7abc20699dec16/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e7929e5b9d67477c839749f0545f463/href">https://medium.com/media/6e7929e5b9d67477c839749f0545f463/href</a></iframe><p>The next two lists complement Order model and hold information about Payment and Shipment associated with it. Both of them hold basic information about timestamps and statuses of both business processes (created the same way as order status) and their relationship to Order.</p><p>The first of them additionally holds information about the sum of orders, its currency, and transaction ID from a third-party provider. I haven’t thought yet about specific integration in this matter, but probably it will be <a href="https://stripe.com/">Stripe</a> because I’m most familiar with it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc45a02a6e72efd1ca0c772d88bd187d/href">https://medium.com/media/fc45a02a6e72efd1ca0c772d88bd187d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a035d8a588b1b69b951236eda4130da/href">https://medium.com/media/8a035d8a588b1b69b951236eda4130da/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc4c3767aa81449433ab254600fbe80c/href">https://medium.com/media/cc4c3767aa81449433ab254600fbe80c/href</a></iframe><p>On the other hand, the Shipment model holds information about the employees responsible for processing this shipment, packing, and sending it. Similarly, like in the previous one, there’s also information about an external ID from a third-party system responsible for processing the delivery.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90ca43c032fe25bba56ba17b7d7ffb68/href">https://medium.com/media/90ca43c032fe25bba56ba17b7d7ffb68/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7af63325965c16c4e63829fada589ea/href">https://medium.com/media/f7af63325965c16c4e63829fada589ea/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91ad1df8ef1ec4503e569a4533b24c5c/href">https://medium.com/media/91ad1df8ef1ec4503e569a4533b24c5c/href</a></iframe><p>For now, all status fields contain only one option — Created. In the next parts of this series more focused on these sections of the system, we are going to add other necessary options.</p><p>The last group of models is focused on products. The main Product list contains basic product information like name, description, SEO description, price, rating (stars), and timestamps. The rest of the fields establish various relationships to more specific product information like product images, categories, and stocks.</p><p>The first one creates a one-to-many relationship; the second one a many-to-many, and the last one is a one-to-one relationship. Basically, a product can have multiple images, but the image belongs only to one product. Each may have categories and category has many products, and lastly, each has only one stock information (as I mentioned in the previous article I’ve decided to support only one warehouse setup).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff6fb579f5c3941d38da0e5a73d3cafc/href">https://medium.com/media/ff6fb579f5c3941d38da0e5a73d3cafc/href</a></iframe><p>The next list holds products images. There are two important fields here: alt and image. The first one contains the information necessary to fill in the HTML alt attribute for each image. The second allows uploading images directly into Cloudinary CDN. All that is supplemented with timestamp fields.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f386ec2c52794ea0353329781d0402c/href">https://medium.com/media/3f386ec2c52794ea0353329781d0402c/href</a></iframe><p>The next list, Stock, contains information about the amount of available-to-order products. Additionally, there’s information about the next expected delivery and the number of products in it. It’s necessary for cases when a user tries to order more products than are available.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b151abf091f81b974308e63c19d2bd06/href">https://medium.com/media/b151abf091f81b974308e63c19d2bd06/href</a></iframe><p>The last model, Category, holds information about products categories and their relationships to one another. Fields here include category name, related products, and parent category (if there’s one) and usual timestamps. This internal relationship allows creating categories tree easily which will be useful when creating our system’s frontend.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90872962076b515191810c9f4bebb597/href">https://medium.com/media/90872962076b515191810c9f4bebb597/href</a></iframe><p>The last thing to do here is to import all models into index.ts, which is imported into keystone.ts main config file shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7a4c113f57f401ef3fddb5c4301db98/href">https://medium.com/media/f7a4c113f57f401ef3fddb5c4301db98/href</a></iframe><p>A quick note about timestamps, each one of them has a set of default values and should not be edited by users. But more on that topic in the next article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z060l7IpY-RVkeikvf9wKA.png" /><figcaption>ER diagram</figcaption></figure><p>OK, that concludes all models we have to create. Now it’s time to create necessary migrations and corresponding tables in the database. Start with spinning up the database container.</p><pre>docker-compose -f docker-compose.dev.yml up database</pre><p>After that, start in the separate terminal of our backend:</p><pre>cd backend &amp;&amp; yarn dev</pre><p>The script will ask for the name of the new migration, type initial_models and hit enter. It will handle the table&#39;s creation and generate migration files. Now we can stop both processes and start the whole system.</p><pre>docker-compose -f docker-compose.dev.yml up database</pre><h3>Summary</h3><p>Now we have a working dev environment and basic models setup, so it gives us a solid foundation for our system. Next time, we will start building up additional features needed in the e-commerce system. First, we will focus on access control and user privileges to access different parts of the system.</p><p>I hope you liked it. If you have any questions or comments, feel free to ask.</p><p>Have a nice day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c02a3e3a70b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/build-your-own-e-commerce-keystone-js-based-system-environment-setup-and-base-models-2c02a3e3a70b">Build Your Own E-Commerce Keystone.js-Based System — Environment Setup and Base Models</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>