https://github.com/fres-sudo/pomo-server
Bun, Hono Server for Pomo Appπ
https://github.com/fres-sudo/pomo-server
Last synced: over 1 year ago
JSON representation
Bun, Hono Server for Pomo Appπ
- Host: GitHub
- URL: https://github.com/fres-sudo/pomo-server
- Owner: fres-sudo
- Created: 2024-08-08T20:31:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-25T13:22:45.000Z (over 1 year ago)
- Last Synced: 2025-01-25T14:22:05.688Z (over 1 year ago)
- Language: TypeScript
- Size: 705 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pomo Server π
Pomo Server is a backend application built to manage and serve the Pomo platform's API. The project is developed using **TypeScript** and runs on **Bun**, leveraging **Drizzle ORM** and **Postgres** for data management. The application integrates with **AWS S3** for storage, **Sentry** for monitoring, and uses Docker for containerization.
## Project Structure π§±
```sh
pomo-server/
βββ Dockerfile # Docker configuration
βββ README.md # Project documentation
βββ bun.lockb # Bun package lock file
βββ bunfig.toml # Bun configuration file
βββ docker-compose.yaml # Docker Compose setup
βββ drizzle.config.ts # Drizzle ORM configuration
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ src/ # Source code
β βββ common/ # Common utilities and base functionality
β βββ constants/ # Application constants
β βββ controllers/ # Route controllers for API endpoints
β βββ dtos/ # Data Transfer Objects for request validation
β βββ infrastructure/ # Application setup (e.g., database, Redis)
β βββ interfaces/ # TypeScript interfaces
β βββ middleware/ # Application middleware (e.g., authentication)
β βββ providers/ # Dependency injection providers
β βββ repositories/ # Data repositories for interacting with the database
β βββ services/ # Business logic services
β βββ tables/ # Drizzle ORM table definitions
β βββ tests/ # Test files
β βββ types/ # TypeScript type definitions
β βββ ui/ # UI utilities (if applicable)
β βββ utils/ # Helper functions and utilities
```
---
## Getting Started π
To get started with the project, follow these steps:
### 1. Clone the Repository π§βπ»
Clone the project repository to your local machine using the following command:
```bash
git clone https://github.com/fres-sudo/pomo-server.git
```
### 2. Set Up Docker π³
Docker is used to set up the project. First, make sure you have Docker and Docker Compose installed on your machine.
### 3. Build and Run with Docker πββοΈ
To build and run the project using Docker, run the following command in the project root:
```bash
bun initialize
```
This will:
- Install the dependencies.
- Build the Docker image using Docker Compose.
- Start the containers for the application.
- Set up the environment with all necessary dependencies, including Drizzle migrations.
### 4. Drizzle Migrations π§³
Drizzle migrations are automatically handled with Docker. If you need to run a migration manually, use the custom command defined in the `package.json`:
TODO
This will run the migration for Drizzle ORM on the database.
### 5. Access the Application π
Once the Docker containers are up, you can access the application at `http://localhost:9000` (or another configured port).
---
## Available Scripts βοΈ
Here are the key commands defined in the `package.json`:
| Command | Description |
|------------------------|-------------------------------------------------------------|
| `bun install` | π οΈ Installs project dependencies using Bun. |
| `bun dev` | π Starts the development server. |
| `bun initialize` | π Starts the production server with docker and drizzle.|
| `bun test` | π§ͺ Runs tests using Bun's test runner. |
| `bun docker:up` | π³ Starts the Docker containers as per `docker-compose.yaml`. |
| `bun docker:build` | π¨ Builds Docker images defined in `docker-compose.yaml`. |
| `bun docker:logs` | π₯ Show the logs on the pomo-backend container. |
| `bun db:generate` | π Generate the migrations scripts to update the db schema |
| `bun db:push` | β‘οΈ Push the migrations `sql` file to the db instance. |
| `bun db:migrate` | ποΈ Perform the migration. |
| `bun db:studio` |π₯οΈ Start the drizzle studio. |
---
## Workflows π
We use GitHub Actions for Continuous Integration (CI) and Continuous Deployment (CD).
The workflow is triggered on every push to the `main` branch, and it involves two main jobs:
### 1. Publish Docker Image to GHCR π³
The first job builds the Docker image and pushes it to the GitHub Container Registry (GHCR). Hereβs a summary of the steps:
- **Checkout Code**: Pulls the latest code from the `main` branch.
- **Log in to GitHub Container Registry**: Authenticates with GHCR using GitHub secrets.
- **Build and Push Docker Image**: Builds the Docker image and pushes it to GHCR with the tag `latest`.
### 2. Deploy to VPS π
The second job deploys the built Docker image to a Virtual Private Server (VPS). Hereβs how it works:
- **Install SSH Key**: Installs the SSH private key for secure access to the VPS.
- **Pull and Deploy on VPS**: SSH into the VPS, pulls the latest code from the `main` branch, and rebuilds the Docker container with `docker-compose up --build -d`.
This setup ensures that your application is continuously built and deployed whenever thereβs a change in the `main` branch.
---
## π Monitoring and Logs
- Sentry: Ensure the SENTRY_DSN is set in your .env file for error tracking.
- Docker Logs: View Docker container logs.
```bash
bun docker:logs
```
## π License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE.md) file for details.
## Contributing π€
We welcome contributions to this project! If you'd like to help improve the project, please fork the repository, create a new branch for your feature or bug fix, and submit a pull request. Ensure that your code follows the existing style, includes relevant tests, and passes all linting and testing checks. If youβre unsure about something or have questions, feel free to open an issue, and weβll be happy to assist! Your contributions help make this project better for everyone. Thank you for your support! π