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
56 changes: 56 additions & 0 deletions .github/workflows/code-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Code - Backend"

on:
pull_request:
types:
- synchronize
- opened
paths:
- 'backend/**'

jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
strategy:
matrix:
python-version: [ "3.11" ]
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
- name: Install All Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run Ruff
run: ruff check --output-format=github
- name: Run Migrations
run: |
eval $(grep -m 4 'export' README.md | tail -n 4)
export ENV=test
export SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@localhost:5432/postgres
alembic upgrade head
- name: Check for vulnerabilities
uses: pypa/gh-action-pip-audit@v1.1.0
with:
inputs: backend/requirements.txt backend/requirements-dev.txt
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dependabot-auto-merge
name: "Dependabot Auto-Merge"
on: pull_request_target

permissions:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/staging-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Staging - Backend"

on:
push:
branches:
- develop
paths:
- 'backend/**'

jobs:
deploy-backend:
name: "Deploy Backend"
runs-on: ubuntu-latest
steps:
- name: "Send webhook to Coolify"
run: |
curl --request GET '${{ secrets.COOLIFY_BACKEND_STAGING_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

- name: "Send webhook to Discord"
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_STAGING_WEBHOOK_URL }}
nocontext: true
username: "kilobyte-bot"
avatar_url: "https://avatars.githubusercontent.com/u/98578253?s=200&v=4"
title: "Backend Deployment to Staging"
description: "Backend code has been pushed to the `develop` branch, triggering a new build for deployment to the staging environment."
28 changes: 28 additions & 0 deletions .github/workflows/staging-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Staging - Frontend"

on:
push:
branches:
- develop
paths:
- 'frontend/**'

jobs:
deploy-frontend:
name: "Deploy Frontend"
runs-on: ubuntu-latest
steps:
- name: "Send webhook to Coolify"
run: |
curl --request GET '${{ secrets.COOLIFY_FRONTEND_STAGING_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

- name: "Send webhook to Discord"
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_STAGING_WEBHOOK_URL }}
nocontext: true
username: "kilobyte-bot"
avatar_url: "https://avatars.githubusercontent.com/u/98578253?s=200&v=4"
title: "Frontend Deployment to Staging"
description: "Frontend code has been pushed to the `develop` branch, triggering a new build for deployment to the staging environment."
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LAN-party Management System (LANMS) is a web-based application that you can self
## Current Project Status
LANMS is currently in development and is **not ready for production use**. We are working hard to get it ready for the first public release.

**Check out the [release page](https://github.com/kilobyteno/LANMS/releases) for more information or join our [Discord](https://kilobyte.no/discord) to stay updated!**

We started the development of the new LANMS 3.0 in February 2023 originally, but other priorities and issues out of our control occurred so we picked it back up in February 2024. But now, as of 25th of September 2024, we are restarting the development from scratch to make it more user-friendly, scalable, flexible and open-source.

## Contribution
Expand Down
31 changes: 31 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ENV=local
JWT_PUBLIC_KEY=""
JWT_PRIVATE_KEY=""
OTP_SECRET_KEY=NNUWY33CPF2GKLTON4======
PORTAL_URL=http://localhost:3000

# Optional variables
CODE_BUILD=
DEBUG=true
DATBASE_DEBUG=

DB_HOST=localhost
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_PORT=5432
DB_DIALECT=postgresql
DB_NAME=lanms-core

JWT_ALGORITHM=RS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
REFRESH_TOKEN_EXPIRE_MINUTES=43200

FROM_EMAIL=hello@lanms.net
SENTRY_DSN=
SENDGRID_API_KEY=
POSTMARK_API_KEY=

PASSWORD_MIN_LENGTH=12
MAX_IMAGE_SIZE_KB=10240
MAX_FILE_SIZE_KB=10240
SUPER_ADMINS=
164 changes: 164 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.DS_Store
.vscode
.ruff_cache
.run/*
9 changes: 9 additions & 0 deletions backend/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.4
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
31 changes: 31 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use the official Python image as base image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Set working directory in the container
WORKDIR /app

# Install system dependencies
RUN apt-get update \
&& apt-get install -y gcc \
libpq-dev postgresql-client \
&& rm -rf /var/lib/apt/lists/* # Reduce the image size after installing dependencies

# Upgrade pip
RUN pip install --upgrade pip

# Install Python dependencies
COPY requirements.txt /app
RUN pip install --no-cache-dir -r requirements.txt

# Copy the FastAPI application code into the container
COPY . .

# Expose port 8000 to the outside world
EXPOSE 8000

# Run the FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Loading
Loading