https://github.com/thejoltjoker/kreacon
Kreacon is a platform where creativity meets competition, allowing users to share and get involved
https://github.com/thejoltjoker/kreacon
azure drizzle postgresql svelte
Last synced: 8 months ago
JSON representation
Kreacon is a platform where creativity meets competition, allowing users to share and get involved
- Host: GitHub
- URL: https://github.com/thejoltjoker/kreacon
- Owner: thejoltjoker
- License: mit
- Created: 2024-09-16T18:00:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-26T19:00:54.000Z (over 1 year ago)
- Last Synced: 2024-12-26T20:16:54.993Z (over 1 year ago)
- Topics: azure, drizzle, postgresql, svelte
- Language: Svelte
- Homepage:
- Size: 66.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Kreacon
## For Mattias
Hi!
It's probably easier to just use the deployed version of the app, a bit of a hassle to get everything set up with Azure.
As for ticket you can use any `UUID` to get a ticket from the external api (`crypto.randomUUID()` works great for generating a ticket number).
## Getting Started
### Prerequisites
- Docker
- Node.js (v20)
- npm
- nvm (optional, for switching Node versions)
### Development Setup
1. Make sure you are using Node 20:
```bash
nvm use 20 # optional, if you have nvm installed
node --version
```
2. Start the PostgreSQL database:
```bash
docker compose up -d
```
3. Install dependencies:
```bash
npm install
```
4. Set up environment variables:
- Copy `.env.example` to `.env`
- `cp .env.example .env`
- Update the values as needed
5. Initialize the database:
```bash
npm run db:reset # Runs migrations and seeds the database
```
6. Start the development server:
```bash
npm run dev
```
7. Open [http://localhost:5173](http://localhost:5173) in your browser
### Additional Notes
- Use `docker compose down` to stop the database container
- The database will be accessible at `localhost:5432` with the credentials in `.env`
- Run `npm run db:studio` to view/edit database content
- You need to create OAuth apps for Discord and Github if you want to use them
- [Create Discord OAuth app](https://discord.com/developers/applications)
- [Create Github OAuth app](https://github.com/settings/applications/new)
- You need to create an Azure Storage account and set the `AZURE_STORAGE_ACCOUNT_KEY` in `.env`
- [Create Azure Storage Account](https://portal.azure.com/#create/Microsoft.StorageAccount-ARM)
## Building
To create a production version of your app:
```bash
npm run build
```
## Commands
| Command | Description |
| ---------------- | --------------------------------------- |
| `dev` | Spin up SvelteKit dev server |
| `build` | Build for production |
| `preview` | Preview production build |
| `check:watch` | Run Svelte check in watch mode |
| `check` | Run Svelte check |
| `commitlint` | Lint commit messages |
| `db:dbml` | Generate dbml file |
| `db:generate` | Generate migrations |
| `db:migrate` | Run migrations |
| `db:push` | Push current schema to database |
| `db:reset` | Run migrations and seed database |
| `db:seed` | Seed database |
| `db:start` | Run PostgreSQL in a docker container |
| `db:studio` | Start Drizzle Studio |
| `format` | Format code |
| `lint:fix` | Lint and fix errors |
| `lint` | Lint code |
| `logbook` | Generate logbook entry |
| `prepare` | Husky |
| `swa:build` | Build for Azure Static Web Apps |
| `swa:deploy` | Deploy to Azure Static Web Apps |
| `swa:start` | Start Azure Static Web Apps |
| `test:e2e` | Run end-to-end tests with Playwright |
| `test:e2e:ui` | Run end-to-end tests with Playwright UI |
| `test:unit` | Run unit tests with Vitest |
| `test` | Run all tests |
| `i18n:translate` | Translate i18n with Ollama |
| `i18n:check` | Check i18n coverage |
## Environment variables
### .env
```
BASE_URL=http://localhost:5173
DATABASE_URL=postgresql://root:mysecretpassword@localhost:5432/kreacon
DB_HOST=localhost
DB_NAME=kreacon
DB_PASSWORD=mysecretpassword
DB_PORT=5432
DB_USER=root
NODE_ENV=development
OAUTH_DISCORD_CLIENT_ID=
OAUTH_DISCORD_CLIENT_SECRET=
OAUTH_DISCORD_REDIRECT_URI=
OAUTH_GITHUB_CLIENT_ID=
OAUTH_GITHUB_CLIENT_SECRET=
OAUTH_GITHUB_REDIRECT_URI=
TICKET_API_URL=
BODY_SIZE_LIMIT=10485760
AZURE_STORAGE_ACCOUNT_NAME=
AZURE_STORAGE_ACCOUNT_KEY=
```
### .env.test.local
Same as `.env` but can use local database.
```
...
NODE_ENV=test
DATABASE_URL=postgresql://root:mysecretpassword@localhost:5432/test
```
### .env.test
Used for CI/CD. Include these additional variables and update to use your hosted test database:
```
NODE_ENV=test
DATABASE_URL=postgresql://:@:5432/test
AZURE_POSTGRESQL_SERVER_NAME=
AZURE_POSTGRESQL_RESOURCE_GROUP=
```
### .env.production
Used when deploying to production. Update the following variables to use your hosted database and production settings:
```
NODE_ENV=production
DATABASE_URL=postgresql://:@:5432/
BASE_URL=https://your-production-domain.com
AZURE_POSTGRESQL_SERVER_NAME=
AZURE_POSTGRESQL_RESOURCE_GROUP=
# OAuth settings (update with production URLs)
OAUTH_DISCORD_REDIRECT_URI=https://your-production-domain.com/auth/discord/callback
OAUTH_GITHUB_REDIRECT_URI=https://your-production-domain.com/auth/github/callback
```
## TODO
- [ ] Remove `For Mattias` from the README
### Profile
- [ ] Fix bug where user gets logged out randomly
- [ ] Update profile page after adding ticket
### Entries
#### Create entry
- [ ] Show add ticket form if user has no tickets
### Admin
- [ ] Disallow change of submission and voting dates if already in progress
- [ ] Add custom field: User status
- [ ] Add custom field: User role
- [ ] Show number of votes per entry