Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .codex
Empty file.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXPO_PUBLIC_USE_LOCAL_API=1
EXPO_PUBLIC_LOCAL_API_URL=http://192.168.76.129:8080
EXPO_PUBLIC_API_URL=https://devbits.app
EXPO_PUBLIC_API_URL=https://devbits.ddns.net
EXPO_PUBLIC_LOCAL_API_PORT=8080
POSTGRES_DB=devbits_dev
POSTGRES_USER=devbits_dev
Expand Down
89 changes: 0 additions & 89 deletions .github/workflows/aws.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Bash-Scripts/run-front.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if [[ -z "$LAN_IP" ]]; then
fi

if [[ -z "$MODE" ]]; then
echo "Select backend: 1) Live (devbits.app) 2) Local (LAN IP:8080)"
echo "Select backend: 1) Live (devbits.ddns.net) 2) Local (LAN IP:8080)"
read -r -p "Choose [1/2]: " selection
case "$selection" in
1) MODE="production" ;;
Expand All @@ -96,8 +96,8 @@ else
unset REACT_NATIVE_PACKAGER_HOSTNAME || true
unset EXPO_PACKAGER_HOSTNAME || true
fi
export EXPO_PUBLIC_API_URL="https://devbits.app"
export EXPO_PUBLIC_API_FALLBACK_URL="https://devbits.app"
export EXPO_PUBLIC_API_URL="https://devbits.ddns.net"
export EXPO_PUBLIC_API_FALLBACK_URL="https://devbits.ddns.net"

if [[ "$MODE" == "local" ]]; then
LOCAL_API_PORT="${EXPO_PUBLIC_LOCAL_API_PORT:-8080}"
Expand All @@ -119,7 +119,7 @@ if [[ "$MODE" == "local" ]]; then
else
export EXPO_PUBLIC_USE_LOCAL_API=0
unset EXPO_PUBLIC_LOCAL_API_URL || true
echo "Using live backend: https://devbits.app"
echo "Using live backend: https://devbits.ddns.net"
fi

cd "$FRONTEND_DIR"
Expand Down
63 changes: 20 additions & 43 deletions INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,29 @@

## Backend

> **AWS EC2 (Amazon Linux) Native Deploy**
> **Live/Deployed Stack**
>
> ```bash
> # On your EC2 instance
> sudo dnf update -y
> sudo dnf install -y git tar
> cd /path/to/DevBits/backend
> docker compose up -d
> docker compose logs -f db
> ```
>
> Install Go 1.24.x (required by `backend/go.mod`):
>
> ```bash
> curl -LO https://go.dev/dl/go1.24.2.linux-amd64.tar.gz
> sudo rm -rf /usr/local/go
> sudo tar -C /usr/local -xzf go1.24.2.linux-amd64.tar.gz
> echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
> source ~/.bashrc
> go version
> ```
>
> Clone and deploy:
>
> ```bash
> sudo mkdir -p /opt/devbits
> sudo chown -R "$USER":"$USER" /opt/devbits
> cd /opt/devbits
> git clone https://github.com/devbits-go/DevBits.git .
> git checkout aws-ready-main
> cd backend
> cp .env.example .env
> # edit .env with production values (DATABASE_URL, secrets, CORS, etc.)
> ./scripts/deploy-aws-native.sh
> ```
>
> Verify service:

> Rebuild and restart:
>
> ```bash
> sudo systemctl status devbits-api --no-pager
> sudo journalctl -u devbits-api -n 120 --no-pager
> curl -i http://127.0.0.1:8080/health
> docker compose up -d --build
> ```
>

> [!TIP]
> AWS deploy uses native `systemd` (no Docker or nginx required in production).
> See `backend/docs/AWS_TRANSFER_NO_NGINX.md` for full runbook.
> Check `backend/scripts/README.md` for database operations.

## Build

> **Android Production Build**
>
> ```bash
> npx eas build -p android --profile production
> npx --yes eas-cli build -p android --profile production
> ```

> [!NOTE]
Expand All @@ -63,11 +35,12 @@
> Replace `android` with `ios` and fill out proper credentials.
>
> ```bash
> npx eas build -p ios --profile production
> npx --yes eas-cli build -p ios --profile production
> ```

> [!NOTE]
> Currently requires MY credentials. Need to add team credentials.
> If iOS build fails with Apple 403 / PLA message, accept the latest Apple Developer Program License Agreement first:
> https://developer.apple.com/account

## Submit

