# Project export: Proxima OS

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: OpenAI Build Week
- Tagline: AI-Native OS powered by GPT-5.6 & Codex. State a goal, Proxima autonomously orchestrates emails, calendars, docs, and code delivering results while you're offline.
- Devpost: https://devpost.com/software/proxima-os
- GitHub: https://github.com/Linkxee-Tech/Proxima
- Demo: https://proxima-fxni.vercel.app/
- Video: https://www.youtube.com/embed/5U7tn7GwhCU?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 1 GitHub contributor(s) — Codex (42 commits)

## Devpost submission (written by the team)

### Inspiration

Work often gets stuck between an idea and the small steps needed to finish it. A simple request such as “prepare a meeting,” “research competitors,” or “share an update” can turn into several tabs, drafts, reminders, and approval messages. We wanted to build a workspace that helps people move from a clear outcome to prepared work without losing control of what is sent, scheduled, or published.

### What it does

Proxima OS helps users organise everyday work in one place. A user can describe what they need to do, review a prepared plan and draft, edit it, save it for later, or start the work. The workspace supports meeting planning, email drafts, research briefs, proposals, campaign planning, saved knowledge, approvals, and activity history. For social campaigns, users can create channel-specific drafts, choose connected accounts, approve a post immediately, schedule it for later, or create a recurring campaign around a topic. For example, a cyber security campaign can be broken into several practical angles and published daily or weekly until the user stops it. Nothing is sent without a clear action from the user, unless they have deliberately enabled a recurring campaign.

### How we built it

We built the frontend with Next.js and the backend with FastAPI. The app uses authenticated API routes, WebSockets for live updates, and durable storage for workflows, drafts, approvals, connected accounts, and campaign history. We connected the workspace to services such as Gmail, Google Calendar, Slack, Notion, X, LinkedIn, Facebook Pages, and WhatsApp Business through their supported authentication flows. The drafting features use OpenAI models to turn a short request into a structured plan, working draft, research outline, or channel-specific social post. We designed the interface so users can always review and edit the result before it becomes an action.

### Challenges we ran into

The hardest part was making connected services behave honestly. Every provider has different permissions, callback rules, token lifetimes, account requirements, and publishing APIs. We had to handle cases where an account is connected but does not yet have permission to publish, where a Facebook Page ID is missing, or where a scheduled post cannot run because the hosting service is asleep. Another challenge was keeping the experience simple while supporting different kinds of work. A research report, a meeting invitation, and a social campaign should not all feel like the same generic form.

### Accomplishments we're proud of

Built a complete flow from a written goal to an editable work plan. Added a real approval system instead of treating approval as a visual label. Made campaign publishing show the actual result from each connected provider. Added recurring topic campaigns that can continue on a daily or weekly schedule until stopped. Kept drafts, approvals, activity, and connected accounts visible in one workspace. Made the product usable locally and deployable with a Next.js frontend and FastAPI backend.

### What we learned

We learned that the useful part of automation is not removing the person from the process. It is reducing repetitive work while making the next decision obvious. We also learned that integrations need clear status messages. A button should not say something was published if it was only saved for approval. Showing the real state of a task builds more trust than hiding provider errors.

### What's next

Next, we want to improve reliability for scheduled work with a dedicated always-on worker, add provider-specific image publishing, improve account naming when several accounts are connected, and make recurring campaigns more flexible with custom posting times and campaign limits. We also want to add richer research outputs, better collaboration features, and clearer reporting so users can see what work was completed and what still needs their attention.

## README (from the GitHub repository)

# Proxima

Proxima is a work companion for turning a written request into prepared, reviewable work. It keeps plans, drafts, approvals, connected accounts, and activity in one place so the user remains in control of what is sent or scheduled.

## What it does

