Skip to content

Commit

Permalink
add favicon, remove unused axiosconfig file, use volumes in docker-co…
Browse files Browse the repository at this point in the history
…mpose-prod, remove unused networks n docker-compose, extend readme
  • Loading branch information
dreth committed Jul 27, 2024
1 parent 0e6841b commit e853044
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 63 deletions.
76 changes: 62 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,77 @@
# hbd

Birthday bot backend and frontend
HBD is a simple application (which you can self-host) that serves birthday reminders through telegram.

## Migrations
## Usage

### Postgres
The application usage is very straightforward:

#### Up
1. Sign up for an account
+ Requires an email, password, reminder time, timezone, [telegram bot API key](#bot-api-key), and [telegram chat ID](#chat-id)
2. Add birthdays
3. Receive reminders

```bash
migrate -database 'postgres://postgres:postgres@localhost:6684/postgres?sslmode=disable' -path ./migrations up
```
### Getting a bot API key and chat ID

#### Down
#### Bot API key

```bash
migrate -database 'postgres://postgres:postgres@localhost:6684/postgres?sslmode=disable' -path ./migrations down
```
1. Open Telegram
2. Search for `BotFather`
3. Start a chat with `BotFather`
4. Use the `/newbot` command to create a new bot
5. Follow the instructions to create a new bot
6. Copy the API key

#### Down to last migration
Through this API key the application can send messages to you through the bot.

```bash
migrate -database 'postgres://postgres:postgres@localhost:6684/postgres?sslmode=disable' -path ./migrations down 1
#### Chat ID

1. Open Telegram on your mobile device
2. Send `/start` to your newly created bot
3. Send a message to the bot
4. Open the following URL in your browser: `https://api.telegram.org/bot<API_KEY>/getUpdates`
5. Look for the `chat` object in the JSON response
6. Copy the `id` field

Using this ID the application can send messages to your chat specifically.

## Self-hosting

### Docker

The application is containerized using docker, we use sqlite as the database by default.

#### Docker compose

The repo includes two docker-compose files.

1. `docker-compose.yml` - This file is used to run the application locally with no reverse proxy. This works fine for use within a local network. We map the ports `8417` and `8418` to the host machine. Port `8417` is the backend port and port `8418` is the frontend port.

```yaml
---
services:
hbd:
build:
context: .
dockerfile: Dockerfile
container_name: hbd
ports:
- "8417:8417"
- "8418:8418"
volumes:
- ./hbd-data:/app
environment:
- DB_TYPE=sqlite
- DATABASE_URL=/app/backend/hbd.db
- MASTER_KEY=35e150e7ca83247f18cb1a37d61d8e161dddec06027f5db009b34da48c25f1b5
- PORT=8418
- ENVIRONMENT=development
- CUSTOM_DOMAIN_FRONTEND=https://hbd.lotiguere.com
- CUSTOM_DOMAIN_BACKEND=https://hbd-api.lotiguere.com
```
## Migrations
### SQLite
#### Up
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
context: .
dockerfile: Dockerfile
container_name: hbd
volumes:
- ./hbd-data:/app
restart: always
environment:
- DB_TYPE=sqlite
Expand Down
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ services:
- ENVIRONMENT=development
- CUSTOM_DOMAIN_FRONTEND=https://hbd.lotiguere.com
- CUSTOM_DOMAIN_BACKEND=https://hbd-api.lotiguere.com

networks:
default:
name: hbd-network
Binary file modified frontend/app/favicon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions frontend/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import {
OctagonAlert,
CircleHelp,
GitPullRequestArrow,
BookOpen,
Coffee,
} from "lucide-react";
import { GitHubLogoIcon } from "@radix-ui/react-icons";
import {
Select,
SelectTrigger,
Expand Down Expand Up @@ -509,7 +509,7 @@ export default function Home() {
target="_blank"
rel="noopener noreferrer"
>
<GitPullRequestArrow className="w-5 h-5 hover:text-accent" />
<GitHubLogoIcon className="w-5 h-5 hover:text-accent" />
</Link>
</TooltipTrigger>
<TooltipContent>
Expand Down
7 changes: 2 additions & 5 deletions frontend/lib/api/apiService.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

import axios from 'axios';

var baseURL = 'https://hbd-api.lotiguere.com';
if (process.env.ENVIRONMENT === 'production') {
baseURL = 'https://hbd-api.lotiguere.com';
}
var baseURL = process.env.ENVIRONMENT === 'production' ? 'https://hbd-api.lotiguere.com' : 'http://localhost:8417';


// Create an Axios instance
const api = axios.create({
Expand Down
38 changes: 0 additions & 38 deletions frontend/lib/api/axiosConfig.js

This file was deleted.

0 comments on commit e853044

Please sign in to comment.