Expand All @@ -76,14 +49,18 @@
> Copy file out of expo and create new release on Google Play Console.

> [!NOTE]
> `npx eas submit -p android` failed, so manual submission is required until fix is in place. Im not sure what is happening.
> Use:
> ```bash
> npx --yes eas-cli submit -p android --latest --profile production
> ```
> If it fails, verify the service account key path in `frontend/eas.json` points to `../devbits-play-service-account.json` and that Google Play API access is enabled for the linked service account.

> **iOS to App Store**
>
> ```bash
> npx eas submit -p ios --latest --profile production
> npx --yes eas-cli submit -p ios --latest --profile production
> ```

---

`Workflow: AWS Backend Deploy → EAS Build → EAS Submit`
`Workflow: Backend Setup → EAS Build → EAS Submit`
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img alt="Expo" src="https://img.shields.io/badge/Expo-SDK_54-000020?style=for-the-badge&logo=expo&logoColor=white" />
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-5.3-3178C6?style=for-the-badge&logo=typescript&logoColor=white" />
<img alt="PostgreSQL" src="https://img.shields.io/badge/PostgreSQL-Data-4169E1?style=for-the-badge&logo=postgresql&logoColor=white" />
<img alt="AWS" src="https://img.shields.io/badge/AWS-Deployed-FF9900?style=for-the-badge&logo=amazonaws&logoColor=white" />
<img alt="Docker" src="https://img.shields.io/badge/Docker-Compose-2496ED?style=for-the-badge&logo=docker&logoColor=white" />
</p>

---
Expand Down Expand Up @@ -113,7 +113,7 @@ Anyone can react, follow, comment, and join the conversation.
- Go + Gin REST backend with JWT auth and middleware-protected routes.
- PostgreSQL production database and SQLite-friendly test workflows.
- React Native + Expo mobile client for Android and iOS.
- AWS-hosted backend deployment path.
- Docker Compose + nginx backend deployment path.

</details>

