Skip to content

Commit

Permalink
Merge pull request #1 from yyewolf/docs
Browse files Browse the repository at this point in the history
Docs
  • Loading branch information
yyewolf committed Aug 11, 2023
2 parents 5b1e555 + 837036a commit bf44fd0
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 19 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## exclude auto generated files from codeclimate analysis
exclude_patterns:
- "backend/autogen/bar.gen.go"
- "frontend/src/lib/api/*"
- "config/"
- "db/"
- "dist/"
- "features/"
- "**/node_modules/"
- "script/"
- "**/spec/"
- "**/test/"
- "**/tests/"
- "Tests/"
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"
117 changes: 116 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,116 @@
# bar
<p align="center">
<p align="center">
<a href="https://github.com/yyewolf/bar/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/yyewolf/bar.svg?style=flat-square"></a>
<a href="https://travis-ci.org/yyewolf/bar"><img alt="Travis" src="https://travis-ci.org/yyewolf/bar.svg?branch=master"></a>
<a href="/LICENSE.md"><img alt="Software License" src="https://img.shields.io/badge/license-GPLv3-brightgreen.svg?style=flat-square"></a>
<a href="https://codeclimate.com/github/yyewolf/bar/test_coverage"><img src="https://api.codeclimate.com/v1/badges/d9fcf617937d6026221f/test_coverage" /></a>
<a href="https://codeclimate.com/github/yyewolf/bar/maintainability"><img src="https://api.codeclimate.com/v1/badges/d9fcf617937d6026221f/maintainability" /></a>
<a href="https://goreportcard.com/report/github.com/yyewolf/bar/backend"><img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/yyewolf/bar/backend"></a>
<a href="https://godoc.org/github.com/yyewolf/bar/backend"><img src="https://godoc.org/github.com/yyewolf/bar/backend?status.svg" alt="GoDoc"></a>
</p>
</p>

# Le Bar

**Le Bar** is a monorepository containing both the frontend and backend components of a system designed to manage various aspects of a bar's operations. This document provides an overview of the project structure, setup instructions, and available commands.

## Presentation

<img src="docs/image.png" alt="presentation" width="50%">

## Dependencies

Before you begin, ensure you have the following dependencies installed:

- **Go:** The Go programming language is required to build and run the backend. You can download and install Go from the [official website](https://golang.org/).

- **Node.js:** Node.js is required to build and run the frontend. Download and install Node.js from the [official website](https://nodejs.org/).

- **Go-Task (task):** Task is a simple task runner for Go projects. It's used in this project for automating setup and regeneration tasks. You can install Task by following the instructions on the [GitHub repository](https://github.com/go-task/task).

## Project Structure

The repository is organized into the following components:

- **backend:** This folder contains the backend implementation of the application.
- **frontend:** This folder encompasses the entire frontend of the application, including terminal, admin panels & public interface.
- **bar.openapi.yml:** The OpenAPI specification for the project.
- **docker-compose.yml:** A configuration file for Docker Compose, enabling easy deployment of the MongoDB database and Mongo Express.
- **backend/Taskfile.yml and frontend/Taskfile.yml:** Contains tasks for setting up dependencies and regenerating API files using OpenAPI specifications.

## Configuration

- **Backend Configuration:**
- Copy the `.env.example` file located at `backend/.env.example` to `backend/.env` in the development environment. Adjust the values in `.env` as needed for your setup.

- **Google OAuth Configuration:**
- To enable Google OAuth, you need to create a Google Cloud project and obtain OAuth client credentials.
- Follow these steps to create and configure the Google project:
1. Go to the [Google Cloud Console](https://console.cloud.google.com/).
2. Create a new project.
3. In the project dashboard, navigate to "APIs & Services" > "Credentials."
4. Create OAuth client credentials. Choose "Web application" as the application type.
5. Set the authorized redirect URIs to match your backend URI (e.g., `http://localhost:8080/auth/google/callback`).
6. Once created, copy the Client ID and Client Secret.
- Update the following environment variables in `backend/.env` with the obtained credentials:
```
BAR_OAUTH_GOOGLE_CLIENT_ID=YOUR_CLIENT_ID
BAR_OAUTH_GOOGLE_CLIENT_SECRET=YOUR_CLIENT_SECRET
```

- **Frontend Configuration:**
- Copy the `frontend/static/config.dev.json` file to `frontend/static/config.json` in the development environment. Modify the settings in `config.json` to match your preferences.

## Setup

To get the project up and running, follow these steps:

1. **Start Database:**
- Run the following command to initiate the MongoDB database and Mongo Express UI:
```
docker-compose up
```

2. **Backend Setup:**
- Navigate to the `backend` folder.
- Run the setup task to install backend dependencies:
```
task setup
```

3. **Frontend Setup:**
- Navigate to the `frontend` folder.
- Run the setup task to install frontend dependencies:
```
task setup
```

4. **Regenerate API Files:**
- To regenerate API files based on OpenAPI specifications, run the following in either the `backend` or `frontend` folder, depending on which API files you need to generate (you only need to do so on bar.openapi.yml changes):
```
task regen
```

2. **Backend:**
- Navigate to the `backend` folder.
- Start the backend using the following command:
```
go run cmd/bar/main.go
```

3. **Frontend:**
- Navigate to the `frontend` folder.
- Start the frontend development server with:
```
npm run dev
```

Please note that actions requiring the terminal to be "safe" require an "X-Local-Token" for route access. For such cases, ensure the frontend is redeployed on the local machine using the local token.

## Contributing

Contributions to the project are welcome. If you encounter any issues or have suggestions, please submit an issue or pull request.

## License

This project is licensed under the [MIT License](LICENSE).
15 changes: 15 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BAR_MONGO_URI=mongodb://127.0.0.1:27017
BAR_MONGO_DB=bar
BAR_MONGO_TIMEOUT=3000

BAR_API_SESSION_SECRET=secret
BAR_API_ADMIN_SESSION_SECRET=secret
BAR_API_PORT=:8080
BAR_API_BASE_PATH=http://localhost:8080
BAR_API_FRONTEND_BASE_PATH=http://localhost:5173
BAR_API_LOCAL_TOKEN=jesuisleplusfort

BAR_OAUTH_GOOGLE_CLIENT_ID=cc
BAR_OAUTH_GOOGLE_CLIENT_SECRET=cc

BAR_LOG_LEVEL=debug
40 changes: 22 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
version: '3.5'

services:
# backend:
# build:
# dockerfile: Dockerfile
# network: host
# context: backend
# ports:
# - 9999:8080
# env_file:
# - backend/.env
# frontend:
# build:
# dockerfile: Dockerfile
# network: host
# context: frontend
# volumes:
# - ./frontend/static/config.dev.json:/app/build/config.dev.json:ro
# ports:
# - 9998:3000
backend:
build:
dockerfile: Dockerfile
network: host
context: backend
ports:
- 9999:8080
env_file:
- backend/.env
profiles:
- "dev"
frontend:
build:
dockerfile: Dockerfile
network: host
context: frontend
volumes:
- ./frontend/static/config.dev.json:/app/build/config.dev.json:ro
ports:
- 9998:3000
profiles:
- "dev"
mongo:
image: mongo
restart: always
Expand Down
Binary file added docs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bf44fd0

Please sign in to comment.