Skip to content

Commit a6cc878

Browse files
committed
Added v2 structure
1 parent 99140d1 commit a6cc878

File tree

135 files changed

+22958
-0
lines changed

Some content is hidden

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

135 files changed

+22958
-0
lines changed

.github/workflows/main.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: JS - Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deployment:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 120
12+
steps:
13+
- name: Execute remote SSH commands
14+
uses: appleboy/ssh-action@master
15+
timeout-minutes: 120
16+
with:
17+
host: ${{ secrets.HOST }}
18+
username: ${{ secrets.USER }}
19+
password: ${{ secrets.PASS }}
20+
port: ${{ secrets.PORT }}
21+
timeout: 120m
22+
command_timeout: 120m
23+
script: |
24+
cd ~/api-server-nestjs
25+
git fetch origin main
26+
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]; then
27+
git pull origin main
28+
export DOCKER_BUILDKIT=1
29+
docker compose up -d --build --no-deps --pull always && docker system prune -af
30+
else
31+
echo "No changes detected, skipping deployment."
32+
fi

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Change Log
2+
3+
## [0.0.2] 2024-12-15
4+
### Changes
5+
6+
- Added Backend
7+
- Added React UI (Mantis Design)
8+
9+
## [0.0.1] 2024-11-11
10+
### Changes
11+
12+
- REPO Created
13+
- Specs Added (RM)

