Files
Filamenteka/DEPLOYMENT.md

101 lines
2.2 KiB
Markdown

# Filamenteka Deployment Guide
## Architecture
Filamenteka now uses:
- **Frontend**: Next.js deployed on AWS Amplify
- **Database**: PostgreSQL on AWS RDS (publicly accessible)
- **API**: Node.js server that can be run locally or deployed anywhere
## AWS RDS Setup
1. Navigate to the terraform directory:
```bash
cd terraform
```
2. Initialize Terraform:
```bash
terraform init
```
3. Apply the infrastructure:
```bash
terraform apply
```
4. After deployment, get the database connection details:
```bash
terraform output -json
```
5. Get the database password from AWS Secrets Manager:
```bash
aws secretsmanager get-secret-value --secret-id filamenteka-db-credentials --query SecretString --output text | jq -r .password
```
## Running the API
### Option 1: Local Development
1. Create `.env` file in the `api` directory:
```
DATABASE_URL=postgresql://filamenteka_admin:[PASSWORD]@[RDS_ENDPOINT]/filamenteka
JWT_SECRET=your-secret-key-here
ADMIN_PASSWORD=your-password-here
PORT=4000
```
2. Install dependencies and run migrations:
```bash
cd api
npm install
npm run migrate
npm run dev
```
### Option 2: Deploy on a VPS/Cloud Service
You can deploy the Node.js API on:
- Heroku
- Railway
- Render
- AWS EC2
- DigitalOcean
- Any VPS with Node.js
Just ensure the `DATABASE_URL` points to your RDS instance.
## Frontend Configuration
Update `.env.local` to point to your API:
```
NEXT_PUBLIC_API_URL=http://localhost:4000/api # For local
# or
NEXT_PUBLIC_API_URL=https://your-api-domain.com/api # For production
```
## Security Notes
1. **RDS Security**: The current configuration allows access from anywhere (0.0.0.0/0). In production:
- Update the security group to only allow your IP addresses
- Or use a VPN/bastion host
- Or deploy the API in the same VPC and restrict access
2. **API Security**:
- Change the default admin password
- Use strong JWT secrets
- Enable HTTPS in production
## Database Management
Connect to the PostgreSQL database using any client:
```
psql postgresql://filamenteka_admin:[PASSWORD]@[RDS_ENDPOINT]/filamenteka
```
Or use a GUI tool like:
- pgAdmin
- TablePlus
- DBeaver
- DataGrip