README.md
March 18, 2025 · View on GitHub
<- Description ->
Demo
You can try out a demo of the API here.
To access the demo, use /auth/login with the following credentials:
{
"username": "admin",
"password": "ABC#abc#123"
}
{
"username": "client_1",
"password": "ABC#abc#123"
}
You can use the Swagger Bearer authentication by clicking Authorize to enter the token generated from the /auth/login endpoint. Once you have authenticated with the token, you can automatically test all endpoints that the user has access to.
Project Setup
See the steps to configure and run the project
-
Install Node.js, Git, and Npm:
Download and install Node.js (preferably version 22 to ensure compatibility) from the official website: https://nodejs.org/en. Verify the installation by running:
node --versionDownload and install Git from the official website: https://git-scm.com. Verify the installation by running:
git --versionNpm is installed automatically with Node.js. Verify the installation by running:
npm --version -
Clone the project and switch to the
developbranch:Run the following commands to clone the repository and checkout the
developbranch:git clone https://https://github.com/cerciber/nest-general-architecture.git cd nest-general-architecture git checkout develop -
Install dependencies:
Run the following command to install all project dependencies:
npm install -
Create configuration file:
Create a file named
.env.developmentin the root of the project with the following content:# PORT: Port number on which the application will listen for incoming requests PORT= # MONGO_URI: Connection string for MongoDB. Includes the database server address, port, and authentication details if required. MONGO_URI= # JWT_SECRET_KEY: Key used for signing and verifying JSON Web Tokens (JWTs). Ensure this key is strong, unique, and kept confidential. JWT_SECRET_KEY= -
Create sample data (Only if you want to use your own database):
If you need reset database and set sample data, you can easily do so by running the following command:
npm run db:reset -
Install VSC extensions (Optional for Visual Studio Code) :
You can install the required VS Code extensions by running the following commands:
code --install-extension dbaeumer.vscode-eslint code --install-extension rvest.vs-code-prettier-eslintAlternatively, you can install these extensions
Prettier ESlintandESlintmanually from the VS Code marketplace.To ensure that the configurations are applied correctly, restart Visual Studio Code.
-
Run the project in development mode:
Navigate to the project directory and run the following command to start the project in development mode:
npm run start:devThis will start the project with the development configuration.
You can view the documentation at
http://localhost:<PORT>/docs, where<PORT>is the port specified in your.env.developmentfile.
Architecture
See the architecture
General architecture
<- Description ->
Structure
<- Description ->
Data Model
<- Description ->
Components diagram
<- Description ->
Use Cases
<- Description ->
Sequence diagrams
<- Description ->
Contribution Guidelines
See Contribution Guidelines
Git Branching Strategy
The Git branching strategy ensures a structured and predictable workflow, facilitating continuous integration and easy management of releases and fixes. Below are the main branches and their specific purposes in the project:
main
Contains stable, production-ready code. All final releases are made from this branch.
develop
Integration branch for ongoing development. All new features and improvements are merged here before being released.
deploy
Used to prepare and deploy code to staging or production environments. Derived from develop or main.
fix/issue-xxxx
Dedicated branch for urgent bug fixes. Based on main, it’s used to resolve critical issues that need immediate attention.
feature/issue-xxxx
Individual branches for developing new features or resolving specific issues, derived from develop. Named according to the related issue number (issue-xxxx).
Conventional Commits
Use this format for commit messages:
Type
feat: New featurefix: Bug fixdocs: Documentation updatestyle: Code formattingrefactor: Code change without adding features or fixing bugstest: Adding or updating testschore: Maintenance tasks
Scope
- Optional: Identifies the part of the code affected (e.g.,
auth,api,ui).
Content
- Brief, imperative summary of the change.
Examples
- Feature:
feat(ui): add dark mode toggle - Bug Fix:
fix(api): handle null values - Docs:
docs(readme): update setup guide
Contribution Guide
This guide outlines the steps to effectively contribute to the project. By following these instructions, we ensure consistent quality, clear communication, and smooth collaboration among team members.
1. Create an Issue
- Title: Clearly describe the issue or feature.
- Details: Add any relevant information or context.
2. Branching
- From: Always branch from
develop. - Branch Name: Use
feature/issue-xxxx(replacexxxxwith the issue number).
3. Development
- Code: Implement the changes in your branch.
- Commits: Follow the Conventional Commits guidelines.
4. Pull Request
- PR Title: Match the issue title.
- Description: Briefly explain the changes.
- Target Branch: Always target
develop.
5. Assign Reviewers
- Reviewers: Assign at least two team members for review.
- Labels: Add relevant labels (e.g.,
bug,enhancement).
6. Address Feedback
- Revisions: Make changes based on reviewer feedback.
- Final Check: Ensure all comments are addressed before merging.
7. Merge
- Approval: At least one team member must approve the pull request before it can be merged.
- Merge: Once approved, merge the PR into
develop. - Delete Branch: Clean up by deleting the feature branch.