README.md

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Django API Server
2+
3+
Open-Source API server powered by [Django](https://app-generator.dev/docs/technologies/django/index.html), a progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
4+
5+
> Status: **Work in progress**
6+
7+
- 👉 [Django API Server](#) - **Complete Documentation**
8+
- 👉 [Get Support](https://app-generator.dev/ticket/create/) via Email and Discord
9+
10+
<br />
11+
12+
## Features
13+
14+
- **Best Practices**: Follows industry-standard best practices for building robust APIs.
15+
- **Backend**: Built with Django, a powerful and scalable Node.js framework.
16+
- **UI**:
17+
- React Mantis (optional frontend integration).
18+
19+
<br />
20+
21+
## Backend API
22+
23+
- **Simple, modular & intuitive structure**: Easy to understand and extend.
24+
- **Toolchain**:
25+
- Usable with the latest Node.js LTS versions:
26+
- v22.x
27+
- v21.x
28+
- v20.x
29+
- Package Managers:
30+
- PNPM,
31+
- Yarn,
32+
- Npm
33+
- **Authentication**: Auth0 for GitHub integration.
34+
- GitHub email pulled during OAuth SignIN.
35+
- Optional: Email validation.
36+
- **Roles**: Admin, Users.
37+
- **ORM**: Prisma for database management.
38+
- **User Profiles**:
39+
- ROLE: Default user.
40+
- Fields: Name, surname, bio, country, address, job.
41+
- **API Features**:
42+
- Search, Pagination.
43+
- Public Access: GET by ID, get all.
44+
- Private access (requires token):
45+
- Create, Update, Delete.
46+
- **Admin**:
47+
- Can search or mutate any user.
48+
- **Users**:
49+
- Can view and mutate only their own information.
50+
51+
## Start with Docker
52+
53+
@Todo
54+
55+
## Start Django Backend
56+
57+
> Edit Environment
58+
59+
Add a `.env` file to your project root directory and populate as follows:
60+
61+
```env
62+
AUTH0_DOMAIN=YOUR_AUTH0_DOMAIN
63+
AUTH0_CLIENT_ID=YOUR_AUTH0_CLIENT_ID
64+
AUTH0_CLIENT_SECRET=YOUR_AUTH0_CLIENT_SECRET
65+
66+
JWT_SECRET=YOUR_JWT_SECRET
67+
68+
DATABASE_URL=YOUR_DATABASE_URL
69+
```
70+
71+
Here's how to get the required Auth0 details. You need to register a client (application) in your Auth0 dashboard.
72+
73+
Follow these steps to register a client with Auth0:
74+
75+
1. Open the [Auth0 Applications](https://manage.auth0.com/?_gl=1*1a4zekg*_ga*Mjg3MzE5NzcyLjE3MzcwMjU4MzA.*_ga_QKMSDV5369*MTczNzIwMTkzNy45LjEuMTczNzIwMTk1Ni40MS4wLjA.#/applications) section of the Auth0 Dashboard.
76+
2. Click on the **Create Application** button.
77+
3. Provide a **Name**, such as "GitHub Auth".
78+
4. Choose `Single Page Web Applications` as the application type.
79+
5. Click on the **Create** button.
80+
6. Finally, note down your `Domain`, `Client ID`, and `Client Secret` and add them to your `.env` file. Click the settings tab if you do not see them.
81+
82+
Choose a random string of letters and numbers for your `JWT_SECRET` and populate the `DATABASE_URL` with your database connection string.
83+
84+
> Install Dependencies
85+
86+
Run the following to install dependencies:
87+
88+
```bash
89+
npm install
90+
```
91+
92+
OR
93+
94+
```bash
95+
yarn
96+
```
97+
98+
> Set Up Prisma
99+
100+
1. Run the following command to generate the Prisma client and apply migrations:
101+
102+
```bash
103+
npx prisma generate
104+
npx prisma migrate dev --name init
105+
```
106+
107+
2. If you need to seed your database, you can add a `seed` script in the `prisma/seed.ts` file and run:
108+
109+
```bash
110+
npx prisma db seed
111+
```
112+
113+
> Run Your Server
114+
115+
Start the Django server with:
116+
117+
```bash
118+
npm run start:dev
119+
```
120+
121+
OR
122+
123+
```bash
124+
yarn start:dev
125+
```
126+
127+
## Compile [React UI](https://github.com/codedthemes/mantis-free-react-admin-template)
128+
129+
> Edit Environment
130+
131+
Add your server base URL to your environment variables as follows:
132+
133+
```env
134+
VITE_APP_PUBLIC_URL=<YOUR_SERVER_URL>
135+
```
136+
137+
> Install Dependencies
138+
139+
```bash
140+
npm install
141+
```
142+
143+
OR
144+
145+
```bash
146+
yarn
147+
```
148+
149+
> Start the React UI
150+
151+
```bash
152+
npm run dev
153+
```
154+
155+
OR
156+
157+
```bash
158+
yarn dev
159+
```
160+
161+
---
162+
Django API Starter provided by [App Generator](https://app-generator.dev/) - Open-source service for developers and companies.

backend/.gitkeep

Whitespace-only changes.

docker-compose.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
services:
2+
backend:
3+
build: ./backend
4+
container_name: backend
5+
ports:
6+
- "3000:3000"
7+
env_file:
8+
- ./backend/.env
9+
command: >
10+
sh -c "
11+
npx prisma generate
12+
npx prisma migrate deploy
13+
yarn start:dev
14+
"
15+
networks:
16+
- app-network
17+
18+
frontend:
19+
build: ./ui-mantis
20+
container_name: frontend
21+
ports:
22+
- "4000:4000"
23+
env_file:
24+
- ./ui-mantis/.env
25+
networks:
26+
- app-network
27+
depends_on:
28+
- backend
29+
30+
# nginx:
31+
# image: nginx:alpine
32+
# container_name: nginx
33+
# ports:
34+
# - "80:80"
35+
# volumes:
36+
# - ./nginx/nginx.conf:/etc/nginx/nginx.conf
37+
# depends_on:
38+
# - backend
39+
# - frontend
40+
# networks:
41+
# - app-network
42+
43+
networks:
44+
app-network:
45+
driver: bridge

nginx/nginx.conf

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
events {}
2+
3+
http {
4+
upstream backend {
5+
server backend:3000;
6+
}
7+
8+
upstream frontend {
9+
server frontend:4000;
10+
}
11+
12+
server {
13+
listen 80;
14+
15+
location /api/ {
16+
proxy_pass http://backend;
17+
proxy_set_header Host $host;
18+
proxy_set_header X-Real-IP $remote_addr;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
proxy_set_header X-Forwarded-Proto $scheme;
21+
}
22+
23+
location / {
24+
proxy_pass http://frontend;
25+
proxy_set_header Host $host;
26+
proxy_set_header X-Real-IP $remote_addr;
27+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28+
proxy_set_header X-Forwarded-Proto $scheme;
29+
}
30+
}
31+
}

ui-mantis/.env

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
VITE_APP_VERSION=v1.3.0
2+
GENERATE_SOURCEMAP=false
3+
4+
## Backend API URL
5+
VITE_APP_PUBLIC_URL = http://0.0.0.0:4000
6+
VITE_APP_BASE_NAME = /free

ui-mantis/.eslintrc

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es2021": true
6+
},
7+
"extends": [
8+
"prettier",
9+
"plugin:react/jsx-runtime",
10+
"plugin:jsx-a11y/recommended",
11+
"plugin:react-hooks/recommended",
12+
"eslint:recommended",
13+
"plugin:react/recommended"
14+
],
15+
"settings": {
16+
"react": {
17+
"createClass": "createReactClass", // Regex for Component Factory to use,
18+
// default to "createReactClass"
19+
"pragma": "React", // Pragma to use, default to "React"
20+
"fragment": "Fragment", // Fragment to use (may be a property of <pragma>), default to "Fragment"
21+
"version": "detect", // React version. "detect" automatically picks the version you have installed.
22+
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
23+
// It will default to "latest" and warn if missing, and to "detect" in the future
24+
"flowVersion": "0.53" // Flow version
25+
},
26+
"import/resolver": {
27+
"node": {
28+
"moduleDirectory": ["node_modules", "src/"]
29+
}
30+
}
31+
},
32+
"parser": "@babel/eslint-parser",
33+
"parserOptions": {
34+
"ecmaFeatures": {
35+
"experimentalObjectRestSpread": true,
36+
"impliedStrict": true,
37+
"jsx": true
38+
},
39+
"ecmaVersion": 12
40+
},
41+
"plugins": ["prettier", "react", "react-hooks"],
42+
"rules": {
43+
"react/jsx-uses-react": "error",
44+
"react/jsx-uses-vars": "error",
45+
"react/react-in-jsx-scope": "off",
46+
"no-undef": "off",
47+
"react/display-name": "off",
48+
"react/jsx-filename-extension": "off",
49+
"no-param-reassign": "off",
50+
"react/prop-types": 1,
51+
"react/require-default-props": "off",
52+
"react/no-array-index-key": "off",
53+
"react/jsx-props-no-spreading": "off",
54+
"react/forbid-prop-types": "off",
55+
"import/order": "off",
56+
"import/no-cycle": "off",
57+
"no-console": "off",
58+
"jsx-a11y/anchor-is-valid": "off",
59+
"prefer-destructuring": "off",
60+
"no-shadow": "off",
61+
"import/no-named-as-default": "off",
62+
"import/no-extraneous-dependencies": "off",
63+
"jsx-a11y/no-autofocus": "off",
64+
"no-restricted-imports": [
65+
"error",
66+
{
67+
"patterns": ["@mui/*/*/*", "!@mui/material/test-utils/*"]
68+
}
69+
],
70+
"no-unused-vars": [
71+
"error",
72+
{
73+
"ignoreRestSiblings": false
74+
}
75+
],
76+
"prettier/prettier": [
77+
"warn",
78+
{
79+
"bracketSpacing": true,
80+
"printWidth": 140,
81+
"singleQuote": true,
82+
"trailingComma": "none",
83+
"tabWidth": 2,
84+
"useTabs": false,
85+
"endOfLine": "auto"
86+
}
87+
]
88+
}
89+
}

0 commit comments

Comments
 (0)