r/FullStack • • 24d ago

Feedback Requested File structure for monolithic microservices (nx workspace)

Is this an scalable codebase / workspace ? (edited thanks to constructive feedback)

File structure

This codebases file structure

Overview

This codebase uses a micro service monorepo to share code across different micro services and deploy independently. 

File structure

  ... root files
  docs\
    architecture\
      {area-covered}\
        architecture.{area-covered}.{category or main}.md
    decisions\
      {area-covered}\
        decisions.{area-covered}.{category or main}.md
    deployment\
      {area-covered}\
        deployment.{area-covered}.{category or main}.md
    development\
      {area-covered}\
        development.{area-covered}.{category or main}.md
    README.md
  packages\
    client\ 
      public\ 
      kernel\ 
    server\ 
      kernel\ 
      repository\ 
    shared\ 
      models\ 
      constants\ 
    ... configuration files
  apps\
    public\
      {public-facing-service}\
        ...root files
        features\
          {feature}\
            models\
            components\
            hooks\
            views\
        shared\
          features\
            {feature}\
          kernel\
          models\
      private\
      {public-facing-backend-service}\
        domains\
          {domain}\
            controller\
            services\
              {service-name}\
                helpers\
                  {service-name}.helpers.main.ts
                  commands\
                  validation\
                {service-name}.services.main.ts
            model\
        shared\
          domains\
            {domain}\
            controllers\
            services\
              {service-name}\
                helpers\
                  {service-name}.helpers.main.ts
                  commands\
                  validation\
                {service-name}.services.main.ts
            models\
          kernel\
          models\
            schema\
            data\
            metadata\
        test\
          e2e\
            domains\
              {domain}\
                domains.{domain}.e2e-spec.ts
    private\
      {private-facing-service}\
        domains\
          {domain}\
            controller\
            services\
              {service-name}\
                helpers\
                  {service-name}.helpers.main.ts
                  commands\
                  validation\
                {service-name}.services.main.ts
            model\
        shared\
          domains\
            {domain}\
            controllers\
            services\
              {service-name}\
                helpers\
                  {service-name}.helpers.main.ts
                  commands\
                  validation\
                {service-name}.services.main.ts
            models\
          kernel\
          models\
            schema\
            data\
            metadata\
        test\
          e2e\
            domains\
              {domain}\
                domains.{domain}.e2e-spec.ts

Responsibilities

frontend feature slice

  • components : individual components, buttons, icons, etc.

  • hooks : reactive and side effect code (not just explicitly react hooks)

  • models : types and interfaces

  • views : fully rendered feature no hooks

  • shared\features : barrel export

backend domain driven

  • controller : handles the networking layer

  • service : imports the repository and schema and setups up business logic through helpers

  • model : defines schema, data and metadata types

  • shared\domains : barrel export

  • commands : calling repository functions correctly

  • validation : data validation through zod

General rules

  • shared\kernel : minimal running code for software tools, for example

    • Redis

    • Redux

    • Supabase

    • Drizzle

    • etc

  • shared

  • models\ : Types, Schemas, and interfaces used throughout the app. Not barrel exports schemas

  • data

  • metadata\

  • constants : constant variables for desktop and mobile apps or type sensitive strings (event names)

5 Upvotes

Duplicates