34493/README.MD
2025-09-30 03:41:24 +00:00

171 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Project Setup & Local Development
## Tech Stack
| Layer | Technology |
| --------- | -------------------- |
| Frontend | **React JS** |
| Backend | **Node JS** |
| Database | **PostgreSQL** |
| Container | **Docker & Compose** |
---
## 1  Run Locally (without Docker)
### 1.1 Backend
```bash
cd backend
# install dependencies
yarn install
```
\#### Configure PostgreSQL
<details>
<summary><strong>macOS</strong></summary>
```bash
brew install postgres
```
</details>
<details>
<summary><strong>Ubuntu</strong></summary>
```bash
sudo apt update
sudo apt install postgresql postgresql-contrib
```
</details>
\##### Create DB & Admin User
```bash
# log in as default superuser
psql postgres -U postgres
-- inside psql
CREATE ROLE admin WITH LOGIN PASSWORD 'admin_pass';
ALTER ROLE admin CREATEDB;
\q
# log in as the new user
psql postgres -U admin
-- inside psql
CREATE DATABASE db_<your_project_name>;
GRANT ALL PRIVILEGES ON DATABASE db_<your_project_name> TO admin;
\q
```
\##### Migrate & Start
```bash
yarn db:create # generate schema
yarn start # production build
```
### 1.2 Frontend
```bash
cd frontend
yarn install
yarn start
```
> Frontend devserver runs at **[http://localhost:3000](http://localhost:3000)** by default.
---
## 2  Run with Docker
```bash
cd docker
chmod +x wait-for-it.sh start-backend.sh
```
| Scenario | Command |
| ------------------------- | ---------------------------------- |
| **Fresh DB volume** | `rm -rf data && docker-compose up` |
| **Reuse existing volume** | `docker-compose up` |
Then open **[http://localhost:3000](http://localhost:3000)**.
Stop services with **Ctrl + C** or:
```bash
docker-compose down
```
> **Headsup:** Files inside the `docker/` folder and the root `Dockerfile` are used for cloud deployment. Changing them may break the pipeline.
---
## Folder Structure (toplevel)
```text
├── backend/ # Node JS API & services
├── frontend/ # React application
├── docker/ # Compose files & helper scripts
└── README.md # (this file)
```
---
## Troubleshooting
### “connection refused”
1. Port closed or backlog full.
2. Firewall (local or network).
3. Service not running.
Verify with:
```bash
telnet <host> <port>
```
### macOS
```bash
sudo service ssh status
```
### Ubuntu IP conflict check
```bash
arp-scan -I eth0 -l | grep <ipaddress>
arping <ipaddress>
```
### Reset PostgreSQL schema (macOS example)
```sql
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
```
---
## Cheatsheet
| Task | Command |
| ----------------------- | ---------------------------------- |
| **Create DB schema** | `yarn db:create` |
| **Start backend** | `yarn start` |
| **Start dev frontend** | `cd frontend && yarn start` |
| **Compose up (fresh)** | `rm -rf data && docker-compose up` |
| **Compose down** | `docker-compose down` |
<br/>
---
Made with ❤ by Flatlogic Platform.