- Turn a work request into a plan and an editable prepared draft.
- Improve a prepared draft with the configured OpenAI model, then save or download it.
- Keep progress, approvals, results, history, and saved work together.
- Generate channel-specific social drafts, edit them, and approve them for delivery.
- Select a connected X, LinkedIn, or Facebook account when more than one is available.
- Schedule a one-time campaign or run a recurring daily or weekly topic series until it is stopped.
- Connect supported services through their own sign-in flows.
- Send a user-authored message through a connected Slack workspace.
- Deliver live updates to signed-in users.

Proxima has a Next.js web application and a FastAPI service. Local development uses a JSON data store. A PostgreSQL-compatible store can be selected for hosted environments.

## Built with Codex and GPT-5.6

I used Codex throughout the build to work through the frontend and backend request paths, improve the approval and campaign flows, trace integration problems, add regression tests, and keep the README and architecture notes aligned with the code.

GPT-5.6 is used by Proxima to prepare first-pass work drafts and channel-specific social copy when `OPENAI_API_KEY` is configured. These responses are drafts, not automatic decisions: a user can edit them, save them, and decide whether an external action should be approved or scheduled.

The project deliberately keeps this boundary visible. Provider actions require a connected account and the right credentials, while approvals and delivery results make it clear what was requested, what was sent, and what a provider accepted or rejected.

## Social campaigns

The Campaigns workspace creates editable drafts for X, LinkedIn, Facebook Pages, and WhatsApp Business. A saved campaign appears in **Needs Your Approval** and can be published immediately or scheduled. Delivery results are stored per provider so the interface does not report a post as sent when a provider rejected it.

The **Recurring campaigns** workspace turns one topic, such as “Cyber security,” into a series of subtopics. It generates and posts the next instalment at the selected daily or weekly cadence until the user stops the campaign.

Before enabling publishing, connect the appropriate accounts in **Connected Apps**. Use **Add account** to connect another X, LinkedIn, or Facebook account. WhatsApp Business sends a direct message, so it requires an opted-in recipient and valid Cloud API credentials.

Text publishing is implemented. Images remain available in campaign previews, but provider-specific media upload flows are not yet implemented, so an image is not silently claimed as published.

## Project layout

```text
backend/       API, authentication, data storage, integrations, and tests
frontend/      Web application and public pages
docs/          Technical notes for contributors
.env.example   Backend environment template
```

## Run locally

### Start the backend

```powershell
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Copy-Item ..\.env.example .env
.\start-local.ps1
```

Open `http://localhost:8000/` for the API reference or `http://localhost:8000/health` for the health check.

`0.0.0.0` is only a server bind address. Use `http://localhost:8000/` in a browser.

### Start the frontend

```powershell
cd frontend
npm ci
Copy-Item .env.example .env.local
npm run dev
```

Open `http://localhost:3000`, create an account, and submit a request.

## Configuration

The backend reads `backend/.env`; the frontend reads `frontend/.env.local`. Do not commit either file.

For a hosted environment, configure these values with your hosting provider:

```env
# Backend
PROXIMA_STORAGE_BACKEND=postgres
PROXIMA_DATABASE_URL=postgresql://...
PROXIMA_JWT_SECRET=<long-random-value>
PROXIMA_TOKEN_ENCRYPTION_KEY=<long-random-value>
PROXIMA_CORS_ORIGINS=https://your-frontend.example
PROXIMA_PUBLIC_APP_URL=https://your-frontend.example
PROXIMA_PUBLIC_API_URL=https://your-api.example
PROXIMA_FRONTEND_CALLBACK_URL=https://your-frontend.example/dashboard/integrations
PROXIMA_SOCIAL_SCHEDULER_INTERVAL_SECONDS=30
PROXIMA_LINKEDIN_API_VERSION=202606
PROXIMA_META_GRAPH_API_VERSION=v22.0
FACEBOOK_PAGE_ID=

# Password reset email
PROXIMA_SMTP_HOST=smtp.example.com
PROXIMA_SMTP_PORT=587
PROXIMA_SMTP_USERNAME=...
PROXIMA_SMTP_PASSWORD=...
PROXIMA_SMTP_FROM=Proxima <support@your-domain.example>
PROXIMA_SMTP_USE_TLS=true

# Frontend
PROXIMA_API_BASE_URL=https://your-api.example
NEXT_PUBLIC_PROXIMA_WS_URL=wss://your-api.example/ws
```

