Skip to content

Commit

Permalink
Feat: Clean Archicture & Appwrite SSR (#18)
Browse files Browse the repository at this point in the history
* feat: added docker file and docker compose

* chore: upgraded packages

* feat: added service worker

* feat: refactored

* feat: added customer routes

* Changed README
  • Loading branch information
acidlake committed Dec 23, 2023
1 parent 18c0fb9 commit 1d20760
Show file tree
Hide file tree
Showing 401 changed files with 5,275 additions and 5,822 deletions.
35 changes: 27 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
## Application Envs
PUBLIC_APPWRITE_ENDPOINT="http://localhost/"
PUBLIC_APPWRITE_API_VERSION="v1"
PUBLIC_APPWRITE_PROJECT_ID="your-project-id"
PUBLIC_SELECTED_PLATFORM="appwrite"
PUBLIC_DEBUG=

## AppWrite CLI Bash Related ENV
APPWRITE_SELF_SIGNED=true
APPWRITE_SET_ENDPOINT=true
APPWRITE_CLI_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_CLI_ENDPOINT=http://localhost/v1


## CORE
VITE_MAINTENANCE=false
VITE_ENVIRONMENT=development

## APPWRITE DEV
VITE_APPWRITE_ENDPOINT=http://localhost/v1
VITE_APPWRITE_PROJECT_ID=your-project-id
VITE_APPWRITE_BUCKET_ID=dev
PUBLIC_APPWRITE_HOSTNAME=localhost
PUBLIC_APPWRITE_SSRHOSTNAME=localhost

## APPWRITE PROD
VITE_APPWRITE_ENDPOINT_PROD=https://your-url/v1
VITE_APPWRITE_PROJECT_ID_PROD=your-project-id
VITE_APPWRITE_BUCKET_ID_PROD=
PUBLIC_APPWRITE_HOSTNAME_PROD=your-domain
PUBLIC_APPWRITE_SSRHOSTNAME_PROD=your-domain

### STRIPE
VITE_STRIPE_SECRET_KEY="as"
VITE_STRIPE_PUBLIC_KEY="ad"

### Security
VITE_SECRET_SALT_KEY=your-random-secure-key
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM node:18-alpine

## ENV VARS
## CORE
ARG VITE_ENVIRONMENT
ENV VITE_ENVIRONMENT=${VITE_ENVIRONMENT}
ARG VITE_MAINTENANCE
ENV VITE_MAINTENANCE=${VITE_MAINTENANCE}
## APPWRITE DEV
ARG VITE_APPWRITE_ENDPOINT
ENV VITE_APPWRITE_ENDPOINT=${VITE_APPWRITE_ENDPOINT}
ARG VITE_APPWRITE_PROJECT_ID
ENV VITE_APPWRITE_PROJECT_ID=${VITE_APPWRITE_PROJECT_ID}
## APPWRITE PROD
ARG VITE_APPWRITE_ENDPOINT_PROD
ENV VITE_APPWRITE_ENDPOINT_PROD=${VITE_APPWRITE_ENDPOINT_PROD}
ARG VITE_APPWRITE_PROJECT_ID_PROD
ENV VITE_APPWRITE_PROJECT_ID_PROD=${VITE_APPWRITE_PROJECT_ID_PROD}
### STRIPE
ARG VITE_STRIPE_SECRET_KEY
ENV VITE_STRIPE_SECRET_KEY=${VITE_STRIPE_SECRET_KEY}
ARG VITE_STRIPE_PUBLIC_KEY
ENV VITE_STRIPE_PUBLIC_KEY=${VITE_STRIPE_PUBLIC_KEY}

WORKDIR /app

COPY package.json ./

RUN npm install -g pnpm vite

COPY . .

RUN pnpm install
RUN pnpm build

FROM node:18-alpine

WORKDIR /app

COPY --from=0 /app/package*.json ./

#RUN pnpm install --production --ignore-scripts
#RUN pnpm audit fix

COPY --from=0 /app ./

EXPOSE 3000

CMD ["node", "build"]
49 changes: 49 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM node:18-alpine

## ENV VARS
## CORE
ARG VITE_ENVIRONMENT
ENV VITE_ENVIRONMENT=${VITE_ENVIRONMENT}
ARG VITE_MAINTENANCE
ENV VITE_MAINTENANCE=${VITE_MAINTENANCE}
## APPWRITE DEV
ARG VITE_APPWRITE_ENDPOINT
ENV VITE_APPWRITE_ENDPOINT=${VITE_APPWRITE_ENDPOINT}
ARG VITE_APPWRITE_PROJECT_ID
ENV VITE_APPWRITE_PROJECT_ID=${VITE_APPWRITE_PROJECT_ID}
## APPWRITE PROD
ARG VITE_APPWRITE_ENDPOINT_PROD
ENV VITE_APPWRITE_ENDPOINT_PROD=${VITE_APPWRITE_ENDPOINT_PROD}
ARG VITE_APPWRITE_PROJECT_ID_PROD
ENV VITE_APPWRITE_PROJECT_ID_PROD=${VITE_APPWRITE_PROJECT_ID_PROD}
### STRIPE
ARG VITE_STRIPE_SECRET_KEY
ENV VITE_STRIPE_SECRET_KEY=${VITE_STRIPE_SECRET_KEY}
ARG VITE_STRIPE_PUBLIC_KEY
ENV VITE_STRIPE_PUBLIC_KEY=${VITE_STRIPE_PUBLIC_KEY}

WORKDIR /app

COPY package.json ./

RUN npm install -g pnpm vite

COPY . .

RUN pnpm install
RUN pnpm build

FROM node:18-alpine

WORKDIR /app

COPY --from=0 /app/package*.json ./

#RUN pnpm install --production --ignore-scripts
#RUN pnpm audit fix

COPY --from=0 /app ./

EXPOSE 3000

CMD ["node", "build"]
48 changes: 6 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# SvelteKit Appwrite BackOffice Template

Everything you need to build an Administration Panel Using Svelte/SvelteKit and AppWrite

## Screenshots
Expand Down Expand Up @@ -33,30 +32,6 @@ There's an appwrite folder in the root of the project, it contains the base func

there's also a bash script that can be run with ./login_appwrite.sh, it will promp to login to appwrite instance that you spesify in the .env, see .env.example

## Events
To use the events handler simple follow:

```bash
# import event list
import EVENTS from $lib/common/constants/events
# import dispatchEvent
import dispatchEvent from $lib/common/events/event-bus

# have some payload ready to send
const payload = {
name: 'demo',
notifications: {
email: true,
sms: true
}
}

# use the function on the component that you want to trigger the event,
<button on:click={() => dispatchEvent(EVENTS.UPDATE_PROFILE, payload)} >hi</button>

# Add as many more handlers and events as need it

```

## Folder Structure
The project is well organized into the following folder structure, and use route grouping.
Expand All @@ -66,25 +41,14 @@ The project is well organized into the following folder structure, and use route
- (backoffice) Here you will find the admin panel ( Protected route )

### Lib
- common
- - constants All application constants are here, images, sizes, enums, colors, api_constants.
- - formatters Formatter utility class to format numbers into currency, format date etc.
- - local_storage Local Storage utility class
- - logger Logger utility class
- - utils Multiple helpers functions
- - validators Validator utility class for email, phone etc
- data Mock/Fake data
- features Here is where we will put the features for the application
- - authentication
- - dashboard
- localization Language files and localization utility class
- stores All application stores are going to be here
- ui All UI related to the application is going to be here
- - components Here is the component library
- - widgets this are a collection of common ui widgets that combine ui components into functional widgets
- app Here you will find your common app, config, constants, stores, utils, types, ui components and ui common widgets
- data-access Here you will find your DTO's and Data Definitions
- entities Here you will find your entites that are in your database
- features Here you will find your application features
- infraestructure Here you will find your Depdency Injection container, and everything related to infraestructure ( AppWrite interface )
- use-cases Here you will find your Application Use Cases (Business Logic / Controllers)

## Tech Stack

- SvelteKit
- Svelte
- TailwindCSS
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.8'
services:
dev:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- '5173:5173'
volumes:
- .:/code
- /code/node_modules
env_file:
- .env
container_name: dev-app
command: pnpm run dev --host 0.0.0.0 --port 5173
networks:
- app-network

prod:
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
env_file:
- .env
container_name: prod-app
command: node build
networks:
- app-network

networks:
app-network:
52 changes: 27 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,48 @@
"test:unit": "vitest"
},
"devDependencies": {
"@playwright/test": "^1.39.0",
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/kit": "^1.26.0",
"@tailwindcss/forms": "^0.5.6",
"@playwright/test": "^1.40.1",
"@sveltejs/adapter-auto": "^2.1.1",
"@sveltejs/kit": "^1.30.3",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@types/d3-scale": "^4.0.6",
"@types/set-cookie-parser": "^2.4.5",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"autoprefixer": "^10.4.14",
"eslint": "^8.52.0",
"@types/cookie": "^0.6.0",
"@types/d3-scale": "^4.0.8",
"@types/set-cookie-parser": "^2.4.7",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"autoprefixer": "^10.4.16",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-svelte": "^2.34.0",
"postcss": "^8.4.24",
"postcss-load-config": "^4.0.1",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.32",
"postcss-load-config": "^4.0.2",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^4.2.2",
"svelte-check": "^3.5.2",
"tailwindcss": "^3.3.2",
"svelte": "^4.2.8",
"svelte-check": "^3.6.2",
"tailwindcss": "^3.4.0",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"typescript": "^5.3.3",
"vite": "^4.5.1",
"vitest": "^0.32.4"
},
"type": "module",
"dependencies": {
"@unovis/svelte": "^1.2.2",
"appwrite": "^13.0.0",
"bits-ui": "^0.6.2",
"@unovis/svelte": "^1.3.1",
"appwrite": "^13.0.1",
"bits-ui": "^0.6.3",
"clsx": "^2.0.0",
"cookie": "^0.6.0",
"d3-scale": "^4.0.2",
"formsnap": "^0.2.0",
"formsnap": "^0.2.1",
"lucide-svelte": "^0.288.0",
"node-appwrite": "^11.0.0",
"node-appwrite": "^11.1.0",
"radix-icons-svelte": "^1.2.1",
"set-cookie-parser": "^2.6.0",
"sveltekit-superforms": "^1.8.0",
"sveltekit-superforms": "^1.13.1",
"tailwind-merge": "^1.14.0",
"tailwind-variants": "^0.1.14",
"tailwind-variants": "^0.1.19",
"zod": "^3.22.4"
}
}
Loading

0 comments on commit 1d20760

Please sign in to comment.