Codebase
Project Structure
To rewrite the provided folder structure using the filetree
notation based on the documentation in the image, the code will look like this:
- Backend code
- Frontend Code
- CLI Code
Folder name | Description |
---|---|
app | Backend code (FastAPI - Python) |
dashboard | Frontend code (React - Typescript) |
cli | CLI code (Typer - Python) |
Backend
Backend is built using FastAPI and uses SQLAlchemy as the ORM for database operations. Pydantic models can be found
in the app/models
directory, while all database-related operations and models are in the app/db
directory. The
migration scripts for the database (Alembic) can be found in the app/db/migrations
directory.
Python Code Formatting
To maintain consistency in the codebase, we require all code to be formatted using
black .
Frontend
The frontend follows a feature-oriented development structure. Features are essentially components, hooks, logics, services which provide user-experience that it coupled with domain and UI functionality.
Folder name | Description |
---|---|
routes | @tanstack/react-router routing |
features | Feature folder |
users | Core domain feature |
nodes | Core domain feature |
hosts | Core domain feature |
entity-table | Support feature |
github-repo | Support feature |
components | Generic Components |
ui | Atomic components |
Features
features
folder encapsulate all features. Features can be categorized in few groups, Core domain, Support.
Core domain features deliver a set of solutions to the problem the application intened to resolve. Meanwhile
Support features provide a set of solutions that are independent from domain model, however, they are necessary
for the application to fully deliver the experience the user expect.
Generic Components
components
folder is a place for react generic components that will be reused by features.
The same logic goes for hooks
, types
, folder.
Atomic components
components/ui
folder is a place for atomic components that are the backbone of the application.
These components are based on shadcn component template, however, depending when you are reading this,
we probably have diverged a lot.
Utils
These functions are generic and reused across codebase, although, they will be transfered to their own generic folder or feature folder as they grow in complexity and code usage.
Routes and pages
routes
folder is tanstack routing folder, containg pages and routing logic.
To build the frontend you’ll need the following dependencies:
- pnpm
then run make dashboard-deps && make dashboard build
for it to build; or make dashboard-dev
for development
purposes.
Marzneshin CLI
Marzneshin CLI is built using Typer, and its commands’ code can be found in cli
directory. Its documentation is generated using Typer CLI which can be
re-generated by navigating to project’s root directory and running the following command:
$ PYTHONPATH=$(pwd) typer marzneshin-cli.py utils docs --name "marzneshin-cli" --output ./cli/README.md
Dev Mode
To run the frontend in development mode use the following commands to install the dependencies, and then run the backend:
make dashboard-deps && make dashboard-dev
run make start
in another console.