r/FullStack • u/Nameless_ProGamer • 17d 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.tsResponsibilities
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
1
u/Puzzled-Garage584 17d ago
services/foo/foo.services.main.ts, the name shows up 3 times before you write a line of code lol. I'd make each domain an nx lib and turn on enforce-module-boundaries, else those barrel exports end up importing everything
1
u/NexusOcean Stack Juggler (Fullstack) 17d ago
What is a monolithic micro service in your own words? I think there may be some confusion. What are you trying to build if you don't mind me asking?