-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart.md
More file actions
273 lines (185 loc) · 6.29 KB
/
start.md
File metadata and controls
273 lines (185 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# Start
Let's get started.
## Project Structure
The main structure of the project is mostly like this:
```sh
├── apps/
│ ├── web/
│ └── api/
├── packages/
│ ├── config/
│ ├── database/
│ ├── ui/
│ └── utils/
├── docs/
├── docker-compose.yml
└── README.md
```
The possiblity of the project structure is endless.
```sh
├── apps/
│ ├── web/
│ ├── admin/
│ ├── graphql/
│ └── rest-api/
```
## Prerequisites
### moon & proto
Install [proto](https://moonrepo.dev/proto) for toolchain versioning:
```sh
curl -fsSL https://moonrepo.dev/install/proto.sh | bash
```
Install [moonrepo](https://moonrepo.dev) for monorepo project management:
```sh
curl -fsSL https://moonrepo.dev/install/moon.sh | bash
# or
proto plugin add moon "https://raw.githubusercontent.com/moonrepo/moon/master/proto-plugin.toml"
proto install moon
```
> Note: moon & proto are not required for the project to run, but they are recommended for efficient project management and toolchain versioning.
### Bun
Use [Bun](https://bun.sh), a fast JavaScript all-in-one toolkit that replace Node.js and npm/yarn/pnpm.
[Install Bun](https://bun.sh/docs/installation) with either methods:
```sh
curl -fsSL https://bun.sh/install | bash
npm i -g bun
brew install oven-sh/bun/bun
proto install bun
```
### Docker
Use [Docker](https://docker.com) for setting up the container, especially for the database.
Install Docker with either methods:
- [OrbStack](https://orbstack.dev) on macOS.
- [Docker Desktop](https://docker.com/products/docker-desktop) or [Podman](https://podman.io) on anywhere else.
## Clone repo
```sh
bunx degit dogokit/dogokit-akita
```
or
```sh
git clone --depth 1 https://github.com/dogokit/dogokit-akita.git <your-project-name>
```
## Install Dependencies
To run the app locally, make sure the project's local packages/dependencies are installed:
```sh
bun install
```
## Check and Fix Code Quality
Log, format, lint to check if the setup is fine:
```sh
bun check
# env typecheck prettier eslint stylelint
```
```sh
bun fix
# prettier eslint stylelint
```
> Note: Can ignore non-critical warning from ESLint and TypeScript
## Setup Environment Variables
Create the `.env.local` file from `.env.example`. This is the one for local development, not production
```sh
cp -i .env.example .env.local
```
Configure the required environment variables if on local, otherwise in the project settings on other environments.
If necessary, create the `.env.production` for production access. Adjust accordingly if need for `staging`, `test`, etc. Be careful to change the `APP_MAIN_URL` on different domains and subdomains.
```sh
cp -i .env.example .env.production
```
Or run the script:
```sh
make setup-env
# cp -i .env.example .env.local
# cp -i .env.example .env.production
```
Client/Frontend/Application:
- `MAIN_CLIENT_URL`: For example, `http://localhost:3000`
- `ADMIN_CLIENT_URL` is also possible
Server/Backend/API:
- `MAIN_SERVER_URL`: For example, `http://localhost:4000`
Database:
- `DATABASE_URL`: For example, `postgres://user:password@localhost:5432/dogokit-akita`. Continue to read the Database Setup.
Auth:
- `SESSION_SECRET`: For example, `the_secret_text`. Anything goes, but better to generate a random string using `openssl rand -base64 32` on the terminal or put any long random text.
OAuth:
- `*_CLIENT_ID`
- `*_CLIENT_SECRET`
[Check the OAuth Guide](oauth.md)
## Database Setup
Drizzle ORM is used to communicate with the database easily. Can replace with query builder such as Kysely if needed or even raw database query.
For the database system itself, either choose to use PostgreSQL or MySQL from local system, Docker container, or hosted services.
If prefer using Docker and Docker Compose for local development, [check the database guide](database.md).
The app is configured primarily to be deployed using PlanetScale. Because of that, the migration files are not needed. Therefore, push the schema directly there. The migration process will be handled through its [deploy requests](https://planetscale.com/docs/concepts/deploy-requests).
### PostgresQL Database
To start quickly, create a PostgresQL database with either of these:
- Vercel Postgres
- Supabase
- Neon.tech
- Xata.io
### Database Operations
Sync between Drizzle schema and the database directly:
```sh
bun db:push
# drizzle-kit push
```
> Note: Only need to push the schema in development. No need for migration files.
Create `users.ts` in the `credentials` folder with the format below. Can focus on certain users who want to be able to access in development, so it doesn't have to be everyone.
```ts
export const dataUsers = [
{
username: "example",
fullname: "Example User",
nickname: "Sample",
email: "example@example.com",
password: "exampleexample",
roleSymbol: "ROOT",
},
];
```
Then seed the initial data when needed:
```sh
bun db:seed
```
## Build
Check if the build is fine. This als be used to build the app for production.
```sh
bun build
```
Then try to run the app in production mode:
```sh
bun start
```
Then pick a host to deploy it to, such as:
- Vercel
- Netlify
- Fly.io
- Render.com
- Railway.app
- Google Cloud
- Amazon Web Services
- Microsoft Azure
## Development
Finally, develop the app while running the development server:
```sh
bun dev
```
## Change the Contents
- Arrange and remove components as needed.
- Find and replace various texts, especially the word "Dogokit" and "Dogokit Akita".
## Change Theme Colors
Use [`kiliman/shadcn-custom-theme`](https://github.com/kiliman/shadcn-custom-theme) to generate shadcn/ui CSS variables with Tailwind CSS colors.
For example:
```sh
bunx shadcn-custom-theme primary=indigo secondary=blue accent=violet gray=neutral
```
## Setup some services
- Image upload with [Uploadcare](https://uploadcare.com)
- `UPLOADCARE_PUBLIC_KEY`, `UPLOADCARE_SECRET_KEY`
- Transactional email with [Resend](https://resend.com)
- `RESEND_API_KEY`
- Product analytics with [Posthog](https://posthog.com)
- `POSTHOG_KEY`
## Subscribe for the status of the services
- [Vercel Status](https://vercel-status.com)
- [PlanetScale Status](https://planetscalestatus.com)
- [Uploadcare Status](https://status.uploadcare.com)
- [Resend Status](https://resend-status.com)