🧩 PostgreSQL + Chroma + FastAPI 환경 구축 요약 (Mac & Windows 공용)
1️⃣ PostgreSQL 설치
🔹 macOS용
brew install postgresql@17
brew services start postgresql@17
psql --version
해석:
brew install postgresql@17→ PostgreSQL 17버전 설치brew services start postgresql@17→ PostgreSQL 서버 자동 실행 설정psql --version→ 설치 확인 명령어
🔹 Windows용
- PostgreSQL 공식사이트 에서 설치 파일 다운로드
- 설치 시 pgAdmin 포함 선택 (GUI 관리도구)
- 설치 완료 후
psql실행 확인:psql -U postgres -l
해석:
-U postgres→ 관리자 계정 접속-l→ 현재 데이터베이스 목록 출력
2️⃣ (선택) pgvector 설치 (Mac/Linux 전용)
git clone https://github.com/pgvector/pgvector.git
cd pgvector
make PG_CONFIG=/opt/homebrew/opt/postgresql@17/bin/pg_config
sudo make install
해석:
git clone→ pgvector 소스 다운로드make→ PostgreSQL 확장 모듈 빌드sudo make install→ 시스템 PostgreSQL에 모듈 등록⚠️ 윈도우에서는 직접 설치 불가 → Docker 또는 ChromaDB 대체 필요
3️⃣ Python 가상환경 생성 (conda)
conda create -n Research python=3.10 -y
conda activate Research
해석:
conda create -n Research→ Research라는 이름의 독립 개발환경 생성conda activate Research→ 해당 환경 활성화
활성화되면 프롬프트에 (Research) 표시됨.
4️⃣ 주요 패키지 설치
python -m pip install chromadb fastapi uvicorn langchain openai psycopg2-binary
해석:
| 패키지 | 역할 |
|---------|------|
| chromadb | AI 벡터 검색 DB (로컬 RAG용) |
| fastapi | 백엔드 프레임워크 (API 서버 구성) |
| uvicorn | FastAPI 실행용 서버 |
| langchain | AI 파이프라인 관리 (임베딩, RAG 구성) |
| openai | GPT API 연동용 |
| psycopg2-binary | PostgreSQL 연결 드라이버 |
5️⃣ 설치 확인
python -c "import chromadb, fastapi, langchain, openai, psycopg2; print('OK')"
해석:
- 설치된 라이브러리들이 정상적으로 import되는지 테스트
OK출력되면 모든 설치 완료
6️⃣ PostgreSQL 연결 테스트
psql -U postgres -l
해석:
PostgreSQL 서버가 실행 중이고 접근 가능한지 확인.
또는 Python에서 연결 확인:
import psycopg2
conn = psycopg2.connect(dbname="postgres", user="postgres", password="비밀번호", host="localhost", port="5432")
print("DB 연결 성공")
conn.close()
7️⃣ ChromaDB 테스트 코드
import chromadb
client = chromadb.Client()
collection = client.create_collection("test")
collection.add(
documents=["Chroma is a vector database", "PostgreSQL handles structured data"],
ids=["1", "2"]
)
results = collection.query(query_texts=["What is Chroma?"], n_results=1)
print(results)
해석:
create_collection()→ 새로운 벡터 저장소 생성add()→ 문서를 벡터화하여 저장query()→ 유사한 문서 검색 (임베딩 기반 검색)
출력 예시:
{'ids': [['1']], 'distances': [[0.23]], 'documents': [['Chroma is a vector database']]}
→ 정상 동작 확인.
8️⃣ 전체 구조 요약
📦 현재 환경 구성
├── PostgreSQL 17 → 정형데이터 저장 (채용공고, 유저 정보 등)
├── ChromaDB → 벡터 데이터 저장 (AI 임베딩, 문서 검색)
├── FastAPI + Uvicorn → API 서버 및 RAG 인터페이스
└── Conda (Research) → Python 패키지 독립 환경✅ 마무리 요약
- PostgreSQL 17 + ChromaDB + FastAPI 조합으로 RAG / AI 챗봇 구조 준비 완료
- Mac은 직접 설치, Windows는 PostgreSQL + Python만 설치 후 동일 코드 실행 가능
- 다음 단계: FastAPI 기반 API 구축 (
/ingest,/chat,/search)
💡 이로써 인프라 세팅은 완전 종료. 이제 본격적인 AI 매칭 / 챗봇 서버를 구현할 수 있다.
'학원 TEAM 프로젝트 > 심화과정 Team Project(최종)' 카테고리의 다른 글
| 기록 5-1 . 그래서 버츄얼 비서 프로젝트..잘할수있을까? (0) | 2025.11.12 |
|---|---|
| 기록 5 . 프로젝트 기획 뒤짚어 엎기... (0) | 2025.11.12 |
| 기록 4 . 환경설정의 고민 (vectorDB, postgreSQL) (0) | 2025.11.11 |
| 기록 3 . 협업준비 (3) | 2025.11.11 |
| 기록 2. 기획 발표 PPT 정리. (0) | 2025.11.11 |