Saltar a contenido

πŸ“ Project Structure

GuΓ­a para entender dΓ³nde estΓ‘ cada cosa en Aeternus.

πŸ—οΈ Folder Layout

aeternus/
β”œβ”€β”€ src/                          # βš›οΈ Frontend (Next.js + React)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ layout.tsx           # Main layout
β”‚   β”‚   β”œβ”€β”€ page.tsx             # Home page
β”‚   β”‚   β”œβ”€β”€ chat/               # Chat module
β”‚   β”‚   β”œβ”€β”€ admin/              # Admin dashboard
β”‚   β”‚   └── api/                # Next.js API routes
β”‚   β”œβ”€β”€ components/             # React components
β”‚   β”œβ”€β”€ hook/                   # Custom hooks
β”‚   β”œβ”€β”€ lib/                    # Libraries & integrations
β”‚   └── utils/                  # Utility functions
β”‚
β”œβ”€β”€ core/                         # 🐍 Backend (FastAPI + Python)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py             # Entry point
β”‚   β”‚   β”œβ”€β”€ routes/             # API endpoints
β”‚   β”‚   β”œβ”€β”€ schemas.py          # Data models
β”‚   β”‚   └── settings.py         # Config
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env
β”‚
β”œβ”€β”€ prisma/                       # πŸ’Ύ Database Schema
β”‚   └── schema.prisma
β”‚
β”œβ”€β”€ docs/                         # πŸ“š Documentation
β”‚   β”œβ”€β”€ setup-local.md
β”‚   β”œβ”€β”€ environment-variables.md
β”‚   └── ...
β”‚
└── .github/workflows/            # πŸ€– CI/CD

Key Directories

src/app/

Next.js App Router β€” Each folder with page.tsx = a route.

  • src/app/page.tsx β†’ /
  • src/app/chat/page.tsx β†’ /chat
  • src/app/admin/page.tsx β†’ /admin

src/components/

React Components β€” Reusable, not tied to routes.

  • chat/ β€” Chat-related components
  • admin/ β€” Admin dashboard components
  • navbar/ β€” Navigation
  • etc.

src/hook/

Custom React Hooks β€” named with use* prefix.

  • useChat.ts β€” Chat logic hook
  • useAuth.ts β€” Auth logic hook

core/app/routes/

FastAPI Endpoints β€” Each file groups related endpoints.

  • chat.py β€” POST /v1/chat, POST /v1/chat/stream
  • chat_storage.py β€” POST /api/chat/save, etc.
  • tts.py β€” GET/POST /api/tts
  • health.py β€” GET /v1/health

prisma/

Database Schema β€” Define your data models here.

  • schema.prisma β€” User, Conversation, Message, etc.

Adding New Features

Add a new page

mkdir -p src/app/my-page
cat > src/app/my-page/page.tsx <<EOF
export default function MyPage() {
  return <div>My Page</div>;
}
EOF

Accessible at /my-page

Add a new API endpoint

# In core/app/routes/my_route.py
from fastapi import APIRouter

router = APIRouter()

@router.post("/api/my-endpoint")
async def my_endpoint(request: MyRequest):
    return {"status": "ok"}

Then register in core/app/main.py:

from app.routes import my_route
app.include_router(my_route.router)

Add a database table

# In prisma/schema.prisma
model MyTable {
  id    String  @id @default(cuid())
  name  String
  email String  @unique
}

Then migrate:

npx prisma migrate dev --name add_my_table

Data Flow

Chat Message Flow

ChatInput β†’ Chat Hook β†’ fetch(/v1/chat) β†’ Backend
             ↓
         setState with response
             ↓
         Re-render ChatMessage
             ↓
         Display response

Save to Database

ChatInput β†’ save() β†’ POST /api/chat/saveMessage
                     ↓
                 Backend validates (Pydantic)
                     ↓
                 Save to PostgreSQL (Prisma)
                     ↓
                 Return success

Technology Stack

Layer Technology
Frontend Next.js 14, React 18, TypeScript
Styling Tailwind CSS, HeroUI
Backend FastAPI, Python 3.9+
Database PostgreSQL, Neo4j, Prisma ORM
Auth Auth0
AI OpenAI API
Deploy Vercel, AWS ECS

Important Files

  • src/app/layout.tsx β€” Main layout & navigation
  • src/app/page.tsx β€” Home page
  • src/components/chat/Chat.tsx β€” Chat component
  • core/app/main.py β€” Backend entry point
  • prisma/schema.prisma β€” Database schema
  • .env.local β€” Frontend config
  • core/.env β€” Backend config
  • mkdocs.yml β€” Documentation config

Next Steps

  1. Read Setup Local
  2. Read Contributing
  3. Explore the code!