Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FriendZone/BE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BE/

## API Documentation

Replace `{{HOST}}` with your server's host URL (e.g., `http://localhost:8000`)
Replace `{{HOST}}` with your server's host URL (e.g., `http://localhost:8080`)

### 1. Authentication

Expand Down
2 changes: 1 addition & 1 deletion aider-genius/aider/website/docs/usage/not-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Added Dockerfile and docker-compose.yml to the chat.
```
+ USER appuser
+ HEALTHCHECK --interval=30s --timeout=3s \
+ CMD curl -f http://localhost:8000/health || exit 1
+ CMD curl -f http://localhost:8080/health || exit 1
```

#### Expose port 5432 and add volume for postgres data
Expand Down
6 changes: 3 additions & 3 deletions jac-gpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jac-gpt/

# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/
MONGODB_DATABASE=jac_gpt
MONGODB_DATABASE=jaseci

# Optional: Serper API for web search
SERPER_API_KEY=your-serper-api-key-here
Expand All @@ -86,7 +86,7 @@ jac-gpt/
jac serve server.jac
```

The server will start on `http://localhost:8000` by default.
The server will start on `http://localhost:8080` by default.

### 2. React Client Setup

Expand All @@ -112,7 +112,7 @@ jac-gpt/
Edit `.env` and update the configuration:
```env
# JAC Server Configuration
VITE_API_URL=http://localhost:8000
VITE_API_URL=http://localhost:8080

# Authentication (uses defaults if not provided)
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/client/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# API Configuration
VITE_API_URL=http://localhost:8000
VITE_API_URL=http://localhost:8080

# Authentication Configuration (optional, will use defaults if not provided)
[email protected]
Expand Down
10 changes: 9 additions & 1 deletion jac-gpt/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ RUN bun install
COPY . .

# Accept build arguments
ARG VITE_API_URL=http://localhost:8000
# Accept build arguments
ARG VITE_API_URL=http://localhost:8080
ARG [email protected]
ARG VITE_JAC_USER_PASSWORD=password

# Set environment variables for the build
ENV VITE_API_URL=$VITE_API_URL
ENV VITE_JAC_USER_EMAIL=$VITE_JAC_USER_EMAIL
ENV VITE_JAC_USER_PASSWORD=$VITE_JAC_USER_PASSWORD

# Build the application
RUN bun run build
Expand Down
19 changes: 19 additions & 0 deletions jac-gpt/client/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ http {
try_files $uri $uri/ /index.html;
}

# Proxy API requests to the backend
location /api/ {
proxy_pass http://jac-server:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;

# Handle preflight requests
if ($request_method = 'OPTIONS') {
return 204;
}
}

# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
Expand Down
10 changes: 5 additions & 5 deletions jac-gpt/client/src/components/AdminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const AdminDashboard = () => {
const fetchUsers = async () => {
try {
console.log('🔍 Fetching users with requester_email:', user?.email);
console.log('🔍 API URL:', import.meta.env.VITE_API_URL || 'http://localhost:8000');
console.log('🔍 API URL:', import.meta.env.VITE_API_URL || 'http://localhost:8080');

// Get auth token for headers
const token = localStorage.getItem('auth_token');
Expand All @@ -88,7 +88,7 @@ const AdminDashboard = () => {
console.log('🔍 Added Authorization header');
}

const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/get_all_users`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/get_all_users`, {
method: 'POST',
headers,
body: JSON.stringify({ requester_email: user?.email }),
Expand Down Expand Up @@ -138,7 +138,7 @@ const AdminDashboard = () => {
console.log('🔍 Added Authorization header');
}

const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/get_all_sessions_admin`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/get_all_sessions_admin`, {
method: 'POST',
headers,
body: JSON.stringify({ requester_email: user?.email }),
Expand Down Expand Up @@ -186,7 +186,7 @@ const AdminDashboard = () => {
headers['Authorization'] = `Bearer ${token}`;
}

const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/get_session_messages_admin`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/get_session_messages_admin`, {
method: 'POST',
headers,
body: JSON.stringify({
Expand Down Expand Up @@ -230,7 +230,7 @@ const AdminDashboard = () => {
// First get all sessions with their messages
for (const session of sessions) {
try {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/get_session_messages_admin`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/get_session_messages_admin`, {
method: 'POST',
headers,
body: JSON.stringify({
Expand Down
10 changes: 5 additions & 5 deletions jac-gpt/client/src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {

// Always fetch the latest user profile to ensure correct role
try {
const profileResponse = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/get_user_profile`, {
const profileResponse = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/get_user_profile`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -121,7 +121,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {

// First, try the built-in JAC Cloud login endpoint
try {
response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/user/login`, {
response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/user/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -143,7 +143,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
if (token) {
// Fetch the complete user profile from our custom endpoint to get correct role
try {
const profileResponse = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/get_user_profile`, {
const profileResponse = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/get_user_profile`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -233,7 +233,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
};

// Use JAC Cloud's built-in register endpoint
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/user/register`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/user/register`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -254,7 +254,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
// Save location data if available
if (location) {
try {
await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/walker/save_user_location`, {
await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/walker/save_user_location`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/client/src/pages/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ForgotPassword = () => {
setIsLoading(true);

try {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/user/forgot_password`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/user/forgot_password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/client/src/pages/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ResetPassword = () => {
setIsLoading(true);

try {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/user/reset_password`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/user/reset_password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/client/src/pages/VerifyEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const VerifyEmail = () => {

const verifyEmail = async () => {
try {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8000'}/user/verify`, {
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:8080'}/user/verify`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/client/src/services/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DocumentationService {
private baseUrl: string;

constructor() {
this.baseUrl = 'http://localhost:8000';
this.baseUrl = 'http://localhost:8080';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/client/src/services/jacServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class JacServerService {
private defaultPassword: string;

constructor() {
this.baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:8000';
this.baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080';
this.defaultEmail = import.meta.env.VITE_JAC_USER_EMAIL || '[email protected]';
this.defaultPassword = import.meta.env.VITE_JAC_USER_PASSWORD || 'password';
}
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- DATABASE_HOST=mongodb+srv://v30793620:[email protected]/?retryWrites=true&w=majority&appName=Cluster0
- DATABASE_NAME=jac_gpt
- DATABASE_NAME=jaseci
- PYTHONUNBUFFERED=1
- PYTHONDONTWRITEBYTECODE=1
- JAC_ENV=production
Expand Down
23 changes: 17 additions & 6 deletions jac-gpt/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ services:
restart: unless-stopped
ports:
- "8080:8080"
env_file:
- ./server/.env
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:-your_openai_api_key_here}
- DATABASE_HOST=mongodb+srv://v30793620:[email protected]/?retryWrites=true&w=majority&appName=Cluster0
- DATABASE_NAME=jac_gpt
- DATABASE_NAME=jaseci
- PYTHONUNBUFFERED=1
- PYTHONDONTWRITEBYTECODE=1
volumes:
Expand All @@ -20,26 +22,35 @@ services:
- jac_server_logs:/app/logs
networks:
- jac-gpt-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/docs"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s

# React Frontend (Webapp)
jac-webapp:
build:
context: ./client
dockerfile: Dockerfile
args:
VITE_API_URL: http://localhost:8080
- VITE_API_URL=/api
- [email protected]
- VITE_JAC_USER_PASSWORD=password
container_name: jac-gpt-webapp
restart: unless-stopped
ports:
- "3000:80" # Use port 3000 to avoid conflict with system nginx
environment:
- VITE_API_URL=http://localhost:8080
- VITE_JAC_USER_EMAIL=${VITE_JAC_USER_EMAIL:[email protected]}
- VITE_JAC_USER_PASSWORD=${VITE_JAC_USER_PASSWORD:-password}
depends_on:
- jac-server
networks:
- jac-gpt-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3

volumes:
jac_server_data:
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/server/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ OPENAI_API_KEY=your_openai_api_key_here

# Database configuration
DATABASE_HOST=mongodb://localhost:27017
DATABASE_NAME=jac_gpt_prod4
DATABASE_NAME=jaseci
4 changes: 4 additions & 0 deletions jac-gpt/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ RUN mkdir -p /app/data /app/logs
# Expose port 8000 (default for jac serve)
EXPOSE 8080

# Set environment variables for CORS
ENV CORS_ORIGINS="http://localhost:3000,http://127.0.0.1:3000"
ENV CORS_ALLOW_CREDENTIALS="true"

# Set the default command to serve the jac application
CMD ["jac", "serve", "server.jac", "--host", "0.0.0.0", "--port", "8080"]
2 changes: 1 addition & 1 deletion jac-gpt/server/database.jac
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ obj MongoDB {
print("DATABASE_HOST not found! Falling back to localhost...");
mongo_uri = "mongodb://localhost:27017/";
}
db_name = os.getenv("DATABASE_NAME", "jac_gpt_2");
db_name = os.getenv("DATABASE_NAME", "jaseci");

print(f"Attempting to connect to MongoDB with URI: {mongo_uri[:50]}...");
print(f"Database name: {db_name}");
Expand Down
2 changes: 1 addition & 1 deletion jac-gpt/server/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ <h2 class="about-title">An Intellectual Journey</h2>
{ type: 'success', text: '🌐 Task Manager API Ready!' },
{ type: 'success', text: '✅ POST /create_task - Create a new task' },
{ type: 'success', text: '✅ GET /get_tasks - List all tasks' },
{ type: 'info', text: '🚀 Server running at http://localhost:8000' },
{ type: 'info', text: '🚀 Server running at http://localhost:8080' },
{ type: 'info', text: '📚 API docs available at /docs' },
{ type: 'success', text: '⚡ Auto-scaling enabled - 0 to 1000 instances' },
{ type: 'success', text: '💾 Persistent storage configured and ready' }
Expand Down
Loading