Skip to content

SAMAHAN-Systems-Development/sysdev-website-backend

Repository files navigation

Samahan Official Website Backend

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.

Table of Contents

Tech Stack

  • 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.

Web GUIs and Credentials

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


Production and Frontend Use setup

  1. Clone the repository
git clone
  1. Fetch the updates
git fetch
  1. 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
  1. Migrate database
npm run db:migrate
  1. Generate Dummy Data (optional)
npm run db:seed
  1. Ensure that you have successfully created minio sysdev-images and 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.


Setting up your application -- In case you want to use the backend codebase

  1. Clone the repository
git clone
  1. Fetch the updates
git fetch
  1. 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

  1. Install the libraries with this command:
npm install
  1. Duplicate .env.sample file 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 .env

Or just ctrl + c ctrl + v the file.

  1. 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.


(Backend Developer) Running Application

After you finish setting up the backend, you can now follow this step to get things running

  1. Run the docker containers (make sure that you already started your docker application)
docker compose -f docker-compose.local.yml up -d
  1. Migrate database
npm run db:migrate
  1. Generate Dummy Data (optional)
npm run db:seed
  1. 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

Potential Issues and Fixes

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 --build

This 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>

⚠️ This will reset Minio, Postgress

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 9

Languages