This guide provides detailed instructions for setting up your local development environment, running the services, and contributing to the OASM project.
- Prerequisites
- Project Structure
- Initialize Developer Environment
- Running Services
- Database Setup
- Development Conventions
- Using Docker Compose
- Contributing
Before you begin, ensure you have the following installed:
- Task (taskfile) - Installation Guide
- Node.js v18+ - Installation Guide
- Bun runtime (latest) - Installation Guide
- PostgreSQL v12+
- Docker & Docker Compose (optional but recommended for database)
The project is organized into several key directories:
open-asm/
├── core-api/ # NestJS API server
│ ├── src/ # Source code
│ ├── example.env # Environment template
│ └── package.json
├── console/ # React web interface
│ ├── src/ # React components
│ ├── public/ # Static assets
│ └── package.json
├── worker/ # Bun-based workers
│ ├── services/ # Worker services
│ ├── tools/ # Security tools integration
│ ├── example.env # Worker environment
│ └── package.json
├── .open-api/ # Auto-generated API docs
├── docker-compose.yml # Container orchestration
├── taskfile.yml # Task automation
└── README.md # Documentation
To set up your local development environment, run the following command:
task initThis command will:
- Copy example environment files (
.env) forcore-api,console, andworker. - Install project dependencies using
npm(managed by the task for each workspace). - Start a PostgreSQL Docker container named
open-asm-postgres(requires Docker).
After running task init, you can start all services using task dev or run them individually as described below.
To start all services (API, Console) simultaneously, use the task command from the root directory:
task devTo run workers locally, use the task command from the root directory:
task worker:devThe task init command automatically starts a PostgreSQL container using Docker. The database connection details are configured in core-api/.env.
If you prefer to use your own PostgreSQL instance, update the core-api/.env file accordingly.
This section explains how to manage database migrations using the taskfile.
Database migrations are managed using TypeORM. The migration scripts are defined in core-api/taskfile.yml and can be executed using the task commands.
This command executes all pending database migrations:
task migration:runThis will:
- Connect to the PostgreSQL database
- Check for pending migrations in the
migrationstable - Run all new migrations that haven't been applied yet
To generate a new migration with a custom name:
task migration:generate MIGRATION_NAME=YourMigrationNameFor example:
task migration:generate MIGRATION_NAME=AddUserTableThis will create a new migration file in core-api/src/database/migrations/.
To rollback the most recently executed migration:
task migration:revertNote: This will only revert one migration at a time. Repeat if needed.
If you prefer to run migrations using Docker (useful when not running PostgreSQL locally):
docker compose up migrationThis will:
- Start the PostgreSQL container (if not running)
- Run the migration service
- Execute all pending migrations
- Automatically remove the migration container after completion
- Start the core-api service after migrations complete
To run migration container manually and keep it for debugging:
docker compose run --rm migrationThe --rm flag ensures the container is removed after it stops.
- Core API (NestJS): Uses ESLint and Prettier for code formatting and linting. Currently, you need to run
npm run lintandnpm run formatdirectly from thecore-apidirectory. Consider creating a task to wrap these commands for convenience. - Console (React): Uses ESLint and Prettier. Currently, you need to run
npm run lintdirectly from theconsoledirectory. Consider creating a task to wrap this command for convenience. - Workers (Bun): Likely follows standard TypeScript conventions. You may need to run linting/formatting commands directly from the
workerdirectory.
- Core API: Uses Jest for testing. Currently, you need to run the following commands directly from the
core-apidirectory:- Run unit tests:
npm run test - Run tests in watch mode:
npm run test:watch - Run end-to-end tests:
npm run test:e2eConsider creating tasks to wrap these commands for convenience.
- Run unit tests:
To run the entire stack, including the database, using Docker Compose:
task docker-composeThis command uses docker-compose.yml to orchestrate containers.
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/amazing-feature. - Make your changes and commit them:
git commit -m 'Add amazing feature'. - Push to the branch:
git push origin feature/amazing-feature. - Open a Pull Request.
Please ensure your code adheres to the project's coding standards and passes all tests before submitting a PR.