Akan.js helps you minimize technical code and focus on implementing business logic.
Akan.js also provides many convenient features for building applications and provides installable libraries to provide best practices for business development.
Workspace (monorepo)
Akan.js is a monorepo structure that allows a single organization (team) to develop multiple apps on a single repository (workspace). A single workspace contains multiple apps (apps) and common libraries (libs).
App(apps): Standalone application that can be deployed to all platforms (web, mobile, server, etc.)
Common library(libs): Provide common features that can be used by multiple apps. For example, login, payment, notification, chat, etc. are common features used in various apps. By providing these features as common libraries, developers can reuse them to reduce development time.
├── apps/ # Application list
│ └── appA/ # Individual application
│ └── appB/ # Individual application
└── libs/ # Library list
├── shared/ # Shared library
├── util/ # Utility library
└── [other libs]/ # Other specific libraries
When you run `akan create-workspace`, shared and util libraries are installed by default. These libraries are common libraries that can be used by all apps.
You can use common libraries in your created application (e.g. myapp). For example, you can use the shared library to provide admin page and file upload tool.
80:20 rule
A healthy workspace maintains a structure where 80% of the code is shared between apps, and 20% is specific to each app.
However, you don't have to force yourself to follow the rule. Just maintain the workspace with your heart, and the ratio will naturally be adjusted as you maintain it.
Workspace file structure
To efficiently arrange server, client, and common code, the apps and libs structure has the following identical structure.
The server is implemented as a node.js application that is executed in the main.ts file, and the client is implemented as a Next.js app router-based file-based routing.
└── {apps,libs}/ # Application or library code
└── {appA,libA}/ # Individual application or library
├── app/ # File based routing (Only in apps)
├── base/ # Base code (not-modularized)
├── common/ # Common code (modularized)
├── env/ # Environment variables
├── lib/ # Domain modules
├── nest/ # Server-side logic code
├── next/ # Client-side logic code (modularized)
├── public/ # Assets files
├── ui/ # UI code (modularized)
├── akan.config.ts # Application configuration
├── main.ts # Backend entry point (Only in apps)
├── client.ts # Client-side barrel file
└── server.ts # Server-side barrel file
To run the server and client, each server.ts and client.ts files implement the modularized code as a single file (barrel file).
To implement this, the server, client, and common files are separated, and the file rules are taken, and roughly expressed as follows.
By arranging the server, client, and common files in accordance with the file rules, you can implement an extensible and reusable structure. You don't need to understand all the rules now. As you write code in the future practice, you can understand one by one. The most important thing is to understand where the code you want to implement is located in the server, client, and common files.
For example, if you want to implement a password-based login feature, the component that receives the ID and password is a client feature. The function of encrypting and storing it is a server feature, and checking if the password is more than 8 characters is a common feature needed by both.