π 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β/chatsrc/app/admin/page.tsxβ/admin
src/components/
React Components β Reusable, not tied to routes.
chat/β Chat-related componentsadmin/β Admin dashboard componentsnavbar/β Navigation- etc.
src/hook/
Custom React Hooks β named with use* prefix.
useChat.tsβ Chat logic hookuseAuth.tsβ Auth logic hook
core/app/routes/
FastAPI Endpoints β Each file groups related endpoints.
chat.pyβ POST /v1/chat, POST /v1/chat/streamchat_storage.pyβ POST /api/chat/save, etc.tts.pyβ GET/POST /api/ttshealth.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 & navigationsrc/app/page.tsxβ Home pagesrc/components/chat/Chat.tsxβ Chat componentcore/app/main.pyβ Backend entry pointprisma/schema.prismaβ Database schema.env.localβ Frontend configcore/.envβ Backend configmkdocs.ymlβ Documentation config
Next Steps
- Read Setup Local
- Read Contributing
- Explore the code!