This project is a RESTful API designed for forum management. The use cases are centered around the fundamental elements of questions, answers, and comments. The entire application is built following SOLID principles, clean architecture, and domain event patterns.
Requirements
- Node.js - Official Node.jsยฎ download page
- Docker Engine - Official Docker installation guide
- AWS CLI - Official AWS CLI installation page
- Terraform - Official Terraform installation guide
Clone the project
$ git clone https://github.com/wladimirgrf/forum.git && cd forumInstall the Project dependencies
$ npm installEnvironment Variables
$ cp .env.example .envSet access credentials
aws configureRun the containers
$ docker-compose up -dMigrations
$ npm run db:migrateLaunch the Application
$ npm run start:devNote
The API will be launched at http://localhost:3333/
Documentation available at http://localhost:3333/docs
You need to set up the resources for Terraform state synchronization.
Create the Bucket
aws s3api create-bucket --bucket forum-tf-state --region us-east-1Caution
S3 requires unique names for buckets.
Create the DynamoDB table for state lock
aws dynamodb create-table \
--table-name forum-tf-state-lock \
--attribute-definitions AttributeName=LockID,AttributeType=S \
--key-schema AttributeName=LockID,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
--region us-east-1Initialize the Working Directory
npm run infra:prepCheck the Execution Plan (OPTIONAL)
npm run infra:planDeploy the entire Infrastructure
# The process takes about 10 minutes
npm run infra:upNote
Terraform requires a username and password for database access during deployment to securely connect the application.
Prisma migrations are automatically executed during the deployment process.
However, it's important to note that this project utilizes a private VPC, and Prisma (in its current version) does not support executing migrations via API.
To address this, I incorporated the engine from the version I am using into the project's deployment flow. With a simple JS script, it is possible to use Lambda to execute the migrations within the VPC.
Important
So, if you want to run this project or another with the same infrastructure, it's crucial to pay attention to the engine version. Below is a link to a step-by-step guide for downloading the schema engine for the version of Prisma you are using: prisma/prisma#14873
Another useful link to follow is the issue addressing this topic in the Prisma repository. This feature may eventually be supported by the framework. prisma/prisma#4703
Fork the repository and clone your fork
$ git clone <fork-url> && cd forumCreate a branch for your edits
$ git checkout -b new-featureMake the commit with your changes
$ git commit -m 'feat: New feature'Send the code to your remote branch
$ git push origin new-featureCreate a pull request with your version.
After your pull request is merged, you can delete your branch.
This project is licensed under the MIT License - see the LICENSE file for details.