Add provider credentials only for the services you intend to use. Keep all secrets in the hosting provider’s environment settings. In production, password reset links require a working SMTP provider.

## Deployment checklist

Before release, confirm that:

1. The backend health endpoint is public.
2. A new user can register, sign in, and reset a password.
3. The web application connects to the secure WebSocket endpoint.
4. A request can reach an approval step and be completed.
5. Persistent data survives an application restart.
6. Every enabled provider callback matches its deployed URL exactly.
7. A social post can be approved and its provider result appears in Campaigns.
8. The scheduled-post worker stays available for every campaign that needs exact delivery times.

Recurring and scheduled campaigns are checked by the backend while it is running. A host that sleeps inactive services cannot guarantee an exact posting time; use an always-on worker or host for reliable scheduling.

The backend includes a `Dockerfile` and `Procfile`. The frontend can be deployed to Vercel or another Node.js host.

For a local Docker setup, run `docker compose up --build` from the repository root. The backend uses port 8000 and the frontend uses port 3001.

## Checks

Backend:

```powershell
cd backend
.\.venv\Scripts\python.exe -m compileall -q app
.\.venv\Scripts\python.exe -m pytest tests -q
```

Frontend:

```powershell
cd frontend
npm run typecheck
npm run build
```

## License

This project is available under the [MIT License](LICENSE).


## Detected evidence (automated analysis)