Expand All @@ -123,7 +123,7 @@ Anyone can react, follow, comment, and join the conversation.
Backend: Go (Gin API, JWT auth, DB query layer)
Frontend: TypeScript (React Native + Expo Router)
Database: PostgreSQL (production), SQLite (test mode)
Infra: AWS EC2 + AWS RDS
Infra: Docker Compose + nginx
```

## Architecture at a Glance
Expand Down Expand Up @@ -154,4 +154,3 @@ Instead of posting polished outcomes only, builders can share:

- Product and deployment runbook: [INSTRUCTIONS.md](INSTRUCTIONS.md)
- Backend structure and scripts: [backend/scripts/README.md](backend/scripts/README.md)
- AWS deployment notes: [docs/AWS_TRANSFER_NO_NGINX.md](docs/AWS_TRANSFER_NO_NGINX.md)
89 changes: 89 additions & 0 deletions SECURITY_NEEDS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
DevBits Security Setup (Cloudflare Domain + Cloudflare Tunnel)

0) Before you start
0.1) Keep current DNS and router setup unchanged until Step 8 verification passes.
0.2) Keep current domain live during migration (no cutover yet).
0.3) Have access to: Cloudflare account, domain registrar account, server SSH/root, router admin panel.

1) Cloudflare domain onboarding
1.1) In Cloudflare, click Add a site.
1.2) Enter your owned domain (not a shared ddns.net hostname).
1.3) Select Free plan and continue.
1.4) Copy the two Cloudflare nameservers shown.

2) Registrar nameserver change
2.1) Open registrar panel for your owned domain.
2.2) Go to Nameservers.
2.3) Replace existing nameservers with the two Cloudflare nameservers.
2.4) Save changes.
2.5) If DNSSEC is enabled at registrar, disable it temporarily.
2.6) Wait until Cloudflare zone status is Active.

3) Create Cloudflare Tunnel
3.1) In Cloudflare dashboard, open Zero Trust.
3.2) Go to Networks -> Tunnels.
3.3) Click Create a tunnel.
3.4) Select Cloudflared.
3.5) Set tunnel name: devbits-home.
3.6) Keep installation/auth command page open.

4) Install cloudflared connector on server
4.1) SSH into server.
4.2) Run the exact install/auth command from Cloudflare tunnel page.
4.3) Confirm tunnel connector shows Healthy/Connected in Cloudflare.

5) Public hostname route for backend
5.1) In Cloudflare tunnel page, open Public Hostnames.
5.2) Click Add a public hostname.
5.3) Subdomain: api (or preferred label).
5.4) Domain: your owned Cloudflare domain.
5.5) Service Type: HTTP.
5.6) URL: localhost:80.
Comment on lines +40 to +41
5.7) Save.

6) Cloudflare edge security controls
6.1) SSL/TLS -> Overview: set mode to Full (strict).
6.2) SSL/TLS -> Edge Certificates: enable Always Use HTTPS.
6.3) Security -> WAF: enable managed rules.
6.4) Security -> Bots: enable Bot Fight Mode.
6.5) Security -> Rate Limiting Rules: add
6.5.1) /auth/login strict limit.
6.5.2) /auth/register strict limit.
6.5.3) /api/* moderate limit.

7) Server config updates (before cutover)
7.1) In backend/.env set DEVBITS_ADMIN_LOCAL_ONLY=1.
7.2) In backend/.env set DEVBITS_CORS_ORIGINS to the new Cloudflare URL (example: https://api.yourdomain.com).
7.3) Keep DEVBITS_TRUST_PROXY=true.
7.4) Rebuild/restart services: cd backend && docker compose up -d --build backend nginx.
7.5) Check status: docker compose ps.
7.6) Check logs: docker compose logs --tail=200 nginx.

8) Validate new path before closing ports
8.1) Open https://api.yourdomain.com and confirm app/backend responses.
8.2) Verify tunnel is Healthy in Cloudflare Zero Trust.
8.3) Verify Cloudflare analytics show requests to hostname.
8.4) Verify login/API rules trigger under burst testing.

9) Close public origin exposure
9.1) Router: remove/disable port forwarding for 80 and 443.
9.2) Host firewall: deny inbound 80/443 from internet.
9.3) Keep only tunnel-based ingress path.

10) Host hardening
10.1) Disable SSH password auth (key-only).
10.2) Disable SSH root login.
10.3) Install and configure fail2ban.
10.4) Enable unattended security updates.
10.5) Disable UPnP on router.

11) Post-cutover verification
11.1) Cloudflare hostname works from external network.
11.2) Direct home IP on 80/443 is closed.
11.3) Bot/WAF/rate-limit events appear in Cloudflare dashboard.
11.4) No DNS record leaks direct home IP for app hostname.

12) Rollback (if emergency)
12.1) Re-enable 80/443 port forward on router.
12.2) Temporarily point clients back to previous hostname.
12.3) Keep investigating tunnel failure via cloudflared logs and Cloudflare tunnel status.
7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DevBits Admin Console Fix/Build TODO

## [✓] 1. Fix admin.css (@extend → explicit, add nav-bottom-list)
## [✓] 2. Full rewrite admin.js (FlatButton, API, pages, etc.)
## [✓] 3. Verify/update console.html & index.html
## [ ] 4. Test locally
## [ ] 5. Complete ✓
18 changes: 9 additions & 9 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
DEVBITS_ADMIN_KEY=replace-with-strong-admin-key
DEVBITS_JWT_SECRET=replace-with-64-plus-char-random-secret

# Preferred for AWS (RDS/Postgres)
# Replace user/password/endpoint/db name with your real RDS values.
# URL-encode special characters in password (for example ! -> %21).
DATABASE_URL=postgres://postgres:replace-with-strong-password@your-rds-endpoint:5432/postgres?sslmode=require
# Docker/Postgres values used by backend/docker-compose.yml
# Keep sslmode=disable for the internal Docker network.
DATABASE_URL=postgres://devbits:replace-with-strong-password@db:5432/devbits?sslmode=disable

# Optional local fallback values (used only when DATABASE_URL is unset)
# Docker database bootstrap values
POSTGRES_DB=devbits
POSTGRES_USER=devbits
POSTGRES_PASSWORD=replace-with-strong-password

# Optional: comma-separated CORS origins for browser clients.
DEVBITS_CORS_ORIGINS=https://devbits.app,https://www.devbits.app
DEVBITS_CORS_ORIGINS=https://devbits.ddns.net

# AWS/ALB runtime settings
# Runtime settings for Docker + nginx reverse proxy
DEVBITS_DEBUG=0
DEVBITS_API_ADDR=0.0.0.0:8080
DEVBITS_ADMIN_LOCAL_ONLY=0
# Set true only when running behind a trusted proxy (ALB/nginx) that sets X-Forwarded-Proto.
DEVBITS_ADMIN_LOCAL_ONLY=1
# Set true only when running behind a trusted proxy (nginx) that sets X-Forwarded-Proto.
DEVBITS_TRUST_PROXY=true
Loading
Loading