Horoscope Web Application
Project Overview
This project is a web application that provides daily, weekly, monthly, and yearly horoscopes for the 12 astrological signs. The horoscopes are generated using the Google Gemini API.
The application consists of a Python backend built with FastAPI and a React frontend built with Vite and Material UI.
Project Structure
horoscope/
├── backend/
│ ├── alembic/
│ ├── .venv/
│ ├── alembic.ini
│ ├── config.py
│ ├── create_admin.py
│ ├── database.py
│ ├── horoscope.py
│ ├── initial_data.py
│ ├── main.py
│ ├── models.py
│ ├── requirements.txt
│ └── schemas.py
├── frontend/
│ └── horoscope-app/
│ ├── public/
│ ├── src/
│ ├── index.html
│ ├── package.json
│ └── vite.config.ts
├── Objectives.md
└── README.md
Getting Started
Prerequisites
- Python 3.10 or higher
- Node.js and npm
Backend Setup
- Navigate to the
backenddirectory:cd backend - Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate - Install the dependencies:
pip install -r requirements.txt - Run the database migrations:
alembic upgrade head - Create the initial data (signs and admin user):
python initial_data.py python create_admin.py - Run the backend server:
The backend will be available at
uvicorn main:app --reload --host 0.0.0.0http://localhost:8000.
Frontend Setup
- Navigate to the
frontend/horoscope-appdirectory:cd frontend/horoscope-app - Install the dependencies:
npm install - Run the frontend server:
The frontend will be available at
npm run devhttp://localhost:5173.
Backend
Technologies Used
- Python 3
- FastAPI
- SQLAlchemy with Alembic
- SQLite
- Google Gemini API
API Endpoints
POST /token: Login to get a JWT token.GET /users/me: Get the current user's information.GET /signs: Get a list of all astrological signs.GET /horoscope/{sign}/{timeline}: Get a horoscope for a specific sign and timeline.POST /horoscope/{sign}/{timeline}: Create a new horoscope for a specific sign and timeline (admin only).
Database Schema
The database schema is defined in backend/models.py and consists of the following tables:
users: Stores user information.signs: Stores the 12 astrological signs.user_signs: A many-to-many table that links users to their signs.horoscopes: Stores the generated horoscopes.
Frontend
Technologies Used
- React with Vite
- TypeScript
- Material UI
- Axios
Component Structure
App.tsx: The main component that sets up the routing.components/AppBar.tsx: The top application bar.components/Login.tsx: The login form.components/Home.tsx: The home page that displays the horoscopes.services/api.ts: The Axios instance for making API calls.
Next Steps
- Implement the OIDC SSO with Keycloak.
- Allow users to create accounts and select their signs.
- Implement the export to PDF, HTML, and Word feature.
- Add the alchemical "mascot" bonus feature.
- Write more tests for the backend and frontend.
- Improve the UI/UX of the application.