Samahan Official Website Backend is the server-side component powering the Samahan organization's official website. Built with Node.js and NestJS, it provides RESTful APIs, manages authentication, handles data storage, and integrates with services like PostgreSQL and MinIO. This backend is designed for scalability, security, and ease of deployment using Docker, supporting both production and local development environments.
- Tech Stack
- Web GUIs and Credentials
- Production and Frontend Use setup
- Setting up your application -- In case you want to use the backend codebase
- (Backend Developer) Running Application
- Potential Issues and Fixes
- Node.js: JavaScript runtime for building scalable server-side applications.
- NestJS: Progressive Node.js framework for efficient and reliable backend development.
- Swagger (OpenAPI): Integrated with NestJS for automatic API documentation and testing.
- PostgreSQL: Open-source relational database for data storage.
- MinIO: High-performance object storage compatible with Amazon S3.
- Docker: Containerization platform for consistent deployment across environments.
- Drizzle ORM: TypeScript-first ORM for SQL databases, providing type-safe queries and migrations.
- JWT: JSON Web Tokens for secure authentication.
- dotenv: Environment variable management.
- Other Utilities: npm scripts for migration, seeding, and development tasks.
| Service | URL | Description | Default Credentials |
|---|---|---|---|
| MinIO | http://localhost:9001 |
Object storage GUI | minioadmin / minioadmin123 |
| pgAdmin | http://localhost:8080 |
PostgreSQL GUI | admin@admin.com / admin |
| Swagger (OpenAPI) | http://localhost:8000/api |
Api Documentation (Application must be running) | Api's are locked so use the /auth/login to get the token |
Just make sure that you have already executed the docker-compose
- Clone the repository
git clone- Fetch the updates
git fetch- Run Docker app and run this comand in the root folder of the project
docker compose -f docker-compose.prod.yml up -d --build-
📌 After you finish using the service, run this command to stop the docker containers:
docker compose -f docker-compose.prod.yml down
- Migrate database
npm run db:migrate- Generate Dummy Data (optional)
npm run db:seed- Ensure that you have successfully created minio
sysdev-imagesand set it to public, you can access it here minio service.
You have now successfully deployed a working production server! You can access it at localhost:8000. For more information about web GUIs and credentials, see the Web GUIs and Credentials section.
- Clone the repository
git clone- Fetch the updates
git fetch- Switch to the branch of your ticket --- this only applies if you are a Backend Developer, if not just stick to
main
git checkout 2-2-get-project- Install the libraries with this command:
npm install- Duplicate
.env.samplefile and rename it to.env
You can accomplish this manually or run this command:
For Windows:
copy .env.sample .env
For Linux:
cp .env.sample .envOr just ctrl + c ctrl + v the file.
- Generation of Jwt secret:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"This will print a code, and put this code in AUTH_SECRET.
After that you now have finally setup the backend and ready to start to run the application.
After you finish setting up the backend, you can now follow this step to get things running
- Run the docker containers (make sure that you already started your docker application)
docker compose -f docker-compose.local.yml up -d- Migrate database
npm run db:migrate- Generate Dummy Data (optional)
npm run db:seed- Run the NestJS backend
npm run start-
📌 After you finish programming, run this command to stop the docker containers:
docker compose -f docker-compose.local.yml down
Sync Issue, and no changes reflected
(Production) In some cases, if error persists after updating the codebase work. Run this following command:
docker compose -f docker-compose.prod.yml up -d --buildThis will sync the current code and the build in docker
Resetting the database
Requirements: docker compose should be running --- then execute this following command:
docker compose -f docker-compose.prod.yml down -v
You can also is remove the volume by manually using docker volume rm <volume_name>
Production: Throwing 500 Internal request error
Assuming you have all records correct and data is provided.
Please create a ticket with a tag issue with a detail instruction on how to replicate the error and announce it to the gc.
Thank you.