Skip to content
This repository was archived by the owner on Apr 17, 2024. It is now read-only.

Commit aa7cbc4

Browse files
authored
Merge pull request #15 from Desunovu/dev
Макет фронтенда
2 parents 6ab93a3 + cd42700 commit aa7cbc4

File tree

83 files changed

+7769
-81
lines changed

Some content is hidden

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

83 files changed

+7769
-81
lines changed

.env.development

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# FASTAPI BACKEND
2+
SECRET_KEY=0000000000000000000000000000000A
3+
LOGGING_LEVEL=DEBUG
4+
MONGODB_URL=mongodb://localhost:27017
5+
MONGODB_DATABASE=blogdatabase
6+
7+
# VITE VUE FRONTEND
8+
VITE_API_URL="localhost:8000"

.env.production

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# FASTAPI BACKEND
2+
SECRET_KEY=
3+
LOGGING_LEVEL=DEBUG
4+
MONGODB_URL=mongodb://mongodb:27017
5+
MONGODB_DATABASE=blogdatabase
6+
7+
# VITE VUE FRONTEND
8+
VITE_API_URL="/api"
9+
10+
## MONGO
11+
#MONGO_INITDB_ROOT_USERNAME:
12+
#MONGO_INITDB_ROOT_PASSWORD:

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
# Python
12
venv/
23
/.idea/
4+
*.pyc
5+
6+
# env
7+
*.env
8+
9+
# Logs
10+
logs
311
*.log
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
pnpm-debug.log*
16+
lerna-debug.log*
17+
18+
node_modules
19+
.DS_Store
20+
dist
21+
dist-ssr
22+
coverage
23+
*.local
24+
25+
/cypress/videos/
26+
/cypress/screenshots/
27+
28+
# Editor directories and files
29+
.vscode/*
30+
!.vscode/extensions.json
31+
.idea
32+
*.suo
33+
*.ntvs*
34+
*.njsproj
35+
*.sln
36+
*.sw?

README.md

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,54 @@
1-
# Blog development using Fast API and MongoDB
1+
# Blog development using Fast API, Vue.js and MongoDB
22

3-
## Description
3+
## Introduction
44

5-
Educational project on developing a blog. The main goal of the project is to utilize a NoSQL database and implement asynchronous CRUD operations.
5+
This project is an educational project for developing a blog using Fast API, Vue.js and MongoDB. The main goal of the project is to demonstrate the use of a NoSQL database and asynchronous CRUD operations.
66

77
## Technology Stack
88

9-
- **Programming Language**: Python
10-
- **Web Framework**: [FastAPI](https://fastapi.tiangolo.com/)
11-
- **Database**: MongoDB (with [Beanie ODM](https://beanie-odm.dev/))
12-
- **Frontend**: _Not selected yet_
13-
- **Honorable mention**: OAuth 2.0 JWT
9+
- **Programming Languages**: Python, TypeScript/JavaScript
10+
- **Backend Web Framework**: [FastAPI](https://fastapi.tiangolo.com/)
11+
- **Database**: MongoDB (used with [Beanie ODM](https://beanie-odm.dev/))
12+
- **Frontend Web Framework**: Vue.js (with [Quasar](https://quasar.dev/), [Pinia](https://pinia.vuejs.org/), [OpenAPI Typescript Codegen](https://github.com/ferdikoomen/openapi-typescript-codegen))
13+
- **Honorable mention**: OAuth 2.0 JWT Bearer Flow, Nginx
1414

1515
## Project Functionality
16+
1. **Registration and Authentication**: Users can register and authenticate using OAuth 2.0 JWT.
17+
2. **Profile Management**: Users can manage their profiles, including changing passwords and updating information. Administrators can also manage users.
18+
3. **Blog Management**: Users can create, edit, and delete blog articles.
19+
4. **Viewing Articles**: Articles can be viewed as a list and in detail. Pagination and sorting are supported for displaying a large number of articles.
20+
5. **Tags and Filters**: Articles can be filtered by tags, and users can add tags to articles.
21+
6. **Search**: Search for articles using keywords.
22+
7. **Comments**: Users can add comments and reply to them.
1623

17-
- User registration and authentication :white_check_mark:
18-
- Hierarchical Role-Based Access Control :white_check_mark:
19-
- Users can manage their profiles, including changing passwords and updating their information. Administrators can manage users :white_check_mark:
20-
- Creation, editing, and deletion of blog articles :white_check_mark:
21-
- Display of article list and their details :white_check_mark:
22-
- Pagination and sort support for displaying a large number of articles :white_check_mark:
23-
- Ability to add tags to articles and filter by tags :white_check_mark:
24-
- Search for articles using keywords :white_check_mark:
25-
- Adding comments/replies to articles :white_check_mark:
2624

27-
## Project Implementation Steps
25+
## Installation and Local Setup
26+
To run this project locally, you can use Docker Compose. Make sure you have Docker and Docker Compose installed on your system.
2827

29-
Here is the link to the Milestones:
30-
[Milestones](https://github.com/Desunovu/fastapi-mongodb-blog/milestones)
28+
1. Clone the repository:
29+
30+
```bash
31+
git clone https://github.com/Desunovu/fastapi-vue-blog.git
32+
cd fastapi-vue-blog
33+
```
34+
2. Open the `.env.production` file located in the project's root directory using a text editor. Set the `SECRET_KEY` variable in this file to a secure secret key for your application. For example:
35+
36+
```dotenv
37+
SECRET_KEY=mysecretkey
38+
```
39+
Ensure that the SECRET_KEY value is kept secret and not shared publicly.
40+
41+
42+
3. Build and start the application containers using Docker Compose:
43+
```bash
44+
docker-compose up --build
45+
```
46+
This command will download the necessary Docker images, build the application, and start the containers.
47+
48+
## Accessing the Application
49+
- Vue App: http://localhost:8080
50+
- API Documentation: http://localhost:8000/docs
51+
52+
## License
53+
54+
This project is distributed under the [MIT License](LICENSE).

backend/.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*
22
!blogapp
33
!tests
4-
!.envexample
54
!pyproject.toml
65
!poetry.lock

backend/.envexample

Lines changed: 0 additions & 11 deletions
This file was deleted.

backend/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM python:3.11-alpine
22
RUN mkdir backend
33
WORKDIR /backend
4-
COPY /pyproject.toml .
4+
COPY /backend/pyproject.toml .
55
RUN pip3 install poetry
66
RUN poetry config virtualenvs.create false
77
RUN poetry install
8-
COPY . ./
8+
COPY /backend /backend
99
EXPOSE 8000
1010
CMD ["uvicorn", "blogapp.main:app", "--host", "0.0.0.0"]

backend/blogapp/core/config.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55
from dotenv import load_dotenv
66

7-
# Загрузка переменных окружения из файла ".envexample"
8-
# без перезаписи если они уже существуют
9-
dotenv_path = os.path.join(
10-
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
11-
".envexample",
12-
)
13-
load_dotenv_result = load_dotenv(dotenv_path=dotenv_path)
7+
mode = os.getenv("APP_MODE", "development")
8+
if mode == "development":
9+
# Загрузка переменных окружения из файла ".env.development в /backend"
10+
# Не перезаписывает уже заданные переменные.
11+
# Переменные для prod устанавливаются в docker-compose.yml
12+
env_path = os.path.join(
13+
os.path.dirname(
14+
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
15+
),
16+
".env.development",
17+
)
18+
print(f"[DEV MODE] Путь к файлу .env: {env_path}")
19+
load_dotenv_result = load_dotenv(dotenv_path=env_path)
20+
elif mode == "production":
21+
print(f"[PROD MODE]")
1422

1523
# Определение констант из переменных окружения
1624
SECRET_KEY = os.getenv("SECRET_KEY")
@@ -20,7 +28,7 @@
2028

2129
# Прочие константы
2230
ALGORITHM = "HS256"
23-
ACCESS_TOKEN_EXPIRE_MINUTES = 30
31+
ACCESS_TOKEN_EXPIRE_MINUTES = 600
2432

2533
# Вычисление абсолютных путей приложения
2634
BACKEND_DIR_PATH: Path = Path().parent.parent.absolute()

backend/blogapp/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22

33
from fastapi import FastAPI
4+
from fastapi.middleware.cors import CORSMiddleware
45

56
from .core.database.mongodb import init_odm
67
from .core.logging import init_loggers
@@ -13,6 +14,18 @@
1314

1415
app = FastAPI()
1516

17+
origins = [
18+
"*"
19+
]
20+
21+
app.add_middleware(
22+
CORSMiddleware,
23+
allow_origins=origins,
24+
allow_credentials=True,
25+
allow_methods=["*"],
26+
allow_headers=["*"],
27+
)
28+
1629
log = logging.getLogger("blogapp")
1730

1831

backend/docker-compose.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)