Giter Site home page Giter Site logo

pantry-tracker's Introduction

I'll update this later

Getting Started

cp .env.sample env
docker compose up
npm i
npm run db:push
npm run dev
open http://localhost:3000

Project Goals

  • Everything works using progressive enhancement (all functionality works with javascript disabled)

The Architecture

In this project, I am trying to apply clean architecture principles, including a separate data access layer (drizzle), a business layer (use cases and business entities), and a presentational layer (server actions / next rsc data fetchers). This also include following paradigms including dependency inversion, meaning the business layer should know NOTHING about next.js, server actions, the database or ORM, etc. To achieve this, often inside the next server actions, we inject the use case dependencies as functional dependencies (context). I do no like using existing libraries that wire up all the dependencies or using decorators on top of functions which automatically inject things from some type of global registration service object.

To help keep clean boundaries, data that is passed between these layeres must be mapped into data transfer objects (DTO). This means you should not be returning anything related to drizzle back from the data layer, instead you should map results to a DTO. Same with the server actions. Server actions should only pass simple primatives to the use case and should never pass anything related to next or react to the use case. Things like revalidatePath or revalidateTag should never live in the business or persistence layer.

To some this may feel like over engineering, but many could argue this helps build systems that are more maintaible as they grow larger. I've been on a project for almost 5 years at work, and this uses a similar approach for that project which is getting close to half a million lines of typescript. Failing to follow a strict pattern in your code base will set you up for technical debt in the future.

I will say, I've never done this clean architecture type of approach on a next.js project, so I'm trying to get a feel for how I personally like it all setup. I've decided to defer using a mono repo and separating out the business logic / persistence layer until I feel it's necessary.

TODO

  • make everything responsive

pantry-tracker's People

Contributors

webdevcody avatar abdulrahman-al-sabagh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.