Indexed codebase: 160 recognized source files, 421 KB.
- CSS (language) — detected in the code
- FastAPI (technology) — detected in the code
- JavaScript (language) — detected in the code
- Next.js (technology) — detected in the code
- OpenAI (technology) — detected in the code
- Python (language) — detected in the code
- React (technology) — detected in the code
- Redis (technology) — detected in the code
- TypeScript (language) — detected in the code
- Docker (technology) — claimed on Devpost, not found in the code
- PostgreSQL (technology) — claimed on Devpost, not found in the code
- Supabase (technology) — claimed on Devpost, not found in the code
- Tailwind CSS (technology) — claimed on Devpost, not found in the code
- Vercel (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (120 of 175)

```
.env.example
.github/workflows/ci.yml
.gitignore
.gitkeep
backend/app/__init__.py
backend/app/core/config.py
backend/app/core/crypto.py
backend/app/core/realtime.py
backend/app/core/security.py
backend/app/core/store.py
backend/app/db/__init__.py
backend/app/db/client.py
backend/app/kernel/__init__.py
backend/app/kernel/approval.py
backend/app/kernel/dag.py
backend/app/kernel/intent.py
backend/app/kernel/observability.py
backend/app/kernel/scheduler.py
backend/app/kernel/state.py
backend/app/main.py
backend/app/memory/__init__.py
backend/app/memory/mesh.py
backend/app/middleware/__init__.py
backend/app/middleware/auth.py
backend/app/middleware/cors.py
backend/app/middleware/exceptions.py
backend/app/middleware/logging.py
backend/app/middleware/rate_limit.py
backend/app/routes/__init__.py
backend/app/routes/approvals.py
backend/app/routes/auth.py
backend/app/routes/deploy.py
backend/app/routes/health.py
backend/app/routes/history.py
backend/app/routes/integrations.py
backend/app/routes/memory.py
backend/app/routes/metrics.py
backend/app/routes/social.py
backend/app/routes/tools.py
backend/app/routes/workflows.py
backend/app/sandbox/__init__.py
backend/app/sandbox/manager.py
backend/app/schemas.py
backend/app/tools/__init__.py
backend/app/tools/base.py
backend/app/tools/calendar.py
backend/app/tools/codex.py
backend/app/tools/facebook.py
backend/app/tools/gmail.py
backend/app/tools/linkedin.py
backend/app/tools/notion.py
backend/app/tools/registry.py
backend/app/tools/slack.py
backend/app/tools/twitter.py
backend/app/tools/whatsapp.py
backend/app/workers/__init__.py
backend/app/workers/async.py
backend/app/workers/queue.py
backend/Dockerfile
backend/Procfile
backend/requirements.txt
backend/start-local.ps1
backend/tests/test_api.py
docker-compose.yml
docs/architecture.md
docs/devpost-submission-brief.md
frontend/.env.example
frontend/.nvmrc
frontend/app/api/[...path]/route.ts
frontend/app/approvals/page.jsx
frontend/app/dashboard/approvals/page.tsx
frontend/app/dashboard/drafts/page.tsx
frontend/app/dashboard/history/page.tsx
frontend/app/dashboard/insights/page.tsx
frontend/app/dashboard/integrations/page.tsx
frontend/app/dashboard/layout.tsx
frontend/app/dashboard/memory/page.tsx
frontend/app/dashboard/page.tsx
frontend/app/dashboard/settings/page.tsx
frontend/app/dashboard/social/page.tsx
frontend/app/dashboard/social/recurring/page.jsx
frontend/app/dashboard/work/page.tsx
frontend/app/error.tsx
frontend/app/forgot-password/page.jsx
frontend/app/globals.css
frontend/app/history/page.jsx
frontend/app/integrations/page.tsx
frontend/app/layout.jsx
frontend/app/login/page.jsx
frontend/app/memory/page.jsx
frontend/app/not-found.tsx
frontend/app/page.jsx
frontend/app/privacy/page.jsx
frontend/app/register/page.jsx
frontend/app/reset-password/page.jsx
frontend/app/settings/page.jsx
frontend/app/social/page.jsx
frontend/app/terms/page.jsx
frontend/components/AnalyticsChart.tsx
frontend/components/ApprovalCard.tsx
frontend/components/ApprovalModal.jsx
frontend/components/ArtifactCard.jsx
frontend/components/AuthGate.jsx
frontend/components/ChatPanel.jsx
frontend/components/CompletionScreen.jsx
frontend/components/ConnectionStatus.tsx
frontend/components/DAGVisualizer.jsx
frontend/components/Icon.jsx
frontend/components/InsightsPage.jsx
frontend/components/LandingPage.jsx
frontend/components/MagicInput.jsx
frontend/components/MemoryCard.tsx
frontend/components/MissionTimeline.jsx
frontend/components/Navbar.jsx
frontend/components/PlatformSelector.jsx
frontend/components/PreferencesPanel.jsx
frontend/components/providers/Providers.jsx
frontend/components/ProximaDashboard.jsx
frontend/components/RecurringCampaigns.jsx
frontend/components/ScheduledPosts.tsx
[55 more files omitted for size]
```

### Dependencies

- backend/requirements.txt: bcrypt@==4.0.1, cryptography@==44.0.0, email-validator@==2.2.0, fastapi@==0.115.6, httpx@==0.28.1, networkx@==3.4.2, openai@==1.59.7, passlib[bcrypt]@==1.7.4, pg8000@==1.31.2, pinecone-client@==5.0.1, prometheus-client@==0.21.1, pydantic@==2.10.5, pydantic-settings@==2.7.1, PyJWT@==2.10.1, pytest@==8.3.4, python-multipart@==0.0.20, redis@==5.2.1, tzdata@==2025.2, uvicorn[standard]@==0.34.0
- frontend/package.json: @types/node@20.17.6, @types/react@^19.2.17, @types/react-dom@^19.2.3, @xyflow/react@^12.11.2, axios@^1.6.8, dagre@^0.8.5, next@^15.5.20, react@^19.2.7, react-dom@^19.2.7, socket.io-client@^4.7.5, typescript@5.8.2, zustand@^5.0.14

### Recent commits (newest first)

- fix(social): add OAuth2 token refresh, realtime updates, and UI spacing
- Add publish retries with exponential backoff and improved logging
- Save workspace changes before push
- Add timezone selector and parsing for recurring campaigns
- Record unexpected social delivery failures
- Show recurring generation history and handle rate limits
- Document Codex usage and frontend architecture
- Fix prepared draft improvement configuration
- Align README with current campaign features
- Add recurring AI social campaigns
- Label sidebar history page clearly
- Publish campaigns from workflow approvals
- Make drafts editable and unify campaign approvals
- Deliver approved and scheduled social campaigns
- Generate reviewable office task drafts
- Use current X OAuth authorization endpoint
- Send workflow updates to Slack
- Complete v1 submission experience
- Enable sending messages through connected Slack
- Clarify integration connection states

## Key source files (fetched from GitHub, selected and truncated for size)

### docs/devpost-submission-brief.md

```markdown
# Proxima

## A short project brief

Proxima is a workspace for turning everyday work requests into a clear plan, a useful draft, and a set of actions that stay under the user's control. It brings planning, approvals, connected tools, social publishing, and activity history into one place.

The project came from a simple frustration: work often gets scattered between notes, inboxes, calendars, and social accounts. A request such as "plan next week's launch" should not end as a vague checklist. It should become something a person can read, adjust, approve, and follow through on.

## Built with Codex and GPT-5.6

I used Codex throughout the build to work through the frontend and backend request paths, improve the approval and campaign flows, trace integration problems, add regression tests, and keep the README and architecture notes aligned with the code.

GPT-5.6 is used by Proxima to prepare first-pass work drafts and channel-specific social copy when `OPENAI_API_KEY` is configured. These responses are drafts, not automatic decisions: a user can edit them, save them, and decide whether an external action should be approved or scheduled.

The project deliberately keeps this boundary visible. Provider actions require a connected account and the right credentials, while approvals and delivery results make it clear what was requested, what was sent, and what a provider accepted or rejected.

## What you can try

- Give Proxima an open-ended work request. It prepares a structured draft that can be edited before use.
- Review a proposed action in the approval area. Nothing is sent externally until the user approves it.
- Connect supported accounts and send a message or publish a social post from the workspace.
- Prepare a social campaign, choose connected accounts, schedule it, or keep it for review.
- Create a recurring campaign. Proxima breaks a broad topic into smaller angles and continues on the selected schedule until the user stops it.
- Visit History to see completed work and the recorded outcome of supported actions.

## How it was built

The frontend is a Next.js application and the backend is built with FastAPI. The application stores users, work items, approvals, connected-account tokens, campaigns, and activity records in its database. OAuth connections are handled on the backend, and provider tokens are stored encrypted.

OpenAI is used for first-pass work drafts and social copy. The generated text is deliberately presented as a draft: the user can edit it and decide whether it should be approved or scheduled. I used Codex throughout the build to work through the API design, interface changes, integration flows, test coverage, and documentation. GPT-5.6 was used as part of that development process.

## A practical note for reviewers

The core workflow can be explored without connecting an external account. Sending email, calendar events, chat messages, and posts requires the corresponding account to be connected and configured with valid p
[truncated — 680 more characters]
```

### docs/architecture.md

```markdown
# Proxima architecture

This note describes the repository as it runs today. It is for contributors who need to find the request paths, data boundaries, and background work before making a change.

![Proxima architecture diagram](./proxima-architecture.png)

## Frontend diagram

![Proxima frontend architecture diagram](./proxima-frontend-architecture.png)

```mermaid
flowchart LR
    browser["Browser"] --> web["Next.js application"]
    web --> proxy["Next.js /api proxy"]
    proxy --> api["FastAPI /api/v1"]
    browser -. authenticated WebSocket .-> realtime["FastAPI /ws"]

    api --> auth["Auth and workflow routes"]
    api --> social["Social and tool routes"]
    api --> store["State store"]
    api --> media["Uploaded media"]
    api --> providers["OAuth providers and provider APIs"]
    api --> scheduler["In-process social scheduler"]
    scheduler --> social

    store --> local["Local JSON"]
    store --> postgres["PostgreSQL JSONB state"]
```

## Request flow

1. The browser loads the Next.js application.
2. Browser requests to `/api/*` are handled by `frontend/app/api/[...path]/route.ts`. The proxy forwards them to FastAPI under `/api/v1/*`.
3. FastAPI authenticates the request, reads or updates the state store, and returns the response through the proxy.
4. The dashboard opens a separate authenticated WebSocket directly to FastAPI at `/ws`. It sends a token as a query parameter and receives connection and heartbeat events. The WebSocket does not pass through the Next.js proxy.
5. OAuth callbacks return to FastAPI, which records the provider connection and redirects the browser back to the frontend integration page.

The backend mounts the same API application at both `/api/v1` and `/api` for compatibility. It also exposes `/health` for host health checks, `/media` for stored uploads, and redirects `/` to its API documentation route.

## Frontend

- `frontend/app` contains page routes for the public pages and dashboard views.
- `frontend/components` contains the workspace, approval, integration, social, campaign, and history interfaces.
- `frontend/lib/proxima-api.js` adds authentication headers, handles refresh-token retries, and is the common browser API client.
- `frontend/app/api/[...path]/route.ts` is the server-side proxy. In hosted environments it requires `PROXIMA_API_BASE_URL` (or `NEXT_PUBLIC_API_URL`) to point to the backend.

The frontend keeps the access and refresh tokens in browser local storage. It uses the access token when calling the API and when establishing the WebSocket connection.

## Backend

`backend/app/main.py` creates the FastAPI application and registers these route groups:

- `auth`: registration, sign-in, token refresh, sign-out, password reset, and current-user lookup.
- `workflows`: intent analysis, prepared drafts, work plans, editable artifacts, approvals, reruns, cancellation, and dashboard data.
- `approvals`: pending approval lists and approve, reject, defer, resume, and batch actions.
- `social`: s
[truncated — 3537 more characters]
```

### docker-compose.yml

```yaml
services:
  api:
    build: ./backend
    env_file: ./backend/.env
    environment:
      PROXIMA_DATA_DIR: /app/.proxima-data
    ports: ["8000:8000"]
    volumes: ["./backend/.proxima-data:/app/.proxima-data"]
  web:
    image: node:24-alpine
    working_dir: /app
    command: sh -c "npm ci && npm run dev"
    environment:
      PROXIMA_API_BASE_URL: http://api:8000
      NEXT_PUBLIC_PROXIMA_WS_URL: ws://localhost:8000/ws
    ports: ["3001:3000"]
    volumes: ["./frontend:/app"]
    depends_on: [api]

```

### backend/Dockerfile

```
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app ./app
ENV PORT=8000
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT}"]

```

### backend/requirements.txt

```
fastapi==0.115.6
uvicorn[standard]==0.34.0
pydantic==2.10.5
pydantic-settings==2.7.1
tzdata==2025.2
email-validator==2.2.0
PyJWT==2.10.1
passlib[bcrypt]==1.7.4
# Passlib 1.7.4 reads bcrypt's legacy version metadata; 4.0.1 keeps local
# authentication startup free of the compatibility warning emitted by newer bcrypt releases.
bcrypt==4.0.1
httpx==0.28.1
openai==1.59.7
pinecone-client==5.0.1
redis==5.2.1
python-multipart==0.0.20
cryptography==44.0.0
networkx==3.4.2
prometheus-client==0.21.1
pytest==8.3.4
pg8000==1.31.2

```

### frontend/package.json

```
{
  "name": "proxima-frontend",
  "private": true,
  "version": "0.1.0",
  "engines": {
    "node": ">=22 <25"
  },
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "typecheck": "tsc --noEmit",
    "type-check": "tsc --noEmit"
  },
  "dependencies": {
    "@xyflow/react": "^12.11.2",
    "axios": "^1.6.8",
    "dagre": "^0.8.5",
    "next": "^15.5.20",
    "react": "^19.2.7",
    "react-dom": "^19.2.7",
    "socket.io-client": "^4.7.5",
    "zustand": "^5.0.14"
  },
  "devDependencies": {
    "@types/node": "20.17.6",
    "@types/react": "^19.2.17",
    "@types/react-dom": "^19.2.3",
    "typescript": "5.8.2"
  }
}

```

### frontend/app/page.jsx

```javascript
import LandingPage from '../components/LandingPage';

export default function Page() {
  return <LandingPage />;
}

```

### frontend/app/layout.jsx

```javascript
import './globals.css';
import Providers from '../components/providers/Providers';

export const metadata = {
  title: 'Proxima — Your Chief of Staff',
  description: 'Plan work, stay in control, and finish more with Proxima.',
};

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body><Providers>{children}</Providers></body>
    </html>
  );
}

```

### backend/app/main.py

```python
import asyncio
from contextlib import asynccontextmanager
from pathlib import Path
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import RedirectResponse
from .core.config import settings
from .core.realtime import realtime
from .core.security import websocket_user
from .middleware.logging import LoggingMiddleware
from .middleware.rate_limit import RateLimitMiddleware
from .middleware.exceptions import unhandled_exception
from .routes import health, auth, workflows, memory, integrations, social, approvals, history, deploy, tools, metrics

@asynccontextmanager
async def lifespan(application: FastAPI):
    task = asyncio.create_task(social.scheduler_loop())
    application.state.social_scheduler = task
    try:
        yield
    finally:
        task.cancel()
        try:
            await task
        except asyncio.CancelledError:
            pass


app = FastAPI(title="Proxima OS API", version="1.0.0", docs_url=None, redoc_url=None, openapi_url=None, lifespan=lifespan)
app.add_middleware(LoggingMiddleware)
app.add_middleware(RateLimitMiddleware)
app.add_exception_handler(Exception, unhandled_exception)
app.add_middleware(
    CORSMiddleware,
    allow_origins=[origin.strip() for origin in settings.proxima_cors_origins.split(",")],
    allow_origin_regex=r"^https?://(localhost|127\.0\.0\.1)(:\d+)?$",
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
api = FastAPI()
for router in (health.router, auth.router, tools.router, workflows.router, memory.router, integrations.router, social.router, approvals.router, history.router, deploy.router, metrics.router): api.include_router(router)
app.mount("/api/v1", api)
app.mount("/api", api)


@app.get("/", include_in_schema=False)
def root() -> RedirectResponse:
    """Give local users a browser-friendly API entry point."""
    return RedirectResponse("/docs")


@app.get("/health", include_in_schema=False)
def root_health() -> dict:
    """Stable platform health-check path for Render and other hosts."""
    return health.health()


@app.get("/docs", include_in_schema=False)
def root_docs() -> RedirectResponse:
    return RedirectResponse("/api/v1/docs")


@app.get("/openapi.json", include_in_schema=False)
def root_openapi() -> RedirectResponse:
    return RedirectResponse("/api/v1/openapi.json")

Path(settings.proxima_data_dir, "uploads").mkdir(parents=True, exist_ok=True)
app.mount("/media", StaticFiles(directory=str(Path(settings.proxima_data_dir) / "uploads"), check_dir=False), name="media")


@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket) -> None:
    try:
        user = websocket_user(websocket.query_params.get("token"), websocket.cookies.get("proxima_access_token"))
    except ValueError:
        await websocket.close(code=1008)
        return
    await realtime.connect(user["id"], websocket)
    await websocket.send_json({"type": "connected", "service": "proxima-fastapi"})
    try:
        while True:
            await websocket.receive_text()
            await websocket.send_json({"type": "heartbeat"})
    except WebSocketDisconnect:
        pass
    finally:
        realtime.disconnect(user["id"], websocket)

```

### frontend/app/social/page.jsx

```javascript
import SocialHub from '../../components/SocialHub';
export default function Page() { return <SocialHub />; }

```

[151 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]