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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Database
DATABASE_URL=postgres://guild_user:guild_password@localhost:5432/guild_genesis
DATABASE_URL=postgres://guild_user:guild_password@postgres:5432/guild_genesis

# Frontend
PUBLIC_WALLET_CONNECT_PROJECT_ID=your_project_id_here
Expand Down
86 changes: 8 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,76 +38,28 @@ This is a monorepo containing:
## Quick Start

### Prerequisites
- [Nix](https://nixos.org/download.html) with flakes enabled
- [direnv](https://direnv.net/) (optional, for automatic environment loading)
- [just](https://github.com/casey/just) (command runner)
- [Docker](https://www.docker.com/)
- [Foundry](https://book.getfoundry.sh/getting-started/installation) (for smart contracts)

### Setup

1. **Clone and enter the development environment:**
```bash
git clone <repository-url>
cd TheGuildGenesis

# If using direnv (recommended)
direnv allow

# Or manually enter the Nix shell
nix develop
```

2. **Install dependencies:**
```bash
just install-all
```

### Development Workflow

#### Quick Start

```bash
# Set up the database
just db-setup
cd backend
cargo install sqlx-cli --no-default-features --features rustls,postgres
cargo sqlx prepare -- --bin guild-backend
```

# Start both frontend and backend
just dev
```bash
docker-compose up -d
```

**Access the applications:**
- Frontend: http://localhost:4321
- Backend API: http://localhost:3001
- PostgreSQL: localhost:5432

#### Individual Services

```bash
# Start database only
just db-start

# Start frontend only
just dev-frontend

# Start backend only
just dev-backend

# Stop database
just db-stop
```

#### Database Management

```bash
# Set up database with migrations
just db-setup

# Reset database completely
just db-reset

# Stop database
just db-stop
```

#### Smart Contracts Development

```bash
Expand All @@ -132,17 +84,6 @@ forge script script/TheGuildBadgeRegistry.s.sol:TheGuildBadgeRegistryScript --rp
forge script script/TheGuildBadgeRegistry.s.sol:TheGuildBadgeRegistryScript --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast
```

### Available Commands

Run `just help` to see all available commands:

- **Development:** `just dev`, `just dev-frontend`, `just dev-backend`
- **Database:** `just db-start`, `just db-stop`, `just db-setup`, `just db-reset`
- **Build:** `just build`, `just build-frontend`, `just build-backend`
- **Testing:** `just test`, `just test-frontend`, `just test-backend`
- **Code Quality:** `just lint`, `just format`
- **Utilities:** `just clean`, `just help`

## Smart Contracts

The `the-guild-smart-contracts/` directory contains our Solidity smart contracts built with Foundry.
Expand Down Expand Up @@ -203,27 +144,16 @@ event BadgeCreated(bytes32 indexed name, bytes32 description, address indexed cr

## Development Philosophy

- **Nix-first development** - Reproducible environments without Docker overhead
- **Simple first, complex later** - Start with MVP, iterate
- **Non-profit, member-driven** - Community ownership
- **Horizontal governance** - Flat organization structure
- **Action over endless talk** - Build and ship
- **We use what we build** - Dogfooding our own tools

### Why Nix?

This project uses Nix for development instead of Docker because:

- **Reproducible environments** - Everyone gets identical toolchains
- **No container overhead** - Direct process execution, faster builds
- **Simpler setup** - One command (`nix develop`) gets you everything
- **Better performance** - No Docker daemon, faster file system access
- **True reproducibility** - Nix ensures exact same versions across all systems

## Contributing

This is a community-driven project. Join our [Discord](https://discord.gg/pg4UgaTr) to discuss features, propose changes, and contribute to the codebase.

## License

See [LICENSE](LICENSE) file for details.
See [LICENSE](LICENSE) file for details.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM rust:latest AS build
WORKDIR /app
COPY . .
RUN cargo build --release

FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m appuser
WORKDIR /app
COPY --from=build /app/target/release/guild-backend /app/app
ENV RUST_LOG=info PORT=3001
EXPOSE 3001
USER appuser
CMD ["/app/app"]

43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.9"

services:
postgres:
image: postgres:16
environment:
POSTGRES_USER: guild_user
POSTGRES_PASSWORD: guild_password
POSTGRES_DB: guild_genesis
ports:
- "5432:5432"
volumes:
- pg_data:/var/lib/postgresql/data

backend:
build: ./backend
command: ["/app/app"]
environment:
RUST_LOG: debug
RUST_BACKTRACE: 1
PORT: 3001
env_file:
- .env
ports:
- "3001:3001"
depends_on:
- postgres

frontend:
build: ./frontend
command: npm run dev -- --host 0.0.0.0 --port 4321
ports:
- "4321:4321"
environment:
HOST: 0.0.0.0
PORT: 4321
PUBLIC_WALLET_CONNECT_PROJECT_ID: ${PUBLIC_WALLET_CONNECT_PROJECT_ID}
PUBLIC_API_URL: ${PUBLIC_API_URL}
depends_on:
- backend

volumes:
pg_data:
15 changes: 15 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20-alpine AS build
WORKDIR /app
RUN apk add --no-cache python3 make g++
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app ./
ENV PORT=8080
EXPOSE 8080
CMD ["node", "server.js"]
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"build": "astro build && node dist/server/entry.mjs",
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"test": "vitest",
Expand Down
Loading
Loading