Skip to content

Commit 1d20760

Browse files
authored
Feat: Clean Archicture & Appwrite SSR (#18)
* feat: added docker file and docker compose * chore: upgraded packages * feat: added service worker * feat: refactored * feat: added customer routes * Changed README
1 parent 18c0fb9 commit 1d20760

File tree

401 files changed

+5275
-5822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

401 files changed

+5275
-5822
lines changed

.env.example

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
## Application Envs
2-
PUBLIC_APPWRITE_ENDPOINT="http://localhost/"
3-
PUBLIC_APPWRITE_API_VERSION="v1"
4-
PUBLIC_APPWRITE_PROJECT_ID="your-project-id"
5-
PUBLIC_SELECTED_PLATFORM="appwrite"
6-
PUBLIC_DEBUG=
7-
81
## AppWrite CLI Bash Related ENV
92
APPWRITE_SELF_SIGNED=true
103
APPWRITE_SET_ENDPOINT=true
11-
APPWRITE_CLI_ENDPOINT=https://cloud.appwrite.io/v1
4+
APPWRITE_CLI_ENDPOINT=http://localhost/v1
5+
6+
7+
## CORE
8+
VITE_MAINTENANCE=false
9+
VITE_ENVIRONMENT=development
10+
11+
## APPWRITE DEV
12+
VITE_APPWRITE_ENDPOINT=http://localhost/v1
13+
VITE_APPWRITE_PROJECT_ID=your-project-id
14+
VITE_APPWRITE_BUCKET_ID=dev
15+
PUBLIC_APPWRITE_HOSTNAME=localhost
16+
PUBLIC_APPWRITE_SSRHOSTNAME=localhost
17+
18+
## APPWRITE PROD
19+
VITE_APPWRITE_ENDPOINT_PROD=https://your-url/v1
20+
VITE_APPWRITE_PROJECT_ID_PROD=your-project-id
21+
VITE_APPWRITE_BUCKET_ID_PROD=
22+
PUBLIC_APPWRITE_HOSTNAME_PROD=your-domain
23+
PUBLIC_APPWRITE_SSRHOSTNAME_PROD=your-domain
24+
25+
### STRIPE
26+
VITE_STRIPE_SECRET_KEY="as"
27+
VITE_STRIPE_PUBLIC_KEY="ad"
28+
29+
### Security
30+
VITE_SECRET_SALT_KEY=your-random-secure-key

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM node:18-alpine
2+
3+
## ENV VARS
4+
## CORE
5+
ARG VITE_ENVIRONMENT
6+
ENV VITE_ENVIRONMENT=${VITE_ENVIRONMENT}
7+
ARG VITE_MAINTENANCE
8+
ENV VITE_MAINTENANCE=${VITE_MAINTENANCE}
9+
## APPWRITE DEV
10+
ARG VITE_APPWRITE_ENDPOINT
11+
ENV VITE_APPWRITE_ENDPOINT=${VITE_APPWRITE_ENDPOINT}
12+
ARG VITE_APPWRITE_PROJECT_ID
13+
ENV VITE_APPWRITE_PROJECT_ID=${VITE_APPWRITE_PROJECT_ID}
14+
## APPWRITE PROD
15+
ARG VITE_APPWRITE_ENDPOINT_PROD
16+
ENV VITE_APPWRITE_ENDPOINT_PROD=${VITE_APPWRITE_ENDPOINT_PROD}
17+
ARG VITE_APPWRITE_PROJECT_ID_PROD
18+
ENV VITE_APPWRITE_PROJECT_ID_PROD=${VITE_APPWRITE_PROJECT_ID_PROD}
19+
### STRIPE
20+
ARG VITE_STRIPE_SECRET_KEY
21+
ENV VITE_STRIPE_SECRET_KEY=${VITE_STRIPE_SECRET_KEY}
22+
ARG VITE_STRIPE_PUBLIC_KEY
23+
ENV VITE_STRIPE_PUBLIC_KEY=${VITE_STRIPE_PUBLIC_KEY}
24+
25+
WORKDIR /app
26+
27+
COPY package.json ./
28+
29+
RUN npm install -g pnpm vite
30+
31+
COPY . .
32+
33+
RUN pnpm install
34+
RUN pnpm build
35+
36+
FROM node:18-alpine
37+
38+
WORKDIR /app
39+
40+
COPY --from=0 /app/package*.json ./
41+
42+
#RUN pnpm install --production --ignore-scripts
43+
#RUN pnpm audit fix
44+
45+
COPY --from=0 /app ./
46+
47+
EXPOSE 3000
48+
49+
CMD ["node", "build"]

Dockerfile.dev

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM node:18-alpine
2+
3+
## ENV VARS
4+
## CORE
5+
ARG VITE_ENVIRONMENT
6+
ENV VITE_ENVIRONMENT=${VITE_ENVIRONMENT}
7+
ARG VITE_MAINTENANCE
8+
ENV VITE_MAINTENANCE=${VITE_MAINTENANCE}
9+
## APPWRITE DEV
10+
ARG VITE_APPWRITE_ENDPOINT
11+
ENV VITE_APPWRITE_ENDPOINT=${VITE_APPWRITE_ENDPOINT}
12+
ARG VITE_APPWRITE_PROJECT_ID
13+
ENV VITE_APPWRITE_PROJECT_ID=${VITE_APPWRITE_PROJECT_ID}
14+
## APPWRITE PROD
15+
ARG VITE_APPWRITE_ENDPOINT_PROD
16+
ENV VITE_APPWRITE_ENDPOINT_PROD=${VITE_APPWRITE_ENDPOINT_PROD}
17+
ARG VITE_APPWRITE_PROJECT_ID_PROD
18+
ENV VITE_APPWRITE_PROJECT_ID_PROD=${VITE_APPWRITE_PROJECT_ID_PROD}
19+
### STRIPE
20+
ARG VITE_STRIPE_SECRET_KEY
21+
ENV VITE_STRIPE_SECRET_KEY=${VITE_STRIPE_SECRET_KEY}
22+
ARG VITE_STRIPE_PUBLIC_KEY
23+
ENV VITE_STRIPE_PUBLIC_KEY=${VITE_STRIPE_PUBLIC_KEY}
24+
25+
WORKDIR /app
26+
27+
COPY package.json ./
28+
29+
RUN npm install -g pnpm vite
30+
31+
COPY . .
32+
33+
RUN pnpm install
34+
RUN pnpm build
35+
36+
FROM node:18-alpine
37+
38+
WORKDIR /app
39+
40+
COPY --from=0 /app/package*.json ./
41+
42+
#RUN pnpm install --production --ignore-scripts
43+
#RUN pnpm audit fix
44+
45+
COPY --from=0 /app ./
46+
47+
EXPOSE 3000
48+
49+
CMD ["node", "build"]

README.md

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# SvelteKit Appwrite BackOffice Template
2-
32
Everything you need to build an Administration Panel Using Svelte/SvelteKit and AppWrite
43

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

3433
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
3534

36-
## Events
37-
To use the events handler simple follow:
38-
39-
```bash
40-
# import event list
41-
import EVENTS from $lib/common/constants/events
42-
# import dispatchEvent
43-
import dispatchEvent from $lib/common/events/event-bus
44-
45-
# have some payload ready to send
46-
const payload = {
47-
name: 'demo',
48-
notifications: {
49-
email: true,
50-
sms: true
51-
}
52-
}
53-
54-
# use the function on the component that you want to trigger the event,
55-
<button on:click={() => dispatchEvent(EVENTS.UPDATE_PROFILE, payload)} >hi</button>
56-
57-
# Add as many more handlers and events as need it
58-
59-
```
6035

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

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

8651
## Tech Stack
87-
8852
- SvelteKit
8953
- Svelte
9054
- TailwindCSS

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3.8'
2+
services:
3+
dev:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.dev
7+
ports:
8+
- '5173:5173'
9+
volumes:
10+
- .:/code
11+
- /code/node_modules
12+
env_file:
13+
- .env
14+
container_name: dev-app
15+
command: pnpm run dev --host 0.0.0.0 --port 5173
16+
networks:
17+
- app-network
18+
19+
prod:
20+
build:
21+
context: .
22+
dockerfile: Dockerfile
23+
ports:
24+
- '3000:3000'
25+
env_file:
26+
- .env
27+
container_name: prod-app
28+
command: node build
29+
networks:
30+
- app-network
31+
32+
networks:
33+
app-network:

package.json

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,48 @@
1515
"test:unit": "vitest"
1616
},
1717
"devDependencies": {
18-
"@playwright/test": "^1.39.0",
19-
"@sveltejs/adapter-auto": "^2.1.0",
20-
"@sveltejs/kit": "^1.26.0",
21-
"@tailwindcss/forms": "^0.5.6",
18+
"@playwright/test": "^1.40.1",
19+
"@sveltejs/adapter-auto": "^2.1.1",
20+
"@sveltejs/kit": "^1.30.3",
21+
"@tailwindcss/forms": "^0.5.7",
2222
"@tailwindcss/typography": "^0.5.10",
23-
"@types/d3-scale": "^4.0.6",
24-
"@types/set-cookie-parser": "^2.4.5",
25-
"@typescript-eslint/eslint-plugin": "^6.8.0",
26-
"@typescript-eslint/parser": "^6.8.0",
27-
"autoprefixer": "^10.4.14",
28-
"eslint": "^8.52.0",
23+
"@types/cookie": "^0.6.0",
24+
"@types/d3-scale": "^4.0.8",
25+
"@types/set-cookie-parser": "^2.4.7",
26+
"@typescript-eslint/eslint-plugin": "^6.15.0",
27+
"@typescript-eslint/parser": "^6.15.0",
28+
"autoprefixer": "^10.4.16",
29+
"eslint": "^8.56.0",
2930
"eslint-config-prettier": "^8.10.0",
30-
"eslint-plugin-svelte": "^2.34.0",
31-
"postcss": "^8.4.24",
32-
"postcss-load-config": "^4.0.1",
31+
"eslint-plugin-svelte": "^2.35.1",
32+
"postcss": "^8.4.32",
33+
"postcss-load-config": "^4.0.2",
3334
"prettier": "^2.8.8",
3435
"prettier-plugin-svelte": "^2.10.1",
35-
"svelte": "^4.2.2",
36-
"svelte-check": "^3.5.2",
37-
"tailwindcss": "^3.3.2",
36+
"svelte": "^4.2.8",
37+
"svelte-check": "^3.6.2",
38+
"tailwindcss": "^3.4.0",
3839
"tslib": "^2.6.2",
39-
"typescript": "^5.2.2",
40-
"vite": "^4.5.0",
40+
"typescript": "^5.3.3",
41+
"vite": "^4.5.1",
4142
"vitest": "^0.32.4"
4243
},
4344
"type": "module",
4445
"dependencies": {
45-
"@unovis/svelte": "^1.2.2",
46-
"appwrite": "^13.0.0",
47-
"bits-ui": "^0.6.2",
46+
"@unovis/svelte": "^1.3.1",
47+
"appwrite": "^13.0.1",
48+
"bits-ui": "^0.6.3",
4849
"clsx": "^2.0.0",
50+
"cookie": "^0.6.0",
4951
"d3-scale": "^4.0.2",
50-
"formsnap": "^0.2.0",
52+
"formsnap": "^0.2.1",
5153
"lucide-svelte": "^0.288.0",
52-
"node-appwrite": "^11.0.0",
54+
"node-appwrite": "^11.1.0",
5355
"radix-icons-svelte": "^1.2.1",
5456
"set-cookie-parser": "^2.6.0",
55-
"sveltekit-superforms": "^1.8.0",
57+
"sveltekit-superforms": "^1.13.1",
5658
"tailwind-merge": "^1.14.0",
57-
"tailwind-variants": "^0.1.14",
59+
"tailwind-variants": "^0.1.19",
5860
"zod": "^3.22.4"
5961
}
6062
}

0 commit comments

Comments
 (0)